-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
36 lines (30 loc) · 907 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
# _*_ coding:utf-8 _*_
"""
@author: JiangZongKang
@contact: [email protected]
@file: test.py
@time: 2018/9/4 17:12
"""
import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# # 实现一个加法运算
# a = tf.constant(5.0)
# b = tf.constant(6.0)
#
# sum1 = tf.add(a, b)
# plt = tf.placeholder(tf.float32, [2, 3])
# with tf.Session(config=tf.ConfigProto(log_device_placement=True)) as sess, tf.device('/gpu:0'):
# print(sess.run([a, b, sum1]))
# print(sess.run(plt, feed_dict={plt: [[1, 2, 3], [4, 5, 6]]}))
#
# # print(sum1.eval())
a = tf.constant([1, 2, 3, 4, 5])
var = tf.Variable(tf.random_normal([2, 3], mean=0.0, stddev=1.0))
var_init = tf.global_variables_initializer()
# print(a,var)
with tf.Session() as sess:
sess.run(var_init)
filewriter = tf.summary.FileWriter('./tmp/summary/test', graph=sess.graph)
print(sess.run([a, var]))