且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 TensorFlow 中更改变量的形状?

更新时间:2023-12-02 11:36:10

看一看 shapes-and-shaping 来自 TensorFlow 文档.它描述了可用的不同形状变换.

Take a look at shapes-and-shaping from TensorFlow documentation. It describes different shape transformations available.

最常见的函数可能是 tf.reshape,其中类似于它的 numpy 等价物.只要元素数量保持不变,它允许您指定所需的任何形状.文档中提供了一些示例.

The most common function is probably tf.reshape, which is similar to its numpy equivalent. It allows you to specify any shape that you want as long as the number of elements stays the same. There are some examples available in the documentation.