autonomio / talos

Hyperparameter Experiments with TensorFlow and Keras
https://autonom.io
MIT License
1.62k stars 268 forks source link

ValueError: Error when checking target: expected dense_20 to have shape (59,) but got array with shape (1,) #329

Closed kskaran94 closed 5 years ago

kskaran94 commented 5 years ago

Thanks so much for coming here to raise an issue. Please take a moment to 'check' the below boxes:

You can provide the code in pastebin / gist or any other format you like.


  1. (11541, 59) and (11541, 1)

  2. p = {'lr': (0.5, 5, 10), 'batch_size': (2, 30, 10), 'epochs': [150], 'optimizer': [Adam, Nadam, RMSprop]}

  3. 
    def autoencoder(x_train, y_train, x_val, y_val, params):
      input_dim = X_train_0.shape[1] #num of predictor variables, 
      encoding_dim = 32
      hidden_dim = int(encoding_dim / 2)
      learning_rate = 1e-3
    
      input_layer = Input(shape=(input_dim, ))
      encoder = Dense(encoding_dim, activation="relu")(input_layer)
      encoder = Dense(hidden_dim, activation="relu")(encoder)
      decoder = Dense(hidden_dim, activation="relu")(encoder)
      decoder = Dense(encoding_dim, activation="relu")(decoder)
      decoder = Dense(input_dim, activation="linear")(decoder)
      autoencoder = Model(inputs=input_layer, outputs=decoder)
    
      autoencoder.compile(loss='mean_squared_error',
                  # here we add a regulizer normalization function from Talos
                  optimizer=params['optimizer'](lr=lr_normalizer(params['lr'],params['optimizer'])),
                  metrics=['acc'])
    
      history = autoencoder.fit(x_train, y_train, 
                        #validation_data=[x_val, y_val],
                        batch_size=params['batch_size'],
                        epochs=params['epochs'],
                        verbose=0)
    
      return history, autoencoder
mikkokotila commented 5 years ago

Have you tried to run your model without Talos? The kind of error you are getting is usually a result of error in the Keras model data inputs.

kskaran94 commented 5 years ago

My Keras Model is working fine

mikkokotila commented 5 years ago

Can you share your Scan() command and the full trace for the issue.

mikkokotila commented 5 years ago

Closing this for inactivity. Feel free to reopen if still relevant.