Building a neuron
Building a neuron
The design parameters of a neuron are specified by: 1. the number or its inputs, 2. the weight of each input, 3. the bias of the neuron, and 4. its acitvation function.The following commands allow you to design your own neuron and plot its output function. You will only need to modify the text in orange.
A neuron with a single input
A neuron with a single input
Click on the cell below. Modify parameters as needed. Then Shift-Enter will evaluate the cell and plot the output function of your neuron. Make sure to follow Mathematica's formatting. There are alternate activation functions. Some are choices are Ramp, Tanh, Cos, and LogisticSigmoid.
In[]:=
bias={-.4};weights={{.2}};activation=Ramp;layer1=LinearLayer[1,"Biases"bias,"Weights"weights];n=NetChain[{layer1,activation},"Input"1];Plot[{n[x]},{x,-1,3},PlotRange{-1,1},PlotStyleThickness[0.01]]
A neuron with a multiple inputs
A neuron with a multiple inputs
This is similar to the cell above, but now you can specify more than one weight
In[]:=
bias={-.4};weights={{.2,.3}};numInputs=2;activation=Ramp;layer1=LinearLayer[1,"Biases"bias,"Weights"weights];n=NetChain[{layer1,activation},"Input"numInputs];Plot3D[{n[{x,y}]},{x,-1,4},{y,-1,4},PlotRange{-0.1,2},PlotStyleThickness[0.01]]