我是神经网络的新手,我正在尝试创建图像分类器。每当我使用tensorboard并在 model.fit 的回调中调用它时,就会发生这些错误。如果我删除张量板,该程序将正常工作
我已经尝试使用在线上的这些代码初始化变量,但仍然会产生错误
22.99
EU
这是我拥有的实际代码
uninitialized_vars = []
for var in tf.all_variables():
try:
sess.run(var)
except tf.errors.FailedPreconditionError:
uninitialized_vars.append(var)
init_new_vars_op = tf.initialize_variables(uninitialized_vars)
这些错误在运行程序后发生
def trainModel(self):
X_train,y_train = self.getTrainingData()
X_test,y_test = self.getTestingData()
run_opts = tf.RunOptions(report_tensor_allocations_upon_oom = True)
tensorboard = TensorBoard(log_dir="logs/{}".format(time()))
self.model.compile(loss=keras.losses.categorical_crossentropy,
optimizer='sgd',
metrics=['accuracy'], options = run_opts)
self.model.fit(
X_train,
y_train,
batch_size=1,
validation_data=(X_test, y_test),
epochs=5, callbacks=[tensorboard])
self.model.summary()
score = self.model.evaluate(X_test, y_test, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])
我正在使用 python 3.5.2 , tensorflow 1.5.0 和 ubuntu 16.04 整个代码在here
中