tensor转化为ndarray

# -*- coding: utf-8 -*-
import tensorflow as tf
# 创建张量
t = tf.constant([1, 2, 3, 4], tf.float32)
# 创建会话
session = tf.Session()
# 张量转化为ndarray
array = session.run(t)
# 打印其数据类型与其值
print(type(array))
print(array)

<class 'numpy.ndarray'>
[ 1.  2.  3.  4.]

 

posted on 2021-04-07 20:49  cltt  阅读(983)  评论(0编辑  收藏  举报

导航