I have an existing *.prototext and *.caffemodel.
Unfortunately, the final layer's name is "class", which causes all sorts of trouble with pycaffe (because "class" is a reserved word).
I'd like to rename this to "class_".
Here's how i'm trying it now:
def convert(prototext, new_prototext, model, newmodel):
net_old = caffe.Net(prototext, model, caffe.TEST)
net_new = caffe.Net(new_prototext, model, caffe.TEST)
net_new = update_key(net_new)
for i in range(0,2):
net_new.params['class_'][i].data[...] = net_old.params['class'][i].data[...]
net_new.save(newmodel)
def update_key(net):
net.params['class_'] = net.params['class']
net.params.pop('class')
return net
This executes cleanly. But, the newly saved prototext has not changed the name of "class" to "class_". I can inspect the state of net_new at the end of convert() and determine that the key in net_new.params is really different... what's going on?