user169703
user169703

Reputation: 66

__index__ returned non-int (type NoneType)

    92 adam = optimizers.Adam(lr = learning_rate)
     93 model.compile(optimizer=adam, loss='mse',metrics=['accuracy'])
---> 94 model.fit({'train_im':trainim}, {'main_output':lableim}, batch_size=batch_size, epochs=epochs, verbose=1)
     95 model.save(directory_log + 'my_model.h5')

/usr/local/lib/python3.5/dist-packages/keras/engine/training.py in fit(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, **kwargs)
   1579             class_weight=class_weight,
   1580             check_batch_axis=False,
-> 1581             batch_size=batch_size)
   1582         # Prepare validation data.
   1583         do_validation = False

/usr/local/lib/python3.5/dist-packages/keras/engine/training.py in _standardize_user_data(self, x, y, sample_weight, class_weight, check_batch_axis, batch_size)
   1423         sample_weights = [_standardize_weights(ref, sw, cw, mode)
   1424                           for (ref, sw, cw, mode)
-> 1425                           in zip(y, sample_weights, class_weights, self._feed_sample_weight_modes)]
   1426         _check_array_lengths(x, y, sample_weights)
   1427         _check_loss_and_target_compatibility(y,

/usr/local/lib/python3.5/dist-packages/keras/engine/training.py in <listcomp>(.0)
   1422                                                    self._feed_output_names)
   1423         sample_weights = [_standardize_weights(ref, sw, cw, mode)
-> 1424                           for (ref, sw, cw, mode)
   1425                           in zip(y, sample_weights, class_weights, self._feed_sample_weight_modes)]
   1426         _check_array_lengths(x, y, sample_weights)

/usr/local/lib/python3.5/dist-packages/keras/engine/training.py in _standardize_weights(y, sample_weight, class_weight, sample_weight_mode)
    568     else:
    569         if sample_weight_mode is None:
--> 570             return np.ones((y.shape[0],), dtype=K.floatx())
    571         else:
    572             return np.ones((y.shape[0], y.shape[1]), dtype=K.floatx())

/usr/local/lib/python3.5/dist-packages/numpy/core/numeric.py in ones(shape, dtype, order)
    190 
    191     """
--> 192     a = empty(shape, dtype, order)
    193     multiarray.copyto(a, 1, casting='unsafe')
    194     return a

while running the keras file I am getting this type of error. I don't know why is it giving an index error. I am not even using it. I am new to keras Please help

Upvotes: 2

Views: 5725

Answers (1)

user169703
user169703

Reputation: 66

I was feeding a wrong array in model.fit. I found the error

Upvotes: 1

Related Questions