tensorflow 细节用法

array  与 tensor 之间的互相转换

https://blog.csdn.net/accumulate_zhang/article/details/78867890

import tensorflow as tf
import numpy as np

a=np.array([[1,2,3],[4,5,6],[7,8,9]])
print (a)
b=tf.constant(a)

with tf.Session() as sess:
    print (b)
    for x in b.eval():      #b.eval()就得到tensor的数组形式
        print (x)

    print ('a是数组',a)

    tensor_a=tf.convert_to_tensor(a)
    print ('现在转换为tensor了...',tensor_a)

猜你喜欢

转载自blog.csdn.net/qq_16761099/article/details/79838706