Building an Neural network with multiple inputs

11 ビュー (過去 30 日間)
Ditf
Ditf 2020 年 12 月 29 日
コメント済み: Image Analyst 2021 年 1 月 2 日
hi, Matlab Newbie
i have to create an Artificial Neural Network to classify using this datatset https://archive.ics.uci.edu/ml/datasets/breast+cancer+wisconsin+(original)
it take 10 input to one output
this is my code, i keep getting the error of " input and outputs have different samples" i know it is because i have 10 inputs and one 1 input but how can i fix it as i need all the 10 inputs?
close all
clear
clc
opts = detectImportOptions('breast-cancer-wisconsin.data', 'filetype','text');
BCTable = readtable('breast-cancer-wisconsin.data',opts);
InputVariable = table2array(BCTable(:,1:10));
OutputVariable = table2array(BCTable(:,11));
net = feedforwardnet(10, 'trainlm');
net = configure (net, InputVariable,OutputVariable);
[net,tr] = train(net,InputVariable, OutputVariable);
  1 件のコメント
Image Analyst
Image Analyst 2021 年 1 月 2 日
Original question attached, in case he deletes this one also.

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 12 月 29 日
The 10 in the line
feedforwardnet(10, 'trainlm');
have nothing to do with the number of inputs. You can put any number here. It is the number of hidden neurons in the first layer. The actual issue is the orientation of InputVariable and OutputVariable. MATLAB expects that each column of the input matrix contains a sample, and the number of columns is equal to the total number of samples. Similar is required for the output matrix. However, in your case, the samples are arranged row-wise. Just take the transpose of these matrices.
net = configure (net, InputVariable.',OutputVariable.');
[net,tr] = train(net, InputVariable.', OutputVariable.');
  2 件のコメント
Ditf
Ditf 2020 年 12 月 29 日
編集済み: Ditf 2020 年 12 月 29 日
thank you so much, been stuck at it all day.
Ameer Hamza
Ameer Hamza 2020 年 12 月 29 日
I am glad to be of help! :)

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by