Я тренирую модель, основанную на логистической регрессии, а также пытаюсь просмотреть график вычислений в тензорной доске. Однако, когда я запускаю код, я получаю сообщение об ошибке, указанное ниже.
Без прикрепления обратного вызова мой model.fit () работает отлично. Кроме того, как было предложено, я добавил update_freq = 1000
logdir = os.path.join("logs", datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))
tensorboard_callback = tf.keras.callbacks.TensorBoard(logdir, histogram_freq=1, update_freq=1000)
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)])
model.compile(optimizer='sgd',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(np.matrix(train_X), np.matrix(train_y).T, epochs=10, callbacks=[tensorboard_callback])
Однако я получаю эту ошибку:
AttributeError Traceback (most recent call last)
<ipython-input-73-90c175274a55> in <module>()
8 metrics=['accuracy'])
9
---> 10 model.fit(np.matrix(train_X), np.matrix(train_y).T, epochs=20, callbacks=[tensorboard_callback])
/usr/local/lib/python3.6/dist-packages/tensorflow/python/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, max_queue_size, workers, use_multiprocessing, **kwargs)
878 """Returns the loss value & metrics values for the model in test mode.
879
--> 880 Computation is done in batches.
881
882 Arguments:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/engine/training_arrays.py in model_iteration(model, inputs, targets, sample_weights, batch_size, epochs, verbose, callbacks, val_inputs, val_targets, val_sample_weights, shuffle, initial_epoch, steps_per_epoch, validation_steps, mode, validation_in_fit, **kwargs)
250 # Loop over dataset for the specified number of steps.
251 target_steps = steps_per_epoch
--> 252
253 step = 0
254 while step < target_steps:
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/callbacks.py in on_epoch_begin(self, epoch, logs, mode)
235 'to the batch update (%f). Check your callbacks.', hook_name,
236 delta_t_median)
--> 237
238 def _call_begin_hook(self, mode):
239 """Helper function for on_{train|test|predict}_begin methods."""
/usr/local/lib/python3.6/dist-packages/tensorflow/python/keras/callbacks.py in on_epoch_begin(self, epoch, logs)
1139 samples. Note that writing too frequently to TensorBoard can slow down
1140 your training.
-> 1141 profile_batch: Profile the batch to sample compute characteristics. By
1142 default, it will profile the second batch. Set profile_batch=0 to
1143 disable profiling. Must run in TensorFlow eager mode.
AttributeError: 'NoneType' object has no attribute 'fetches'
Нужна помощь!