简体   繁体   中英

Lstm Keras - How to increase the number of epochs

I am working on binary classification I want to increase the number of epochs in my code this is my data set when i am increasing the value in the dense function i am getting Error when checking target: expected dense_16 to have shape (10,) but got array with shape (1,)

[[   nan  1520.  1295.    nan  8396.  9322. 12715.    nan  5172.  7232.
  11266.    nan 11266.  2757.  4416. 12020. 12111.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.]
 [   nan  3045. 11480.   900.  5842. 11496.  4463.    nan 11956.   900.
  10400.  8022.  2504. 12106.     0.     0.     0.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.]
 [   nan  9307. 12003.  2879.  6398.  9372.  4614.  5222.    nan    nan
   2879. 10364.  6923.  4709.  4860. 11871.     0.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.]
 [   nan  6689.  2818. 12003.  6480.    nan     0.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.]
 [   nan  3395.  1087. 11904.  7232.  8840. 10115.  4494. 11516.  7441.
   8535. 12106.     0.     0.     0.     0.     0.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.]
 [   nan  1287.   420.  4070. 11087.  7410. 12186.  2387. 12111.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.
      0.     0.     0.     0.     0.     0.     0.     0.     0.     0.]]

I want to increase the number of epochs here

PositiveOrNegativeLabel=np.array([[1]])
PositiveOrNegativeLabel=PositiveOrNegativeLabel.reshape(1,-1)
PositiveOrNegativeLabel.shape
inputBatch =inputBatch.reshape(1,6,30)
print(PositiveOrNegativeLabel.shape)
model=Sequential()
model.add(LSTM(100,input_shape=(6,30)))
model.add(Dense(1,activation="sigmoid"))
model.compile(loss='mean_absolute_error',optimizer='adam',metrics=['accuracy'])
model.fit(inputBatch,PositiveOrNegativeLabel,batch_size=24,verbose=1)

this is the value error i am getting ValueError: Error when checking target: expected dense_16 to have shape (10,) but got array with shape (1,)

I believe this may be a mismatch between the output of the last layer and your expected output dimensions. One easy way to fix this is to change your line

model.add(Dense(1,activation="sigmoid"))

to:

model.add(Dense(10,activation="sigmoid"))

Could you list all variables you are using and the dimensions of them, if you need further assistance?

Additionally, you have some whitespace issues here not in accordance with PEP8. I suggest you check out: https://www.python.org/dev/peps/pep-0008/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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