Keras 1D CNN: How to specify dimension correctly?

和自甴很熟 提交于 2019-11-30 21:10:20
  1. Yes, your dataset should be a 3d tensor.

  2. The correct input shape (for tensorflow backend) is (sample_number,sample_size,channel_number). You can check that from your error message, "the expected dimension was (None, 3197, 1)".

'None' refers to an arbitrary size dimension, as it is expected to the number of samples used in training.

So in your situation the correct shape is (570, 3197, 1).

If you happen to use theano backend you should put your channel dimension first: (sample_number,channel_number,sample_size) or in your paricular case

(570,1, 3197)

Suppose the shape of your data is,

>>> data.shape()
(m, n)

So, you should add a new axis as the channel axis,

>>> data = data[..., np.newaxis]
>>> data.shape()
(m, n, 1)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!