【小白入门tensorflow】tensor的shape

    科技2022-07-10  99

    获取一个tensor类型变量的shape

    import tensorflow as tf import numpy a=tf.random.normal([4,28,28,3]) print(type(a)) print(a.shape) print(a[1].shape) print(a[1,2].shape) print(a[1,2,3].shape) print(a[1,2,1,1].shape)

    之前报错是因为我把shape写成了shape(),感觉在入门深度学习的路上又像我当初入门C语言的时候,犯很低级的错误,哭辽 报错信息如下:

    print(a.shape()) TypeError: 'TensorShape' object is not callable
    Processed: 0.027, SQL: 8