keras--将tensor转换为numpy

tensor转换为numpy

from keras import backend as K
tensor = K.constant([1, 2, 3])
numpy = K.eval(tensor)
print(type(tensor), type(numpy))
print(tensor)
print(numpy)

>>> <class 'tensorflow.python.framework.ops.EagerTensor'> <class 'numpy.ndarray'>
	tf.Tensor([1. 2. 3.], shape=(3,), dtype=float32)
	[1. 2. 3.]
发布了83 篇原创文章 · 获赞 4 · 访问量 5348

猜你喜欢

转载自blog.csdn.net/weixin_43486780/article/details/105560693
今日推荐