用Hualos可视化Keras的培训进度

2024-09-30 02:33:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着按照这里的指示https://github.com/fchollet/hualos 在Keras中可视化训练进度。在前面提到的那一页,我读到:

Hualos - Keras Total Visualization project

For now, this is a simple demo where a Flask server exposes an API to publish and consume events in the form of JSON objects. The Keras callback RemoteMonitor can publish events to the server, and the Hualos landing page listens to the server and displays incoming data on a c3.js graph.

Example:

start the server: python api.py
load the landing page: http://localhost:9000/
launch a Keras experiment with the RemoteMonitor callback:
> from keras import callbacks
> remote = callbacks.RemoteMonitor(root='http://localhost:9000')
> 
> model.fit(X_train, Y_train, batch_size=batch_size, nb_epoch=nb_epoch,
> validation_data=(X_test, Y_test), callbacks=[remote])

此外:

Dependencies:

Python:
    Flask
    gevent

JS (included in the repo):
    d3.js
    c3.js

我已经成功地安装了烧瓶和gevent。在

为了简洁起见,我的代码如下:使用mnist测试数据作为csv文件从这里下载:https://pjreddie.com/projects/mnist-in-csv/

^{pr2}$

结果如下:

Train on 7000 samples, validate on 3000 samples
Epoch 1/3
7000/7000 [==============================] - 1s 100us/step - loss: 0.7812 - acc: 0.7717 - val_loss: 0.3036 - val_acc: 0.9153
Epoch 2/3
3296/7000 [=============>................] - ETA: 0s - loss: 0.3139 - acc: 0.9072

C:\ProgramData\Anaconda3\lib\site-packages\keras\callbacks.py:606: UserWarning: Warning: could not reach RemoteMonitor root server at http://localhost:9000
  'root server at ' + str(self.root))

7000/7000 [==============================] - 0s 55us/step - loss: 0.3051 - acc: 0.9111 - val_loss: 0.2616 - val_acc: 0.9213
Epoch 3/3
2400/7000 [=========>....................] - ETA: 0s - loss: 0.2613 - acc: 0.9237

C:\ProgramData\Anaconda3\lib\site-packages\keras\callbacks.py:606: UserWarning: Warning: could not reach RemoteMonitor root server at http://localhost:9000
  'root server at ' + str(self.root))

7000/7000 [==============================] - 0s 63us/step - loss: 0.2397 - acc: 0.9284 - val_loss: 0.2350 - val_acc: 0.9320

C:\ProgramData\Anaconda3\lib\site-packages\keras\callbacks.py:606: UserWarning: Warning: could not reach RemoteMonitor root server at http://localhost:9000
  'root server at ' + str(self.root))

实际上,当我尝试运行命令时:

python api.py

我有个例外:

 (base) D:\Mint_ns>python api.py
Traceback (most recent call last):
  File "api.py", line 10, in <module>
    from pattern.server import App
ModuleNotFoundError: No module named 'pattern'

(base) D:\Mint_ns>conda install -c asmeurer pattern
Solving environment: failed

UnsatisfiableError: The following specifications were found to be in conflict:
  - pattern
  - tensorflow
Use "conda info <package>" to see the dependencies for each package.

这有点奇怪,因为整个要点是使用Hualos来处理以TensorFlow为后端的Keras。在

我该怎么做?在


Tags: thetoinpylocalhosthttpserverval

热门问题