hi, i newbie to matlab i am creating a very simple feed forward network, but i keep getting the too many output arguments error. what can i do?

 채택된 답변

Star Strider
Star Strider 2020년 12월 28일

0 개 추천

Without knowing what ‘dataset’ is, although assuming that it is an array with 2 columns, try this:
Input = dataset(:,1);
Target = dataset(:,2);
Note that the dataset class is a collection of functions for constructing Dataset Arrays.

댓글 수: 10

Ditf
Ditf 2020년 12월 28일
ah what if it has 11 columns and the first 10 are the input and the last colomn is the output
In that case:
Input = dataset(:,1:10);
Output = dataset(:,11);
or equivalently:
Input = dataset(:,1:end-1);
Output = dataset(:,end);
.
Ditf
Ditf 2020년 12월 28일
i have done what you suggested but i still get 'input and target have different number of samples', can you help?
Well this is a different dataset than the first time you asked. Please attach the breastcancer.mat file.
In the meantime, input has 10 columns while target has 1 columns. It says they need the same number of samples. Can you take just one of the columns of input
inputColumn = breastcancer(:, 1); % Take column 1.
Do NOT use input as the name of your variable since that is a built-in function that you do not want to blow away.
Ditf
Ditf 2020년 12월 28일
it needs all 10 attributes as inputs to make that one output
what can i do?
Assuming you need to use ‘breast-cancer-wisconsin.data’, the way I chose to import it is:
opts = detectImportOptions('breast-cancer-wisconsin.data', 'FileType','text');
BCTable = readtable('breast-cancer-wisconsin.data', opts);
InputVariables = BCTable(:,1:10);
OutputVariable = BCTable(:,11);
and that appears to work.
Examing the imported file with:
FirstFiveRows = BCTable(1:5,:)
produces:
FirstFiveRows =
5×11 table
Var1 Var2 Var3 Var4 Var5 Var6 Var7 Var8 Var9 Var10 Var11
_______ ____ ____ ____ ____ ____ ____ ____ ____ _____ _____
1000025 5 1 1 1 2 1 3 1 1 2
1002945 5 4 4 5 7 10 3 2 1 2
1015425 3 1 1 1 2 2 3 1 1 2
1016277 6 8 8 1 3 4 3 7 1 2
1017023 4 1 1 3 2 1 3 1 1 2
.
Ditf
Ditf 2020년 12월 29일
yes it work but when i try to configure the network i get the error that the input data is not a matrix or cell array.
Try this to create a matrix from them:
InputVariables = table2array(BCTable(:,1:10));
OutputVariable = table2array(BCTable(:,11));
See the documentation on table2array for details on the function. You can also use table2cell, linked to in the table2array documentation, if you want them as a cell array instead.
Ditf
Ditf 2020년 12월 29일
Thank you so much for your help, i greatly appreciate it.
Star Strider
Star Strider 2020년 12월 29일
As always, my pleasure!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Workspace Variables and MAT Files에 대해 자세히 알아보기

질문:

2020년 12월 28일

댓글:

2020년 12월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by