Neural Network Last Layer Shows a Different Number of Outputs

4 ビュー (過去 30 日間)
Nour Aburaed
Nour Aburaed 2019 年 1 月 29 日
編集済み: Nour Aburaed 2019 年 1 月 30 日
So I have the following inputs and outputs with their respective dimenions
input: 521 x 21048
output: 15 x 21048
So basically I have 15 classes, and the network should tell me what class the input belongs to.
This is the network's configuration:
trainFcn = 'trainscg';
hiddenLayerSize = ([10 5]);
net = patternnet(hiddenLayerSize, trainFcn);
net.input.processFcns = {'removeconstantrows','mapminmax'};
net.divideFcn = 'dividerand'; % Divide data randomly
net.divideMode = 'sample'; % Divide up every sample
net.divideParam.trainRatio = 90/100;
net.divideParam.valRatio = 5/100;
net.divideParam.testRatio = 5/100;
net.performFcn = 'crossentropy'; % Cross-Entropy
net.plotFcns = {'plotperform','plottrainstate','ploterrhist', ...
'plotconfusion', 'plotroc'};
[net,tr] = train(net,x,t);
However, when I view the network, it always shows the output player with "13" outputs instead of 15!
This does not happen when I use the GUI to train the network. But as soon as I use the advanced scipt (even with the same configurations I set in the GUI) I still get 13 in the output layer, whether it is 1 layer or multiple ones.
  2 件のコメント
Greg Heath
Greg Heath 2019 年 1 月 30 日
I still get 15 with
close all, clear all, clc
x = randn( 521, 21048);
t = rand( 15, 21048);
YOUR CODE
view(net)
HOPE THIS HELPS
GREG
Nour Aburaed
Nour Aburaed 2019 年 1 月 30 日
I have just figured out the problem. I have no inputs that yield to classes 10 and 5, which makes the network skip them and just stick to 13 classes. Thank you for taking time to help!

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

回答 (1 件)

Greg Heath
Greg Heath 2019 年 1 月 29 日
編集済み: Greg Heath 2019 年 1 月 30 日
Line 2: target, not output
trainFcn is undefined.
I get 15, not 13 in the figure
Hope this helps.
Thank you for formally accepting my answer
Greg
  1 件のコメント
Nour Aburaed
Nour Aburaed 2019 年 1 月 29 日
編集済み: Nour Aburaed 2019 年 1 月 29 日
1- I am writing "output" in the decription only, in order to be consistent with the figure shown.
2- trainFcn is defined in my code. I will add it to my post. (otherwise the code wouldn't run to begin with)
3- I get 13. Not 15. The layer right before the last shows 13, inconsistent with the final output I am supposed to get.

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

カテゴリ

Help Center および File ExchangeSequence and Numeric Feature Data Workflows についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by