Problem using scalingLayer for shifting actor outputs to desired range

3 ビュー (過去 30 日間)
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?
Thanks
  3 件のコメント
Mostafa Nazmi
Mostafa Nazmi 2021 年 2 月 10 日
I'm using DDPG agent for this problem
Mostafa Nazmi
Mostafa Nazmi 2021 年 2 月 13 日
@Emmanouil Tzorakoleftherakis Any ideas how to fix this my friend?

サインインしてコメントする。

採用された回答

Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2021 年 2 月 13 日
If you remove ',...' from the 'tanh' row the error goes away. 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)
];
  3 件のコメント
Emmanouil Tzorakoleftherakis
Emmanouil Tzorakoleftherakis 2021 年 2 月 15 日
Np. Please accept the answer if it answered your question
Mostafa Nazmi
Mostafa Nazmi 2021 年 2 月 16 日
All done and thanks again!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by