Numpy to Tensor
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Numpy to Tensor相关的知识,希望对你有一定的参考价值。
numpy数据转成Tensor小Demoimport 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)
以上是关于Numpy to Tensor的主要内容,如果未能解决你的问题,请参考以下文章