//Functions to simulate a neural network with binary neurons //Author: Gerd Doeben-Henisch //Version: 7.Jan 2009 //Dependent from: annsvecmtx.sci (Vector and matrix operations) //Dependent from: neuron1.sce //******************************************************* //Function to compute the reaction of a network of neurons n.j in Matrix N with input neurons in.i // weight matrix W (one row per neuron n.j) and output values in vector o //Every neuron is assumed to hav a simple binary function as activation function //There is a vector th with threshold values for each neuron n.j of N function [o] = nnbin(in,W,th,N) [r,c] = size(N),//N assumed as column [r2,c2] = size(W), //W as matrix one row per neuron n.j o=zeros(1,r), if c2 <> length(in) error ('LENGTH OF INPUT DOES NOT MATCH WEIGHTS'), elseif r2 <> r error ('NUMBER OF NEURONS DOES NOT MATCH WEIGHTS'), elseif r <> length(th) error ('NUMBER OF NEURONS DOES NOT MATCH THRESHOLDS') else for i=1:r, o(i)=eval(N(i)),end end endfunction