Keras ValueError: I/O operation on closed file
<p>I am trying to write a single layer network. When it starts to train through <code>model.fit</code>, at some random epoch it will throw the following error:</p>

<p><code>ValueError: I/O operation on closed file</code></p>

<p>Here is how I am using <code>model.fit</code></p>

<p><code>my_model = model.fit(train_x, train_y, batch_size=100, nb_epoch=20, show_accuracy=True, verbose=1)</code></p>

<p>Please let me know if you have any thoughts or is encountering the same problem.</p>

<p>Thanks</p>

<p>Here is the full output of the error:</p>

<pre><code>Epoch 1/20
47900/60816 [======================&gt;.......] - ETA: 3s - loss: 0.1688 - acc: 0.9594
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
&lt;ipython-input-4-273f2082a322&gt; in &lt;module&gt;()
     14 model.compile(loss='binary_crossentropy', optimizer='adadelta')
     15 
---&gt; 16 model.fit(train_x, train_y, batch_size=100, nb_epoch=20, show_accuracy=True, verbose=1)
     17 score = model.evaluate(test_x, test_y, show_accuracy=True, verbose=0)
     18 print('Test loss:', score[0])

/usr/local/lib/python2.7/dist-packages/keras/models.pyc in fit(self, X, y, batch_size, nb_epoch, verbose, callbacks, validation_split, validation_data, shuffle, show_accuracy, class_weight, sample_weight)
    699                          verbose=verbose, callbacks=callbacks,
    700                          val_f=val_f, val_ins=val_ins,
--&gt; 701                          shuffle=shuffle, metrics=metrics)
    702 
    703     def predict(self, X, batch_size=128, verbose=0):

/usr/local/lib/python2.7/dist-packages/keras/models.pyc in _fit(self, f, ins, out_labels, batch_size, nb_epoch, verbose, callbacks, val_f, val_ins, shuffle, metrics)
    321                     batch_logs[l] = o
    322 
--&gt; 323                 callbacks.on_batch_end(batch_index, batch_logs)
    324 
    325                 epoch_logs = {}

/usr/local/lib/python2.7/dist-packages/keras/callbacks.pyc in on_batch_end(self, batch, logs)
     58         t_before_callbacks = time.time()
     59         for callback in self.callbacks:
---&gt; 60             callback.on_batch_end(batch, logs)
     61         self._delta_ts_batch_end.append(time.time() - t_before_callbacks)
     62         delta_t_median = np.median(self._delta_ts_batch_end)

/usr/local/lib/python2.7/dist-packages/keras/callbacks.pyc in on_batch_end(self, batch, logs)
    187         # will be handled by on_epoch_end
    188         if self.verbose and self.seen &lt; self.params['nb_sample']:
--&gt; 189             self.progbar.update(self.seen, self.log_values)
    190 
    191     def on_epoch_end(self, epoch, logs={}):

/usr/local/lib/python2.7/dist-packages/keras/utils/generic_utils.pyc in update(self, current, values)
     59             prev_total_width = self.total_width
     60             sys.stdout.write("\b" * prev_total_width)
---&gt; 61             sys.stdout.write("\r")
     62 
     63             numdigits = int(np.floor(np.log10(self.target))) + 1

/usr/local/lib/python2.7/dist-packages/ipykernel/iostream.pyc in write(self, string)
    315 
    316             is_child = (not self._is_master_process())
--&gt; 317             self._buffer.write(string)
    318             if is_child:
    319                 # newlines imply flush in subprocesses

ValueError: I/O operation on closed file
</code></pre>