Python Tensorflow Tensorboard在Windows中的 "NotFoundError "错误信息。

问题描述 投票:2回答:1

我在Windows 10中使用Tensorflow与Python 3.7.4(64位)。

我已经建立了一个卷积神经网络模型,它在Jupyter中运行良好。现在我想用Tensorboard来可视化它的性能。但在尝试设置时,我得到了一条错误信息。

# Setting up Tensorboard to view model performance 
NAME = "Trains_vs_Cars_16by2_CNN_{}".format(int(time.time()))
tensorboard = TensorBoard(log_dir="logs/{}".format(NAME))

model.fit(X, y,
      batch_size=25,
      epochs=5,
      validation_split=0.2,
      callbacks=[tensorboard])

# ERROR MESSAGE 
     NotFoundError                             Traceback (most recent call last)
     <ipython-input-6-c627053c0717> in <module>
     67           epochs=5,
     68           validation_split=0.2,
---> 69           callbacks=[tensorboard])

这个页面上的一个海报(https:/github.comtensorflowtensorboardissues2023#。)提到有一个windows特有的Tensorflow bug。我也遇到了这样的问题吗?我是Tensorflow (和Python)的新手。

谢谢!我在使用Tensorflow和Python 3.4。

python windows tensorflow tensorboard
1个回答
0
投票

你的不是windows特有的Tensorflow bug。我已经使用了你的代码,并做了一些小的修改,现在我能够使用Tensorboard来可视化模型的性能。

请参考下面的完整工作代码

# Load the TensorBoard notebook extension
%load_ext tensorboard

import tensorflow as tf
print(tf.__version__)
import datetime, os

fashion_mnist = tf.keras.datasets.fashion_mnist

(x_train, y_train),(x_test, y_test) = fashion_mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

def create_model():
  return tf.keras.models.Sequential([
    tf.keras.layers.Flatten(input_shape=(28, 28)),
    tf.keras.layers.Dense(512, activation='relu'),
    tf.keras.layers.Dropout(0.2),
    tf.keras.layers.Dense(10, activation='softmax')
  ])

def train_model():

  model = create_model()
  model.compile(optimizer='adam',
                loss='sparse_categorical_crossentropy',
                metrics=['accuracy'])

  #NAME = "Trains_vs_Cars_16by2_CNN_{}".format(int(time.time()))
  NAME = "Trains_vs_Cars_16by2_{}".format(str(datetime.datetime.now()))
  tensorboard = tf.keras.callbacks.TensorBoard(log_dir="logs/{}".format(NAME))

  model.fit(x=x_train, 
            y=y_train, 
            batch_size=25,
            epochs=5, 
            # validation_split=0.2,
            validation_data=(x_test, y_test), 
            callbacks=[tensorboard])

train_model()


%tensorboard --logdir logs

输出。

2.2.0
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-labels-idx1-ubyte.gz
32768/29515 [=================================] - 0s 0us/step
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/train-images-idx3-ubyte.gz
26427392/26421880 [==============================] - 0s 0us/step
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/t10k-labels-idx1-ubyte.gz
8192/5148 [===============================================] - 0s 0us/step
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/t10k-images-idx3-ubyte.gz
4423680/4422102 [==============================] - 0s 0us/step
Epoch 1/5
2400/2400 [==============================] - 6s 3ms/step - loss: 0.4953 - accuracy: 0.8207 - val_loss: 0.4255 - val_accuracy: 0.8428
Epoch 2/5
2400/2400 [==============================] - 6s 3ms/step - loss: 0.3851 - accuracy: 0.8589 - val_loss: 0.3715 - val_accuracy: 0.8649
Epoch 3/5
2400/2400 [==============================] - 6s 3ms/step - loss: 0.3515 - accuracy: 0.8708 - val_loss: 0.3718 - val_accuracy: 0.8639
Epoch 4/5
2400/2400 [==============================] - 6s 3ms/step - loss: 0.3315 - accuracy: 0.8771 - val_loss: 0.3649 - val_accuracy: 0.8686
Epoch 5/5
2400/2400 [==============================] - 6s 3ms/step - loss: 0.3160 - accuracy: 0.8827 - val_loss: 0.3435 - val_accuracy: 0.8736

enter image description here

更多详情请参考 此处

如果你遇到任何问题,请告诉我,我很乐意帮助你。

© www.soinside.com 2019 - 2024. All rights reserved.