Problem using scalingLayer for shifting actor outputs to desired range

Technical Source
1 min readApr 15, 2021

--

Greetings everyone. I want to use scalingLayer to shift my actor network’s outputs to desired range. I’m using this reference and the code below :

numObs = 10;
numAct = 5;
actorLayerSizes = [400 300];
sc = reshape([10, 10, 20, 15, 15], [1 1 5]);
bias = reshape([0, 0, 0, 0, 0], [1 1 5]);
actorNetwork = [
imageInputLayer([numObs 1 1],'Normalization','none','Name','observation')
fullyConnectedLayer(actorLayerSizes(1), 'Name', 'ActorFC1')
reluLayer('Name', 'ActorRelu1')
fullyConnectedLayer(actorLayerSizes(2), 'Name', 'ActorFC2')
reluLayer('Name', 'ActorRelu2')
fullyConnectedLayer(numAct, 'Name', 'ActorFC3')
tanhLayer('Name','ActorTanh1'), ...
scalingLayer('Scale',sc, 'Bias',bias)
];

I’m getting the error below:

Error using vertcat

Dimensions of arrays being concatenated are not consistent.

Can anyone help me with this?

ANSWER

Matlabsolutions.com provide latest MatLab Homework Help,MatLab Assignment Help for students, engineers and researchers in Multiple Branches like ECE, EEE, CSE, Mechanical, Civil with 100% output.Matlab Code for B.E, B.Tech,M.E,M.Tech, Ph.D. Scholars with 100% privacy guaranteed. Get MATLAB projects with source code for your learning and research.

The way you have it now, you are adding the scaling layer in the same row as tanh whereas it should be in its own row.

actorNetwork = [
imageInputLayer([numObs 1 1],'Normalization','none','Name','observation')
fullyConnectedLayer(actorLayerSizes(1), 'Name', 'ActorFC1')
reluLayer('Name', 'ActorRelu1')
fullyConnectedLayer(actorLayerSizes(2), 'Name', 'ActorFC2')
reluLayer('Name', 'ActorRelu2')
fullyConnectedLayer(numAct, 'Name', 'ActorFC3')
tanhLayer('Name','ActorTanh1')
scalingLayer('Scale',sc, 'Bias',bias)
];

--

--

Technical Source
Technical Source

Written by Technical Source

Simple! That is me, a simple person. I am passionate about knowledge and reading. That’s why I have decided to write and share a bit of my life and thoughts to.

No responses yet