Too many output arguments
显示 更早的评论
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?

采纳的回答
Without knowing what ‘dataset’ is, although assuming that it is an array with 2 columns, try this:
Input = dataset(:,1);
Target = dataset(:,2);
10 个评论
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);
.
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.
the dataset i am using is https://archive.ics.uci.edu/ml/datasets/breast+cancer+wisconsin+(original)
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
.
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.
Thank you so much for your help, i greatly appreciate it.
As always, my pleasure!
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Workspace Variables and MAT Files 的更多信息
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
