tf.keras - 如何在 tf.keras 中指定输出层的单位?
问题描述
在我的数据集中,单个输入和输出的形状是 15 x 61。我指定 input_shape=(15,61)。这意味着 15 x 61 到 15 x 61 之间的映射,这不是分类问题。输出层中的单位规范应该是什么?
model = tf.keras.models.Sequential([tf.keras.layers.Dense(units=128,input_shape =(15,61),
tf.keras.layers.Dense(units=128, activation=tf.nn.relu),
tf.keras.layers.Dense(units=, activation=tf.nn.softmax)])
解决方案
您在 Dense 上的 Keras turorial中拥有所有信息。如果你想进行分类,输出形状必须是类的数量。如果您希望 15 * 61 作为输入和 15*61 作为输出,只需将所有这些 : 展平15 x 61 = 915
,因此采用 915 大小的图层并输出 915 大小的图层,然后对其进行整形以获得初始形状。
推荐阅读
- .net - 无法从 C++/CLI 项目添加对 C# DLL 的引用
- javascript - Nuxt.js:如何使用不同URL的同一页面并根据URL切换要显示的组件
- elasticsearch - 弹性搜索 - 聚合分页
- typescript - Primeng p-radioButton - 文本作为锚点
- ios - 在多个视图移动时更改旋转布局
- javascript - 使用 Javascript 显示 Div 无法在 Select 上工作
- java - 内存已满和 GC 需要很长时间
- accessibility - 如何根据 dom 命令部分使画外音朗读?
- c# - C# 尝试捕获和异常并抛出确切的异常备份
- c# - 现有对象突然变为空。无法从数据库生成打印预览。C#