davidsandberg / facenet

Face recognition using Tensorflow
MIT License
13.62k stars 4.8k forks source link

TypeError: '<=' not supported between instances of 'NoneType' and 'int' #1133

Open pasa13142 opened 4 years ago

pasa13142 commented 4 years ago

File "src/train_softmax.py", line 308, in train │
if lr<=0: │
TypeError: '<=' not supported between instances of 'NoneType' and 'int'


I got this error at after 275. epoch, because learning rate at learning_rate_schedule_classifier_vggface2.txt :

Learning rate schedule

Maps an epoch number to a learning rate

0: 0.05
100: 0.005
200: 0.0005
276: -1

How should I do ? Thanks for help

zhangying0409 commented 4 years ago

Have you solved this problem? Could you share the solution,thank you very much!

bilalahmed381 commented 4 years ago

Replace get_learning_rate_from_file function in facenet.py file with this function and this error will not appear.

def get_learning_rate_from_file(filename, epoch):
    with open(filename, 'r') as f:
        for line in f.readlines():
            line = line.split('#', 1)[0]
            if line:
                par = line.strip().split(':')
                e = int(par[0])
                if par[1]=='-':
                    lr = -1
                else:
                    lr = float(par[1])
                if e <= epoch:
                    learning_rate = lr
                else:
                    pass
    return learning_rate