netrack / keras-metrics

Metrics for Keras. DEPRECATED since Keras 2.3.0
MIT License
164 stars 23 forks source link

Failure when model.fit parameter verbose set to 2 #1

Closed EldarMu closed 6 years ago

EldarMu commented 6 years ago

Tensorflow backend Model parameters: 2 GRU followed by 1 dense, monitor binary crossentropy

Model tested with metrics precision and recall, fails with parameter verbose set to 2, passes when parameter is set to 0 or 1.

model = Sequential()
model.add(GRU(45, input_shape=[maximum_smiles_size, char_vec_len], return_sequences=True, go_backwards=True,
activation='tanh', recurrent_regularizer=rgr.l2(l2)))
model.add(GRU(30, activation='tanh', recurrent_dropout=.5))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer=RMSprop(lr=0.0007), metrics=[keras_metrics.precision(), keras_metrics.recall()])
history = model.fit(train_x[0:7000,:,:], train_y[0:7000], epochs=200, batch_size=100,
validation_data=(test_x, test_y), verbose=2)
Traceback (most recent call last):

File "mypathdatanotshowingitonreddit", line 220, in <module>

validation_data=(test_x, test_y), verbose=2)

File "mypathdatanotshowingitonreddit/lib/python3.5/site-packages/keras/models.py", line 963, in fit

validation_steps=validation_steps)

File "mypathdatanotshowingitonreddit/lib/python3.5/site-packages/keras/engine/training.py", line 1705, in fit

validation_steps=validation_steps)

File "mypathdatanotshowingitonreddit/lib/python3.5/site-packages/keras/engine/training.py", line 1255, in _fit_loop

callbacks.on_epoch_end(epoch, epoch_logs)

File "mypathdatanotshowingitonreddit/lib/python3.5/site-packages/keras/callbacks.py", line 77, in on_epoch_end

callback.on_epoch_end(epoch, logs)

File "mypathdatanotshowingitonreddit/lib/python3.5/site-packages/keras/callbacks.py", line 339, in on_epoch_end

self.progbar.update(self.seen, self.log_values)

File "mypathdatanotshowingitonreddit/lib/python3.5/site-packages/keras/utils/generic_utils.py", line 426, in update

self._values[k][0] / max(1, self._values[k][1]))

IndexError: invalid index to scalar variable.
ybubnov commented 6 years ago

@EldarMu, Hi, thank you for the issue! What keras version are you using? I can't reproduce the issue with 2.1.5 version.

EldarMu commented 6 years ago

@ybubnov I am using Keras 2.1.5

It's working for me now too and I'm not sure why it started. If It crops up again at some point, I'll message about reopening