1. 写好callback语句:
tf_callbacks = tf.keras.callbacks.TensorBoard(log_dir="D:\\XXX\\0 EXAM\\4th\\XXXXXXXXXXXXXX\\Final Code\\Source Code\\logs", update_freq=1)
这里要注意一下update的频率,如果频率不够,可能看不见log文件
2. 在fit时调用callback:
history_lstm_res = lstm_res.fit(Feature_stock, Target_stock, batch_size=32, epochs=10, validation_split=0.3, callbacks=tf_callbacks, shuffle=False, verbose=2)
3.当训练好后打开log文件夹检查是否有log文件输入
3. 打开tensorboard端口:
用anaconda prompt打开:(1)先cd 到log所在的文件夹,然后输入:
(base) D:\XXX\0 EXAM\4th\XXXXXXXXXX\Final Code\Source Code\logs>tensorboard --logdir="D:\XXX\0 EXAM\4th\XXXXXXXXXX\Final Code\Source Code\logs" --port 8123
4. 然后prompt终端会给你提示:
2023-11-12 21:27:22.417126: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
2023-11-12 21:27:22.417427: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2023-11-12 21:27:25.105550: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'nvcuda.dll'; dlerror: nvcuda.dll not found
2023-11-12 21:27:25.105915: W tensorflow/stream_executor/cuda/cuda_driver.cc:269] failed call to cuInit: UNKNOWN ERROR (303)
2023-11-12 21:27:25.108283: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:169] retrieving CUDA diagnostic information for host: Bookman
2023-11-12 21:27:25.108505: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:176] hostname: Bookman
Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all
TensorBoard 2.9.1 at http://localhost:8123/ (Press CTRL+C to quit)
W1112 21:28:34.297618 14308 security_validator.py:46] In 3.0, this warning will become an error:
X-Content-Type-Options is required to be "nosniff"
W1112 21:28:34.335514 9636 security_validator.py:46] In 3.0, this warning will become an error:
X-Content-Type-Options is required to be "nosniff"
W1112 21:28:34.335514 9636 security_validator.py:46] In 3.0, this warning will become an error:
Requires default-src for Content-Security-Policy
W1112 21:28:34.627880 16920 security_validator.py:46] In 3.0, this warning will become an error:
X-Content-Type-Options is required to be "nosniff"
W1112 21:28:34.929035 16508 application.py:556] path /data/plugin/whatif/data/plugins_listing not found, sending 404
W1112 21:28:35.268610 15520 application.py:556] path /data/plugin/whatif/data/plugins_listing not found, sending 404
W1112 21:28:35.510952 17352 application.py:556] path /data/plugin/whatif/data/plugins_listing not found, sending 404
W1112 21:28:35.581216 18164 application.py:556] path /data/plugin/whatif/data/plugins_listing not found, sending 404
5.再用浏览器打开: