#tensor 常量 转 numpy
a = tf.constant([1,2,3])
a_numpy = a.numpy()
#tensor 转list
a = tf.constant([1,2,3])
a_numpy = list(a.numpy())
tensor变量转numpy
#tensor 常量 转 numpy
a = tf.Variable([1,2,3])
a_numpy = list(a.numpy())
tensor 变量设置值
import tensorflow as tf
import tensorflow.python.keras.backend as K
varib = tf.Variable([1,2])
new_value = np.array([2,3])
K.set_value(varib, new_value)
print(K.eval(varib))
print(varib.numpy())