Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. def create_model():
  2. embedding_layer = Embedding(input_dim=100, output_dim=300,
  3. input_length=100)
  4. model = Sequential()
  5. model.add(embedding_layer)
  6. model.add(Dropout(0.2))
  7. model.add(Conv1D(filters=100, kernel_size=4, padding='same', activation='relu'))
  8. model.add(MaxPooling1D(pool_size=4))
  9. model.add(LSTM(units=100, return_sequences=True))
  10. model.add(GlobalMaxPooling1D())
  11. model.add(Dense(1, activation='sigmoid'))
  12. ###### multiclassification #########
  13. #model.add(Dense(3, activation='softmax')) #I want to replace the above line with this for multi-classification but this didnt work
  14. model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  15.  
  16. Programs/anaconda3/lib/python3.6/site-packages/keras/engine/training.py in _standardize_input_data(data=array([1, 1, 2, 1, 0, 0, 2, 1, 1, 2, 0, 0, 1, 1,...2, 0, 2, 1, 0, 2, 0, 1, 0, 0,
  17. 1, 2, 2, 0]), names=['dense_1'], shapes=[(None, 3)], check_batch_axis=False, exception_prefix='model target')
  18. 128 raise ValueError(
  19. 129 'Error when checking ' + exception_prefix +
  20. 130 ': expected ' + names[i] +
  21. 131 ' to have shape ' + str(shapes[i]) +
  22. 132 ' but got array with shape ' +
  23. --> 133 str(array.shape))
  24. array.shape = (280, 1)
  25. 134 return arrays
  26. 135
  27. 136
  28. 137 def _standardize_sample_or_class_weights(x_weight, output_names, weight_type):
  29.  
  30. ValueError: Error when checking model target: expected dense_1 to have shape (None, 3) but got array with shape (280, 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement