hello everyone,
Thank you for open code!
I get some errors when I use ukdale2.h5
to test code. Could you help me?
error 1:
File "D:\code\image-nilm-main\image-nilm-main\src\disaggregate\batchgenerator.py", line 22, in __init__
super.__init__(BatchGenerator,)
TypeError: descriptor '__init__' requires a 'super' object but received a 'type'
I choose comment this line in the code!
class BatchGenerator(tf.keras.utils.Sequence) :
def __init__(self, x_sequence,y_sequence, batch_size,img_method = 'gasf',img_size = 28) :
# super.__init__(BatchGenerator,)
self.x_sequence = x_sequence
self.y_sequence = y_sequence
self.batch_size = batch_size
self.img_method = img_method
self.img_size = img_size
error 2:
File "D:\code\image-nilm-main\image-nilm-main\src\disaggregate\Im2Seq.py", line 130, in partial_fit
loss_history = LossHistory()
NameError: name 'LossHistory' is not defined
I think maybe you delete the function LossHistory
and step_decay
, so I comment these line in the code and change the callback_llist
.
validation_batch_generator = BatchGenerator(v_x, v_y, self.batch_size, self.img_method,
self.img_size)
# loss_history = LossHistory()
# lrate = LearningRateScheduler(step_decay)
# callbacks_list = [loss_history, lrate, checkpoint]
callbacks_list = [checkpoint]
with tf.device('/device:GPU:0'):
print('training with GPU')
model.fit_generator(generator=batch_generator,
steps_per_epoch=int(len(train_y) // self.batch_size),
epochs=self.n_epochs,
verbose=1,
shuffle=True,
callbacks=checkpoint,
validation_data=validation_batch_generator,
validation_steps=int(len(v_y) // self.batch_size))
model.load_weights(filepath)
error 3:
File "E:\Software\Anaconda3\envs\nilmtk\lib\site-packages\tensorflow\python\keras\callbacks.py", line 98, in configure_callbacks
callbacks = [BaseLogger()] + (callbacks or []) + [model.history]
TypeError: can only concatenate list (not "ModelCheckpoint") to list
I think maybe you change the code, so I change the code!
Original Code:
with tf.device('/device:GPU:0'):
print('training with GPU')
model.fit_generator(generator=batch_generator,
steps_per_epoch=int(len(train_y) // self.batch_size),
epochs=self.n_epochs,
verbose=1,
shuffle=True,
callbacks=checkpoint,
validation_data=validation_batch_generator,
validation_steps=int(len(v_y) // self.batch_size))
model.load_weights(filepath)
Change the code:
with tf.device('/device:GPU:0'):
print('training with GPU')
model.fit_generator(generator=batch_generator,
steps_per_epoch=int(len(train_y) // self.batch_size),
epochs=self.n_epochs,
verbose=1,
shuffle=True,
callbacks=[checkpoint], ### add [] in this line #####
validation_data=validation_batch_generator,
validation_steps=int(len(v_y) // self.batch_size))
model.load_weights(filepath)
error 4:
InvalidArgumentError: 2 root error(s) found.
(0) Invalid argument: Incompatible shapes: [64,120,1] vs. [64,120]
[[{{node loss_3/conv1d_3_loss/SquaredDifference}}]]
[[loss_3/mul/_131]]
(1) Invalid argument: Incompatible shapes: [64,120,1] vs. [64,120]
[[{{node loss_3/conv1d_3_loss/SquaredDifference}}]]
0 successful operations.
0 derived errors ignored.
I don't konw how can I solve this problem, could you help me? Could you give me a complete code?
Thank you very much!
Best wishes!