'LayerParameter' object has no attribute 'scale'
zht3344 opened this issue · 15 comments
I was having some problems when running the following line ,
Write the train prototxt in a file
f = open(MODEL_FOLDER + 'train_segnet.prototxt', 'w')
f.write(str(net_arch.to_proto()))
I got the error:
'LayerParameter' object has no attribute 'scale'
I don't know what cause the error,how can i resolve this problem?
the following error message is showed:
File "training.py", line 213, in
f.write(str(net_arch.to_proto()))
File "/home/tukrin1/caffe/python/caffe/net_spec.py", line 189, in to_proto
top._to_proto(layers, names, autonames)
File "/home/tukrin1/caffe/python/caffe/net_spec.py", line 97, in _to_proto
return self.fn._to_proto(layers, names, autonames)
File "/home/tukrin1/caffe/python/caffe/net_spec.py", line 158, in _to_proto
assign_proto(layer, k, v)
File "/home/tukrin1/caffe/python/caffe/net_spec.py", line 64, in assign_proto
is_repeated_field = hasattr(getattr(proto, name), 'extend')
AttributeError: 'LayerParameter' object has no attribute 'scale'
Could anyone help me with this?
I appreciate your help!
Are you using our Caffe fork ?
You should have done :
# Initialize and checkout our custom Caffe fork (upsample branch !)
git submodule init
git submodule update
Then, you can use Caffe in Python either by adding our fork to the PYTHON_PATH
or manually in your script :
import sys
sys.path.insert(0, '/path/to/DeepNetsForEO/caffe/python')
@nshaud Thank you, I change your Caffe for,now it work. but when i trained the caffemodel, i got the wrong result:
I0314 17:45:18.172921 6023 solver.cpp:238] Train net output #0: accuracy = 0.404126
I0314 17:45:18.172945 6023 solver.cpp:238] Train net output #1: loss = 1.32147 (* 1 = 1.32147 loss)
I0314 17:45:18.172952 6023 solver.cpp:238] Train net output #2: per_class_accuracy = 0.712315
I0314 17:45:18.172974 6023 solver.cpp:238] Train net output #3: per_class_accuracy = 0.291166
I0314 17:45:18.172979 6023 solver.cpp:238] Train net output #4: per_class_accuracy = 0.00170741
I0314 17:45:18.172986 6023 solver.cpp:238] Train net output #5: per_class_accuracy = 4.86287e-05
I0314 17:45:18.172992 6023 solver.cpp:238] Train net output #6: per_class_accuracy = 0
I0314 17:45:18.173008 6023 solver.cpp:238] Train net output #7: per_class_accuracy = 0
I0314 17:45:18.173024 6023 sgd_solver.cpp:105] Iteration 800, lr = 0.01
I also don't understand why set BGR=True, i use the Vaihingen irrg data , is it reverse the channel order to g r ir? can you give me some advices.
Yes, BGR=True reverses the order of the channels. E.g, if you use IRRG data, the LMDB will actually be GRIR. Our pre-trained weights use this format.
If you are training your own model, it should take around 40000 iterations (with a batch size of 10) before convergence.
@nshaud I increased the training times to 40000,but it still wrong. I found that at the beginning of the train net output the first four class accuracy are not zero,however,at the end of the training only the top of 2 are not zero :
I0315 14:30:36.392210 2502 solver.cpp:238] Train net output #0: accuracy = 0.16449
I0315 14:30:36.392230 2502 solver.cpp:238] Train net output #1: loss = 2.09245 (* 1 = 2.09245 loss)
I0315 14:30:36.392246 2502 solver.cpp:238] Train net output #2: per_class_accuracy = 0.270436
I0315 14:30:36.392251 2502 solver.cpp:238] Train net output #3: per_class_accuracy = 0.121069
I0315 14:30:36.392258 2502 solver.cpp:238] Train net output #4: per_class_accuracy = 0.0145857
I0315 14:30:36.392266 2502 solver.cpp:238] Train net output #5: per_class_accuracy = 0.175652
I0315 14:30:36.392271 2502 solver.cpp:238] Train net output #6: per_class_accuracy = 0.239834
I0315 14:30:36.392287 2502 solver.cpp:238] Train net output #7: per_class_accuracy = 0
I0315 14:30:36.392294 2502 sgd_solver.cpp:105] Iteration 0, lr = 0.01
/usr/lib/python2.7/dist-packages/numpy/core/_methods.py:59: RuntimeWarning: .
warnings.warn("Mean of empty slice.", RuntimeWarning)
/usr/lib/python2.7/dist-packages/numpy/core/_methods.py:70: RuntimeWarning: invalid value encountered in double_scalars
ret = ret.dtype.type(ret / rcount)
iter 0, train_loss=2.092453
0%| | 100/40000 [00:20<2:11:38, 5.05it/s]I0315 14:30:56.584589 2502 solver.cpp:219] Iteration 100 (4.95231 iter/s, 20.1926s/100 iters), loss = 1.52628
I0315 14:30:56.584635 2502 solver.cpp:238] Train net output #0: accuracy = 0.303955
I0315 14:30:56.584646 2502 solver.cpp:238] Train net output #1: loss = 1.52628 (* 1 = 1.52628 loss)
I0315 14:30:56.584655 2502 solver.cpp:238] Train net output #2: per_class_accuracy = 0.772755
I0315 14:30:56.584677 2502 solver.cpp:238] Train net output #3: per_class_accuracy = 0.23393
I0315 14:30:56.584699 2502 solver.cpp:238] Train net output #4: per_class_accuracy = 0.00012333
I0315 14:30:56.584704 2502 solver.cpp:238] Train net output #5: per_class_accuracy = 0.00130501
I0315 14:30:56.584710 2502 solver.cpp:238] Train net output #6: per_class_accuracy = 0
I0315 14:30:56.584717 2502 solver.cpp:238] Train net output #7: per_class_accuracy = 0
I0315 14:30:56.584724 2502 sgd_solver.cpp:105] Iteration 100, lr = 0.01
iter 100, train_loss=1.526283
0%|▏ | 200/40000 [00:40<2:14:46, 4.92it/s]I0315 14:31:16.698926 2502 solver.cpp:219] Iteration 200 (4.97154 iter/s, 20.1145s/100 iters), loss = 1.3434
100%|██████████████████ | 39900/40000 [3:56:21<00:19, 5.20it/s]I0315 18:26:57.442383 2502 solver.cpp:219] Iteration 39900 (1.57393 iter/s, 63.5351s/100 iters), loss = 1.32824
I0315 18:26:57.442427 2502 solver.cpp:238] Train net output #0: accuracy = 0.353693
I0315 18:26:57.442440 2502 solver.cpp:238] Train net output #1: loss = 1.32824 (* 1 = 1.32824 loss)
I0315 18:26:57.442446 2502 solver.cpp:238] Train net output #2: per_class_accuracy = 0.00656828
I0315 18:26:57.442471 2502 solver.cpp:238] Train net output #3: per_class_accuracy = 0.999583
I0315 18:26:57.442476 2502 solver.cpp:238] Train net output #4: per_class_accuracy = 0
I0315 18:26:57.442482 2502 solver.cpp:238] Train net output #5: per_class_accuracy = 0
I0315 18:26:57.442488 2502 solver.cpp:238] Train net output #6: per_class_accuracy = 0
I0315 18:26:57.442503 2502 solver.cpp:238] Train net output #7: per_class_accuracy = 0
I0315 18:26:57.442510 2502 sgd_solver.cpp:105] Iteration 39900, lr = 0.001
Besides,there are several warning messages:
I0315 14:30:35.096953 2502 layer_factory.cpp:91] cuDNN does not support multiple tops. Using Caffe's own pooling layer.
upsample_layer.cpp:31] Params 'pad_out_{}_' are deprecated. Please declare upsample height and width useing the upsample_h, upsample_w parameters.
need help thanks:)
Those warnings are not critical, you can safely ignore them.
On what data are you training the network ? The Vaihingen dataset ?
yes, i use The Vaihingen dataset
It seems that you are only learning the 'building' class. Can you check the classification achieves good results using the provided pre-trained weights ?
@nshaud
yes,i run the reference.py with the segnet_vaihingen_128x128_fold1_iter_60000.caffemodel ,and have got a good result
Did you change anything in the training script file ? Or in the training prototxt ?
@nshaud i just change the path of dataset in the prototxt:
data_param {
source: "path/to/your/train/lmdb" # E
Could you paste the full prototxt that you used ? How did you generate the LMDB ? Can you check (using Python) that the Caffe Blobs inside the network are OK ? i.e. by using the Python Caffe API checking that net.blobs['data'].data
and net.blobs['label'].data
have not been corrupted somehow ?
@nshaud thanks for the solution,I re-download the code and regenerate the database,now the traning results are correct. I have modified the code before , it maybe have made something wrong
Hello
I have also same problem ('LayerParameter' object has no attribute 'scale' ). but I could not solve it. would you please guide me step by step. I used caffe version 1.0.0 on windows7.