如何在TensorFlow中更改变量的形状? [英] How can I change the shape of a variable in TensorFlow?

查看:135
本文介绍了如何在TensorFlow中更改变量的形状?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

TensorFlow教程说,在创建时,我们需要指定张量的形状.该形状将自动成为张量的形状.它还说TensorFlow提供了重塑变量的高级机制.我怎样才能做到这一点?有代码示例吗?

TensorFlow tutorial says that at creation time we need to specify the shape of tensors. That shape automatically becomes the shape of the tensor. It also says that TensorFlow provides advanced mechanisms to reshape variables. How can I do that? Any code example?

推荐答案

看看形状和形状" .它描述了可用的不同形状转换.

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.

这篇关于如何在TensorFlow中更改变量的形状?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆