# -*- 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.]
# -*- 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.]