MingjunZhong / transferNILM

Transfer Learning for Non-Intrusive Load Monitoring
113 stars 44 forks source link

the parameter ​"acc" in function "customfit" is none #3

Closed danl423 closed 4 years ago

danl423 commented 4 years ago

I appreciate very much for the open source code. And I'm a little confused when I run the code "seq2point_train.py" - "NetFlowExt.py", the parameter ​"acc" in function "customfit" :

def customfit(sess,
              network,
              cost,
              train_op,
              tra_provider,
              x,
              y_,
              acc=None,
              n_epoch=50,
              print_freq=1,
              val_provider=None,
              save_model=-1,
              tra_kwag=None,
              val_kwag=None,
              save_path=None,
              epoch_identifier=None,
              earlystopping=True,
              min_epoch=1,
              patience=10):

will always be "None" ,so this part of code [else] will be executed all the time:

                if acc is not None:
                    err, ac = sess.run([cost, acc], feed_dict=feed_dict)
                    train_acc += ac
                    logging.warning('acc not null ')
                else:
                    err = sess.run(cost, feed_dict=feed_dict)
                    logging.warning('acc is null')

and the "train_acc" will always be 0.000000. I'm wondering if I missed something, anyone can advise?

MingjunZhong commented 4 years ago

So I think you could turn on the `acc' parameter in the seq2point_train.py by setting acc not to be None. Can you try that?

danl423 commented 4 years ago

So I think you could turn on the `acc' parameter in the seq2point_train.py by setting acc not to be None. Can you try that?

O! thanks for your reply! and could you be more specific?

MingjunZhong commented 4 years ago

In the script file seq2point_train.py (at the line 263), when you call `customfit' you could set acc=True

danl423 commented 4 years ago

In the script file seq2point_train.py (at the line 263), when you call `customfit' you could set acc=True

Thanks and It prompts: TypeError: Fetch argument True has invalid type <class 'bool'>, must be a string or Tensor. (Can not convert a bool into a Tensor or Operation.)

MingjunZhong commented 4 years ago

Can you try the required type of value for this parameter? For example, acc='True', acc=1.0. I need to fix this issue later in order to make it more easier to use.

danl423 commented 4 years ago

@MingjunZhong sorry I think I made an mistake. It's ok for the acc to be 0.0000 in seq2point_train.py, and the value of accuracy will get in seq2point_test.py, and I misunderstand the difference, Thanks so..o much for your help.