MingjunZhong / transferNILM

Transfer Learning for Non-Intrusive Load Monitoring

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Transfer Learning Training using Washing Machine:Layer weight shape (10, 1, 1, 30) not compatible with provided weight shape (8, 1, 30, 30)

up1047045 opened this issue · comments

Greetings dr Zhong

I am currently trying to use the following command (That's the one you provided in the README file, but i've changed the directories to my computer's path) :

python seq2point_train.py --appliance_name 'kettle' --datadir './dataset_management/refit/' --save_dir './trained_model' --transfer_cnn True --cnn washingmachine --pretrainedmodel_dir './pretrained_model' --crop_dataset 10000`

I have tested the original seq2point NILM algorithm and i get great results for all appliances, pretty much like the ones in your paper. But when i am trying the transfer learning part, i get the following error:

Traceback (most recent call last):
File "CODING\transferNILM_master\seq2point_train.py", line 221, in
pretrainedmodel_dir=args.pretrainedmodel_dir)
File "D:\Georgoulakis Titos\Smart_grid_Thesis\CODING\transferNILM_master\cnnModel.py", line 93, in get_model
cnn_weights_loader(model, cnn, pretrainedmodel_dir)
File "D:\Georgoulakis Titos\Smart_grid_Thesis\CODING\transferNILM_master\cnnModel.py", line 147, in cnn_weights_loader
model_to_fill.layers[int(name[-1])+1].set_weights(weight_values)
File "C:\Users\titos\anaconda3\envs\thesis\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 1305, in set_weights
'shape %s' % (ref_shape, weight.shape))
ValueError: Layer weight shape (10, 1, 1, 30) not compatible with provided weight shape (8, 1, 30, 30)

I really do not know what's wrong because i didn't make any changes in the original code you provided and i cannot understand why wouldn't it work.

I would really appreciate your thoughts for my problem. Thank you in advance

@up1047045 It seems that your model to be training does not match the parameter settings in your pre-trained model. That means the layer weight shapes are different.

Thank you for your instant reply. Do you have any suggestions on how to fix this issue ?

@up1047045 you may just simply use the same architectures for both of your pre-trained model and the one to be trained.

I am sorry but i can't seem to understand which parameters i should change in order for them to match. Could you be more specific if that'ts possible, because all of these days i am trying different changes, but none of them seem to work. Thanks again in advance