【边喝caffee边Caffe 】(二)python版本的报错:Mean shape incompatible with input shape
2016-03-20 16:00
656 查看
在运行Ubuntu上的python版本,希望对比一下C++的结果是否正确时,发现一直报错Mean shape
incompatible with input shape
后来遍查网络,发现了一个解决方法,见
http://blog.csdn.net/gzljss/article/details/45849013
直接贴过来
------------------------------------------分割线-----------------------------------------
解决方法参考http://stackoverflow.com/questions/29842935/mean-shape-incompatible-with-input-shape-caffe-classification-error-in-io-py
在运行caffe的python例子时,命令行输入
[html] view
plain copy
python classify.py cat.jpg foo
报错
ValueError: Mean shape incompatible with input shape.
原因是‘mean’与‘input’的尺寸不同造成的。
参考前面的文章,修改了 ./python/caffe/io.py 文件
将:
[html] view
plain copy
if ms != self.inputs[in_][1:]:
raise ValueError('Mean shape incompatible with input shape.')
修改为:
[python] view
plain copy
if ms != self.inputs[in_][1:]:
print(self.inputs[in_])
in_shape = self.inputs[in_][1:]
m_min, m_max = mean.min(), mean.max()
normal_mean = (mean - m_min) / (m_max - m_min)
mean = resize_image(normal_mean.transpose((1,2,0)),
in_shape[1:]).transpose((2,0,1)) * \
(m_max - m_min) + m_min
#raise ValueError('Mean shape incompatible with input shape.')
incompatible with input shape
后来遍查网络,发现了一个解决方法,见
http://blog.csdn.net/gzljss/article/details/45849013
直接贴过来
------------------------------------------分割线-----------------------------------------
解决方法参考http://stackoverflow.com/questions/29842935/mean-shape-incompatible-with-input-shape-caffe-classification-error-in-io-py
在运行caffe的python例子时,命令行输入
[html] view
plain copy
python classify.py cat.jpg foo
报错
ValueError: Mean shape incompatible with input shape.
原因是‘mean’与‘input’的尺寸不同造成的。
参考前面的文章,修改了 ./python/caffe/io.py 文件
将:
[html] view
plain copy
if ms != self.inputs[in_][1:]:
raise ValueError('Mean shape incompatible with input shape.')
修改为:
[python] view
plain copy
if ms != self.inputs[in_][1:]:
print(self.inputs[in_])
in_shape = self.inputs[in_][1:]
m_min, m_max = mean.min(), mean.max()
normal_mean = (mean - m_min) / (m_max - m_min)
mean = resize_image(normal_mean.transpose((1,2,0)),
in_shape[1:]).transpose((2,0,1)) * \
(m_max - m_min) + m_min
#raise ValueError('Mean shape incompatible with input shape.')
相关文章推荐
- 以文件为单位的分句、分词python封装脚本
- 解决OS X下Pycharm无法识别Python第三方库的问题
- Python Challenge 10
- python——sys
- Python 遍历子文件和所有子文件夹
- ssh的工作原理之python获取远程主机公钥
- python 关键字 之 and 与 or
- leetcode之jump game II
- 关于python爬虫的一点心得
- Python 09 模块学习
- Python 08 re 正则表达式
- Python常用模块
- Python 07 Pickle 与 Json 序列化
- Python 06 lambda函数
- Python 2.x vs 3.x
- Python学习笔记
- Python 05 自定义函数的创建、调用和函数
- Python 04 中并行遍历 zip,map,enumerate
- python脚本生成exe可执行文件
- Python 基础 员工信息列表