# bias problem with trainb

3 views (last 30 days)
Emiliano Rosso on 1 Jul 2016
Commented: Emiliano Rosso on 2 Jul 2016
I need to train a supervised neural network to linearly separate a set of inputs with logical output 0,1 in batch training. My inputs is inputstemp2 (100,2000) of double precision & target is dividetargets(2,2000) of double 0 & 1. My code is :
mynet=perceptron;
mynet.trainFcn= 'trainb';
mynet.inputWeights.learnFcn='learnp'; %default
mynet.biases.learnFcn= 'learnp'; %default
mynet.biasConnect =[1];
mynet.outputs{1}.processFcns = {};
mynet.inputs{1}.processFcns = {'mapstd','processpca'};
mynet.divideFcn = 'divideblock';
mynet.divideParam.trainRatio = 80/100;
mynet.divideParam.valRatio = 10/100;
mynet.divideParam.testRatio =10/100;
mynet.trainParam.showWindow = false;
mynet.trainParam.showCommandLine = false;
mynet.trainParam.epochs=500;
mynet.efficiency.memoryReduction=1;
[mynet,tr]=train(mynet,inputstemp2,dividetargets);
No problem if mynet.biasConnect =[0] but if I set mynet.biasConnect =[1] Matlab return:
Error using *
Inner matrix dimensions must agree.
Error in learnp>apply (line 93)
dw = e*p';
Error in trainb>train_network (line 231)
[db,BLS{i}] = learnFcn.apply(net.b{i}, ...
Error in trainb (line 55)
[out1,out2] = train_network(varargin{2:end});
ecc.... The same if I use linearlayer and harlim. Somebody can explain me why bias is not accepted?

Greg Heath on 1 Jul 2016
Just use the current (i.e., non-obsolete) classifier
net = patternnet([]); % [] => No hidden layer for linear model
For documentation
help patternnet
doc patternnet
Hope this helps.
Thank you for formally accepting my answer
Greg

#### 1 Comment

Emiliano Rosso on 2 Jul 2016
Solved & best convergence.
Thanks.