tf.constant()函数介绍和示例
tf.constant(value, shape, dtype=None, name=None)
释义:生成常量
- value,值
- shape,数据形状
- dtype,数据类型
- name,名称
示例:
import tensorflow as tf
c = tf.constant(-1, shape=[2,3], dtype=tf.float32, name=None)
with tf.Session() as sess:
print(sess.run(c))
[[-1. -1. -1.]
[-1. -1. -1.]]