0
votes
class Neuron:
    eta=0.9 #learning rate
    alpha=0.15 #momentum rate
    def __init__(self,layer):
        self.dendrons=[]
        self.error=0.0
        self.output=0.0
        self.gradient=0.0
        if(layer in None):
            pass
        else:
            for neuron in layer:
                con=Connection(neuron)
                self.dendrons.append(con)

While designing neural network we are getting the error for this part of the code as TypeError: argument of type 'NoneType' is not iterable.

Error is :

runfile('C:/Users/Saritha Reddy/AnacondaProjects/NeuralNetwork.py', wdir='C:/Users/Saritha Reddy/AnacondaProjects') Traceback (most recent call last):

File "", line 1, in runfile('C:/Users/Saritha Reddy/AnacondaProjects/NeuralNetwork.py', wdir='C:/Users/Saritha Reddy/AnacondaProjects')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/Saritha Reddy/AnacondaProjects/NeuralNetwork.py", line 123, in main()

File "C:/Users/Saritha Reddy/AnacondaProjects/NeuralNetwork.py", line 97, in main net=Net([2,3,5,1])

File "C:/Users/Saritha Reddy/AnacondaProjects/NeuralNetwork.py", line 57, in init neuron=Neuron(None)

File "C:/Users/Saritha Reddy/AnacondaProjects/NeuralNetwork.py", line 23, in init if(layer in None):

TypeError: argument of type 'NoneType' is not iterable

Can anyone please suggest to solve this error..

1

1 Answers

0
votes

You have a wrong condition. Try this:

if(None in layer):
    pass