我在Windows分支上使用BVLC Caffe,目前不支持.
当我尝试在Visual Studio 2013上以调试模式编译pycaffe时,我得到了错误
_caffe.obj : error LNK2019: unresolved external symbol __imp__Py_NegativeRefcount referenced in function _import_array
_caffe.obj : error LNK2019: unresolved external symbol __imp__Py_Dealloc referenced in function _import_array
_caffe.obj : error LNK2001: unresolved external symbol __imp__Py_RefTotal
Run Code Online (Sandbox Code Playgroud)
但是,pycaffe在Release模式下编译很好.我正在使用Python 2.7.12 :: Anaconda 4.1.1(64位),我在libs目录中添加了python27_d.lib.
这不是另一个问题的重复,因为:
符号在释放模式下解析,但不在调试模式下解析.(/sf/answers/880167291/)
符号不是虚拟的(/sf/answers/880208521/)
在发布模式下声明和定义符号(什么是未定义的引用/未解析的外部符号错误以及如何修复它?)
Python27.lib和Python27_d.lib库存在且位于同一目录中.(/sf/answers/880208031/)
Release和Debug库都以相同的顺序链接.(/sf/answers/1727300081/)
符号使用C++,而且在发布模式下工作但不在调试模式下工作(/sf/answers/880209431/)
重新编译和重新启动不起作用.(/sf/answers/1425097971/)
Python库的发布和调试模式虽然命名不同,但实际上是彼此的副本.那对一个人有用的东西应该适用于另一个人.(/sf/answers/880209641/)
它们不是模板类.(/sf/answers/1836349441/)
我使用 synset 来计算k来自 softmax 输出的排序最高预测。
这给了我前 5 个班级名称。但我想知道如何计算它的百分比。我的意思是前 5% 的错误。
任何人都可以指导我。谢谢。
我正在使用caffe和python(pycaffe).我正在使用模型动物园的预建的alexnet模型.
从这个页面:https: //github.com/BVLC/caffe/tree/master/models/bvlc_alexnet
每次我使用该模型时,使用以下代码:
net = caffe.Classifier('deploy.prototxt','bvlc_alexnet.caffemodel',
channel_swap=(2,1,0),
raw_scale=255,
image_dims=(256, 256))
Run Code Online (Sandbox Code Playgroud)
caffe告诉我文件格式很旧,需要升级文件.这不应该只发生一次吗?
Run Code Online (Sandbox Code Playgroud)E0304 20:52:57.356480 12716 upgrade_proto.cpp:609] Attempting to upgrade input file specified using deprecated transformation parameters: /tmp/bvlc_alexnet.caffemodel I0304 20:52:57.356554 12716 upgrade_proto.cpp:612] Successfully upgraded file specified using deprecated data transformation parameters. E0304 20:52:57.356564 12716 upgrade_proto.cpp:614] Note that future Caffe releases will only support transform_param messages for transformation fields. E0304 20:52:57.356580 12716 upgrade_proto.cpp:618] Attempting to upgrade input file specified using deprecated V1LayerParameter: /tmp/bvlc_alexnet.caffemodel I0304 20:52:59.307096 12716 …
我正在安装caffe,我想我通过拥有多个版本的OpenCV搞砸了我的安装.现在我不知道我自己做了什么,但似乎没有什么工作正常.所以我最安全的选择是完全卸载opencv.我该如何帮助谢谢?
我想在使用conda之后安装python
我按照这个线程删除了所有已安装的OpenCV库
虽然当我输入 $> sudo find / -name "*opencv*" -exec rm -i {} \;
ubuntu仍然一直要求我允许删除每个烦人的文件.我如何告诉ubuntu删除它?
我试图将预训练模型的大小为3x3x3的图层'con_1'的学习权重复制到新图层'con_1_1',以使新图层的大小为6x3x3(6个通道).我实际上试图将大小为3x3x3的重量复制到6x3x3.我怎么能用pycaffe做到这一点.
layer name: 'con_1'
size: 3x3x3
new layer name: 'con_1_1'
size: 6x3x3
con_1_1 should be [con_1, con_1] % just concatenation of two con_1 weights
Run Code Online (Sandbox Code Playgroud) 我正在尝试重塑caffemodel的卷积层的大小(这是这个问题的后续问题).虽然有一个关于如何进行网络手术的教程,但它只展示了如何将体重参数从一个caffemodel复制到另一个相同大小的caffemodel.
相反,我需要在我的卷积滤镜中添加一个新通道(全0),以便将其大小从当前(64x 3x 3x 3)更改为(64x 4x 3x 3).
假设卷积层被调用'conv1'.这是我到目前为止所尝试的:
# Load the original network and extract the fully connected layers' parameters.
net = caffe.Net('../models/train.prototxt',
'../models/train.caffemodel',
caffe.TRAIN)
Run Code Online (Sandbox Code Playgroud)
现在我可以执行此操作:
net.blobs['conv1'].reshape(64,4,3,3);
net.save('myNewTrainModel.caffemodel');
Run Code Online (Sandbox Code Playgroud)
但保存的模型似乎没有改变.我已经读过卷积的实际权重存储而net.params['conv1'][0].data不是存在,net.blobs但我无法弄清楚如何重塑net.params对象.有没有人有想法?
我没有成功尝试使用Caffe在Python中实现一个简单的丢失层.作为参考,我发现了几个用Python实现的层,包括这里,这里和这里.
从EuclideanLossLayerCaffe文档/示例提供的开头,我无法使其正常工作并开始调试.即使使用这个简单TestLayer:
def setup(self, bottom, top):
"""
Checks the correct number of bottom inputs.
:param bottom: bottom inputs
:type bottom: [numpy.ndarray]
:param top: top outputs
:type top: [numpy.ndarray]
"""
print 'setup'
def reshape(self, bottom, top):
"""
Make sure all involved blobs have the right dimension.
:param bottom: bottom inputs
:type bottom: caffe._caffe.RawBlobVec
:param top: top outputs
:type top: caffe._caffe.RawBlobVec
"""
print 'reshape'
top[0].reshape(bottom[0].data.shape[0], bottom[0].data.shape[1], bottom[0].data.shape[2], bottom[0].data.shape[3])
def forward(self, bottom, top): …Run Code Online (Sandbox Code Playgroud) 我在caffe上按照步骤操作,并更改了配置文件:
PYTHON_LIBRARIES := boost_python3 python3.5m PYTHON_INCLUDE :=
/usr/include/python3.5m \
/usr/lib/python2.7/dist-packages/numpy/core/include"
INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include
/usr/include/hdf5/serial/ LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib
/usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial/
Run Code Online (Sandbox Code Playgroud)
然后做了:
make all
make test
make runtest
Run Code Online (Sandbox Code Playgroud)
这些运行正常。但是当我跑步时:
make pycaffe
Run Code Online (Sandbox Code Playgroud)
我收到一个错误:
CXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpp
/usr/bin/ld: cannot find -lboost_python3
collect2: error: ld returned 1 exit status Makefile:507: recipe for
target 'python/caffe/_caffe.so' failed make: ***
[python/caffe/_caffe.so] Error 1
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
我想从.prototxtPython 中定义的 caffe 网络中读出网络参数,作为layer_dict唯一的层对象告诉我,例如,它是一个“卷积”层,而不是像kernel_size,strides等等。.prototxt文件。
所以让我们说我有一个model.prototxt这样的:
name: "Model"
layer {
name: "data"
type: "Input"
top: "data"
input_param {
shape: {
dim: 64
dim: 1
dim: 28
dim: 28
}
}
}
layer {
name: "conv2d_1"
type: "Convolution"
bottom: "data"
top: "conv2d_1"
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian" # initialize the filters from a Gaussian
std: 0.01 # distribution with stdev 0.01 (default mean: …Run Code Online (Sandbox Code Playgroud)