Laboratorio Matlab: differenze tra le versioni
Da Bioingegneria Elettronica e Informatica.
(→Reti Neurali Feed-Forward) |
|||
Riga 3: | Riga 3: | ||
<syntaxhighlight lang="matlab" line> | <syntaxhighlight lang="matlab" line> | ||
+ | clear all, close all | ||
+ | |||
+ | load cancer_dataset.mat | ||
+ | x = cancerInputs; | ||
+ | t = cancerTargets(1,:); | ||
+ | |||
+ | temp = [x;t]; | ||
+ | rng(0) | ||
+ | p = randperm(size(temp,2)); | ||
+ | |||
+ | train_size = floor(size(temp,2)*.8); | ||
+ | p_train = p(1:train_size); | ||
+ | p_test = p(train_size+1:end); | ||
+ | |||
+ | x_train = temp(1:9,p_train); | ||
+ | t_train = temp(10,p_train); | ||
+ | |||
+ | x_test = temp(1:9,p_test); | ||
+ | t_test = temp(10,p_test); | ||
+ | |||
+ | save('dataset2.mat','x_train','t_train','x_test','t_test') | ||
</syntaxhighlight> | </syntaxhighlight> |
Versione delle 14:27, 21 mag 2019
Reti Neurali Feed-Forward
Esempio di applicazione di reti neurali artificiali.
clear all, close all
load cancer_dataset.mat
x = cancerInputs;
t = cancerTargets(1,:);
temp = [x;t];
rng(0)
p = randperm(size(temp,2));
train_size = floor(size(temp,2)*.8);
p_train = p(1:train_size);
p_test = p(train_size+1:end);
x_train = temp(1:9,p_train);
t_train = temp(10,p_train);
x_test = temp(1:9,p_test);
t_test = temp(10,p_test);
save('dataset2.mat','x_train','t_train','x_test','t_test')