Unsupported operand type(s)
Closed this issue ยท 6 comments
While running your code with Python 3.8.5, I'm getting the following error:
TypeError: unsupported operand type(s) for *: 'NoneType' and 'float'
It is occurring at this line:
Line 239 in 858308d
I thought the issue was caused by self.last_input = None
, but the forward pass assigns values to self.last_input. Any suggestions as to where the issue might be? @AlessandroSaviolo
I am also facing the same issue, if you have solved it kindl post the answer? @Hommus
@MuhammadShifa Unfortunately, I haven't used this repository in a while and no longer have the solution. Best of luck with the problem though!
Can you tell how did you figured out the issue ? @Hommus | If you didn't can you help by answering , how did you did CNN from scratch. I will be very grateful...
Finally, got the bug ... You see , in layer.py file , the lr_schedule functon returns only learning rate when Iteration is 0 or above 10,000 , I think @AlessandroSaviolo forget to mention ' above zero or less than 10,000 ' should return learning rate also .Here is the working code ,replace it with that 'lr schedule function' in layer.py |
def lr_schedule(learning_rate, iteration):
if iteration == 0:
return learning_rate
if (iteration >= 0) and (iteration <= 10000): # add this additional condition to resolve the bug
return learning_rate
if iteration > 10000:
return learning_rate * 0.1
if iteration > 30000:
return learning_rate * 0.1
The learning rate is None because no argument was passed when the iteration is greater than 0 , So when the iteration 2nd hit , it became None and couldn't multipy with the Float value ... as @Hommus mentioned the error .... When you add an additional 'if condition' for greater than zero , it will no longer gives that error and the CNN will work completely fine. I hope my answer is clear ...
I am also facing the same issue, if you have solved it kindl post the answer? @Hommus
Inbox me
Thank you for pointing this out. Accepted the pull request. Closing.