简体   繁体   English

Keras中RNN模型的input_size是多少

[英]What's the input_size for the RNN Model in Keras

I'm just starting with deep learning, and I've been told that Keras would be the best library for beginners. 我只是从深度学习开始,有人告诉我Keras是最适合初学者的库。

Before that, for the sake of learning, I built a simple feed forward network using only numpy so I could get the feel of it. 在此之前,为了学习,我仅使用numpy构建了一个简单的前馈网络,因此可以体会到这一点。

In this case, the shape of the weight matrix was (len(X[0]), num_neurons) . 在这种情况下,权重矩阵的形状为(len(X[0]), num_neurons) The number of features and the number of neurons. 特征的数量和神经元的数量。 And it worked. 而且有效。

Now, I'm trying to build a simple RNN using Keras. 现在,我正在尝试使用Keras构建一个简单的RNN。 My data has 7 features and the size of the layer would be 128. 我的数据有7个要素,层的大小为128。

But if I do something like model.add(Dense(128, input_dim=(7, 128))) it says it's wrong. 但是,如果我执行诸如model.add(Dense(128, input_dim=(7, 128)))则表示这是错误的。

So I have no idea what this input_dim should be. 所以我不知道这个input_dim应该是什么。

My data has 5330 data points and 7 features (shape is (5330, 7)). 我的数据有5330个数据点和7个要素(形状为(5330,7))。 Can someone tell me what the input_dim should be and why? 有人可以告诉我input_dim应该是什么,为什么?

Thank you. 谢谢。

The input_dim is just the shape of the input you pass to this layer. input_dim只是您传递到此层的输入的形状。 So: 所以:

  • input_dim = 7

There are other options, such as: 还有其他选项,例如:

  • input_shape=(7,) -- This argument uses tuples instead of integers, good when your input has more than one dimension input_shape=(7,) -此参数使用tuples而不是整数,当您的输入具有多个维度时很好
  • batch_input_shape=(batch_size,7) -- This is not usually necessary, but you use it in cases you need a fixed batch size (there are a few layer configurations that demand that) batch_input_shape=(batch_size,7) -通常不是必须的,但是如果需要固定的批处理大小(有一些层配置要求使用),可以使用它

Now, the size of the output in a Dense layer is the units argument. 现在,Dense层中输出的大小是units参数。 Which is 128 in your case and should be equal to num_neurons . 在您的情况下为128,应等于num_neurons

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM