tensorflow 找不到张紧板

gmxoilav  于 2023-02-24  发布在  其他
关注(0)|答案(3)|浏览(241)

我尝试使用tensorboard Jmeter 板来检查模型性能。下面是我使用的代码:

from keras.callbacks import TensorBoard
%load_ext tensorboard

log_dir = "logs/fit/" + datetime.now().strftime("%Y%m%d-%H%M%S")

tensorboard_callback = TensorBoard(log_dir=log_dir, histogram_freq=1)

checkpoint_name = 'Weights-{epoch:03d}--{val_loss:.5f}.hdf5' 

checkpoint = ModelCheckpoint(checkpoint_name, monitor='val_loss', verbose = 1, save_best_only = True, mode ='auto')

es = EarlyStopping(monitor='val_loss', verbose=1, patience=10)

callbacks_list = [checkpoint ,es,tensorboard_callback]

NN_model.fit(train, target, epochs=100, batch_size=32, validation_split = 0.2, callbacks=callbacks_list)

但在模型训练后,我无法显示 Jmeter 板:

%tensorboard --logdir logs

以下是我得到的错误:

ERROR: Could not find `tensorboard`. Please ensure that your PATH
contains an executable `tensorboard` program, or explicitly specify
the path to a TensorBoard binary by setting the `TENSORBOARD_BINARY`
environment variable.
chy5wohz

chy5wohz1#

这可能是因为笔记本电脑和虚拟环境之间的一些冲突。
这里一个简单的解决方案是在你的笔记本上直接指定TENSORBOARD_BINARY变量,这样它就不会干扰全局变量,然后像这样调用tensorboard:

os.environ['TENSORBOARD_BINARY'] = '/path/to/envs/my_env/bin/tensorboard'

一个长期的解决方案是为虚拟环境设置一个变量,就像here提出的那样。

prdp8dxp

prdp8dxp2#

1.如果尚未安装,则安装张拉板pip3 install tensorboard
1.使用命令pip3 show tensorboard检查软件包的位置
您将看到如下输出

Name: tensorboard
Version: 2.12.0
Summary: TensorBoard lets you watch Tensors Flow
Home-page: https://github.com/tensorflow/tensorboard
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: /Users/admin/Library/Python/3.9/lib/python/site-packages
Requires: protobuf, wheel, tensorboard-plugin-wit, numpy, setuptools, requests, google-auth-oauthlib, absl-py, grpcio, werkzeug, markdown, tensorboard-data-server, google-auth
Required-by:

复制"位置"(在本例中为/Users/admin/Library/Python/3.9/lib/python/site-packages),并通过运行python3 <Locaton copied>/tensorboard/main.py --logdir=<log dir path>运行Tensor板
例如:
python3 /Users/admin/Library/Python/3.9/lib/python/site-packages/tensorboard/main.py --logdir=./
这将启动tensorboard并显示如下URL:

TensorFlow installation not found - running with reduced feature set.
Serving TensorBoard on localhost; to expose to the network, use a proxy or pass --bind_all
TensorBoard 2.12.0 at http://localhost:6006/ (Press CTRL+C to quit)

你现在可以打开url(在本例中为http://localhost:6006/)来查看张板

g9icjywg

g9icjywg3#

您需要在终端上执行tensorboard命令来打开tensorboard服务器。
命令应该是

tensorboard --logdir="<path to your logdir>"

相关问题