{"action":"created","issue":{"url":"https://api.github.com/repos/keras-team/keras/issues/10128","repository_url":"https://api.github.com/repos/keras-team/keras","labels_url":"https://api.github.com/repos/keras-team/keras/issues/10128/labels{/name}","comments_url":"https://api.github.com/repos/keras-team/keras/issues/10128/comments","events_url":"https://api.github.com/repos/keras-team/keras/issues/10128/events","html_url":"https://github.com/keras-team/keras/issues/10128","id":320519567,"number":10128,"title":"Conv1D after MaxPooling1D Negative Dimension Error","user":{"login":"mobiusinversion","id":955489,"avatar_url":"https://avatars1.githubusercontent.com/u/955489?v=4","gravatar_id":"","url":"https://api.github.com/users/mobiusinversion","html_url":"https://github.com/mobiusinversion","followers_url":"https://api.github.com/users/mobiusinversion/followers","following_url":"https://api.github.com/users/mobiusinversion/following{/other_user}","gists_url":"https://api.github.com/users/mobiusinversion/gists{/gist_id}","starred_url":"https://api.github.com/users/mobiusinversion/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mobiusinversion/subscriptions","organizations_url":"https://api.github.com/users/mobiusinversion/orgs","repos_url":"https://api.github.com/users/mobiusinversion/repos","events_url":"https://api.github.com/users/mobiusinversion/events{/privacy}","received_events_url":"https://api.github.com/users/mobiusinversion/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-05-05T15:50:14Z","updated_at":"2018-05-05T19:47:02Z","closed_at":null,"author_association":"NONE","body":"Hello,\r\n\r\nI am creating a sequential model with alternating `Conv1D` and `MaxPooling1D` layers.  \r\n\r\nThe last line of this code raises an error\r\n \r\n    model = Sequential()\r\n    model.add(Embedding(len(word_index) + 1, embedding_size,\r\n                        weights=[embedding_matrix],\r\n                        input_length=MAX_SEQUENCE_LENGTH,\r\n                        trainable=True))\r\n    model.add(SpatialDropout1D(0.2))\r\n    model.add(Conv1D(128, 3, activation='relu'))\r\n    model.add(MaxPooling1D(3))\r\n    model.add(Conv1D(128, 3, activation='relu'))\r\n    model.add(MaxPooling1D(3))\r\n    model.add(Conv1D(128, 3, activation='relu'))\r\n\r\nThe error is \r\n\r\n    File \"/Users/david/PycharmProjects/deep-learning-with-keras/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py\", line 627, in call_cpp_shape_fn\r\n    require_shape_fn)\r\n    File \"/Users/david/PycharmProjects/deep-learning-with-keras/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py\", line 691, in _call_cpp_shape_fn_impl\r\n    raise ValueError(err.message)\r\n    ValueError: Negative dimension size caused by subtracting 3 from 2 for 'conv1d_3/convolution/Conv2D' (op: 'Conv2D') with input shapes: [?,1,2,128], [1,3,128,128].\r\n\r\nWhat is goinf wrong here?  This example should to my knowledge be consistent with [this Keras blog post](https://blog.keras.io/using-pre-trained-word-embeddings-in-a-keras-model.html). "},"comment":{"url":"https://api.github.com/repos/keras-team/keras/issues/comments/386830258","html_url":"https://github.com/keras-team/keras/issues/10128#issuecomment-386830258","issue_url":"https://api.github.com/repos/keras-team/keras/issues/10128","id":386830258,"user":{"login":"vkk800","id":19554001,"avatar_url":"https://avatars3.githubusercontent.com/u/19554001?v=4","gravatar_id":"","url":"https://api.github.com/users/vkk800","html_url":"https://github.com/vkk800","followers_url":"https://api.github.com/users/vkk800/followers","following_url":"https://api.github.com/users/vkk800/following{/other_user}","gists_url":"https://api.github.com/users/vkk800/gists{/gist_id}","starred_url":"https://api.github.com/users/vkk800/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vkk800/subscriptions","organizations_url":"https://api.github.com/users/vkk800/orgs","repos_url":"https://api.github.com/users/vkk800/repos","events_url":"https://api.github.com/users/vkk800/events{/privacy}","received_events_url":"https://api.github.com/users/vkk800/received_events","type":"User","site_admin":false},"created_at":"2018-05-05T19:47:02Z","updated_at":"2018-05-05T19:47:02Z","author_association":"CONTRIBUTOR","body":"How long is the sequence you're trying to input? The problem is probably due to you using `padding='valid'` option (the default) in the convolution while your sequence is shorter than 3 units. If this is the case, this is not a bug in Keras, but simply due to the fact that you can't use a convolution kernel of width 3 if your data is less than 3 units.\r\n\r\nIf this is indeed the case, you can fix it by either using longer data sequences or using another padding with convolutions (which will just append zeros to the data to keep it the same size after applying the convolution)."}}
{"actor":{"display_login":"vkk800"}}