Numpy to Tensor

numpy数据转成Tensor小Demo

import numpy as np
import tensorflow as tf

temp_np = np.zeros((3,3))
print(type(temp_np))#<class 'numpy.ndarray'>
tensor_temp = tf.convert_to_tensor(temp_np)#<class 'tensorflow.python.framework.ops.Tensor'>
print(type(tensor_temp))

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    tensor_var = sess.run(tensor_temp)
    print(tensor_var)

猜你喜欢

转载自blog.51cto.com/5669384/2415629