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
Star Strider
Star Strider 2020 年 12 月 28 日
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?
Image Analyst
Image Analyst 2020 年 12 月 28 日
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?
Star Strider
Star Strider 2020 年 12 月 29 日
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.
Star Strider
Star Strider 2020 年 12 月 29 日
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 ExchangeWorkspace 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