recurrent-neural-network - 如何改变 rnn 网络的输出形状?
问题描述
如何将tf.nn.dynamic_rnn
[batch_size, max_stepsize, num_hidden] 的输出更改为 [batch_size, num_hidden]?
self.outputs = tf.reshape(outputs, [-1, num_hidden])
给出 [batch_size * max_stepsize, num_hidden] 但我正在寻找 [batch_size , num_hidden] 而我不想使用 tf.reshape(outputs, [batch_size, num_hidden])
. 我试过了shape = tf.shape(outputs)[1]
,tf.squeeze(outputs, shape)
但它给出了错误:
TypeError: Expected list for 'axis' argument to 'squeeze' Op, not <tf.Tensor 'lstm/strided_slice:0' shape=() dtype=int32>.
任何解决方案?
解决方案
推荐阅读
- azure - 如何将 ADLS gen2 文件夹/文件名动态传递到 ADF 或 Databricks 中的 Databricks Notebook
- java - 在不改变 server.xml 或 tomcat/web.xml 的情况下添加 tomcat 监听器 LifecycleListener
- c# - C# 事件调用和同步
- python-3.x - Python - 使用 most_common 的预期列表与给定的数量较少的列表不同
- r - 如何在 R 上创建我的逻辑回归图的可发布表
- javascript - 用于分析 chrome 扩展中的文本的 Javascript
- azure - 在 Azure DevOps 管道中运行使用 Azure API 和其他基础结构的单元测试
- python - 连接到 PostgreSQL 数据库时 Python 打印加载“动画”
- python - Django 模型对象有任何长度函数吗?
- javascript - 如何将一个 kist 拆分为多个数组并在 thymleaf 中单独求和?