caffe官网上的example中的例子,如果环境配对都能跑出来,接下来跑Notobook Example中的程序,都是python写的,这些程序会让你对如何使用caffe解决问题有个初步的了解(http://www.cnblogs.com/dupuleng/articles/4242983.html)

即然用到python,那么就要确定安装了python,并且pycaffe编译通过,还要安装一些依赖项:

sudo apt-get install python-numpy python-scipy python-matplotlib python-sklearn python-skimage python-h5py python-protobuf python-leveldb python-networkx python-nose python-pandas python-gflags Cython ipython

其中matplotlib是用来进行绘图的,非常方便。在深度学习中,我们经常会通过将中间结果显示来观察学习到的特征,因此掌握matplotlib相当重要。

在使用matplotlib时需要注意一个问题,先看示例

import matplotlib.pyplot as plt

input_image = caffe.io.load_image(IMAGE_FILE)
plt.imshow(input_image)
#显示
plt.show() 

最后一唏的plt.show()必须有,要不然不会显示绘图,在caffe的例子中并没有注明这一点。

如果你有多幅图像要显示,可以像matlab一样使用subplot

3. caffe中 python Notebook
import matplotlib.pyplot as plt

plt.figure()
plt.subplot(1,2,1)
plt.bar(left = (0,1),height = (1,0.5),width = 0.35)

plt.subplot(1,2,2)
plt.bar(left = (0,1),height = (1,0.5),width = 0.35)

plt.show()
3. caffe中 python Notebook

如果想每幅图单独显示,可以在每次绘图前新建一个绘图区

3. caffe中 python Notebook
import matplotlib.pyplot as plt

plt.figure()
plt.bar(left = (0,1),height = (1,0.5),width = 0.35)

plt.figure()
plt.bar(left = (0,1),height = (1,0.5),width = 0.35)  
plt.show()
3. caffe中 python Notebook

相关文章:

  • 2021-04-18
  • 2021-05-22
  • 2021-04-27
  • 2021-10-11
  • 2021-08-05
  • 2021-08-21
  • 2022-12-23
  • 2021-12-01
猜你喜欢
  • 2022-01-01
  • 2022-12-23
  • 2022-02-09
  • 2021-10-18
  • 2021-05-14
  • 2022-12-23
  • 2021-09-16
相关资源
相似解决方案