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
在运行keras文件时,我遇到了这种类型的错误。我不知道为什么会出现索引错误。我甚至没有使用它。我是keras的新手请帮忙
答案 0 :(得分:1)
我在model.fit中输入了一个错误的数组。我发现了错误