美文网首页
tf.constant

tf.constant

作者: Yuri7 | 来源:发表于2021-01-27 10:15 被阅读0次

    tf.constant(value,dtype=None,shape=None,name=’Const’)

    创建一个常量tensor,按照给出value来赋值,可以用shape来指定其形状。value可以是一个数,也可以是一个list。
    如果是一个数,那么这个常亮中所有值的按该数来赋值。
    如果是list,那么len(value)一定要小于等于shape展开后的长度。赋值时,先将value中的值逐个存入。不够的部分,则全部存入value的最后一个值。

    a = tf.constant(2,shape=[2])
    b = tf.constant(2,shape=[2,2])
    c = tf.constant([1,2,3],shape=[6])
    d = tf.constant([1,2,3],shape=[3,2])
    

    相关文章

      网友评论

          本文标题:tf.constant

          本文链接:https://www.haomeiwen.com/subject/jqiozktx.html