Error: Unused Output Layer

조회 수: 29 (최근 30일)
Elaine Todd
Elaine Todd 2020년 1월 28일
답변: Elaine Todd 2020년 1월 31일
This is the full error I'm getting: Error using trainNetwork (line 150)
Invalid network.
Error in train (line 12)
Caused by:
Network: Missing output layer. The network must have one output layer.
Layer 4: Unused output. Each layer output must be connected to the input of another layer.
X is a 5 by 30 matrix that I'm trying to run through a relu, then a fully connected layer, and then a softmax to label the data as 0 or 1. I'm confused on why the softmaxLayer isn't taking in the data from the fullyConnectedLayer.
This is the function I'm trying to run.
function [trained_net] = train(X,Y)
% creates adam optimizer
options = trainingOptions('adam', 'InitialLearnRate',3e-4, ...
'SquaredGradientDecayFactor',0.99, 'MaxEpochs',20, ...
'MiniBatchSize',10, 'Plots','training-progress');
% creates layers
layers = [sequenceInputLayer(5)
reluLayer
fullyConnectedLayer(1)
softmaxLayer];
% trains network
trained_net = trainNetwork(X,Y,layers,options);

답변 (2개)

Elaine Todd
Elaine Todd 2020년 1월 31일
Turns out that even though Softmax is in the output layer category, it isn't counted as an output. I added in a classification output layer after the softmax and it runs now.

Harsha Priya Daggubati
Harsha Priya Daggubati 2020년 1월 31일
Hi,
I guess the issue is with fullConnectedLayer's outputSize, as it needs to be equal to the number of classes your network needs to classify. Try changing it to 2 and check whether it works.
  댓글 수: 1
Elaine Todd
Elaine Todd 2020년 1월 31일
That didn't fix it. Thanks for answering though.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by