Neuron output
Neural Networks course (practical examples) © 2012 Primoz Potocnik
PROBLEM DESCRIPTION: Calculate the output of a simple neuron
Contents
Define neuron parameters
close all, clear all, clc, format compact % Neuron weights w = [4 -2] % Neuron bias b = -3 % Activation function func = 'tansig' % func = 'purelin' % func = 'hardlim' % func = 'logsig'
w = 4 -2 b = -3 func = tansig
Define input vector
p = [2 3]
p = 2 3
Calculate neuron output
activation_potential = p*w'+b neuron_output = feval(func, activation_potential)
activation_potential = -1 neuron_output = -0.7616
Plot neuron output over the range of inputs
[p1,p2] = meshgrid(-10:.25:10); z = feval(func, [p1(:) p2(:)]*w'+b ); z = reshape(z,length(p1),length(p2)); plot3(p1,p2,z) grid on xlabel('Input 1') ylabel('Input 2') zlabel('Neuron output')