필터 지우기
필터 지우기

How to create a training data from excel sheet to matlab?

조회 수: 3 (최근 30일)
Nadiah Zainudin
Nadiah Zainudin 2017년 11월 10일
댓글: NICOLE MIN 2020년 5월 18일
close all; clear all; clc;
%load data & display data1= xlsread('DSN OFFSET.xlsx','R0'); disp(data1);
%filter data(divide training sets and test sets) X = data1(2,:); Y = data1(3,:);
%train = training data
What do i do next?

답변 (1개)

Shashika Munasingha
Shashika Munasingha 2019년 6월 3일
편집: Shashika Munasingha 2020년 5월 17일
There is a solution for this. I encountered similar problem and struggled for a while as there was no proper answer found in MatLab community. This is little bit lengthy and may not be the optimum solution, but hopefully this will solve some of your issues.
In my excel/csv, I have feature vector of length 7 and one output.
Here I used MatLab Deep Network Designer Toolbox (quite new toolbox) to generate the layer architecture and designed a nn setting input layer of dimension [7,1,1]. Design your network as you wish, but pay attention to the size of the inputs and outputs from each layer. They must be tallied with the data vectors in your excel/csv.
Import the NN model to MatLab workspace or you can create NN from scratch using code.
%% your layer architecture variable
net_layers
What I am going to highlight here is arranging our data such that it could be fed into our model.
%% importing data from csv file and separating them into target and input arrays %%
[~,~,data] = xlsread('temperature_feature_vector.csv');
data_mat = cell2mat(data);
target_array = categorical(data_mat(:,8));
input_array = data_mat(:,1:7);
%% reshaping input data such that it matches our model 2D ---> 4D
%% there are 53 input vectors in this example
x = reshape(input_array',[7,1,1,53]);
Now you have shaped your data accordingly. You are ready to train your network !!!
%define options for your network. you can change accordingly
options = trainingOptions('sgdm', ...
'ExecutionEnvironment','auto', ...
'InitialLearnRate',0.000003, ...
'LearnRateSchedule','piecewise', ...
'MaxEpochs',10, ...
'MiniBatchSize',1, ...
'SequenceLength','longest', ...
'Shuffle','never', ...
'Verbose',0, ...
'Plots','training-progress');
net = trainNetwork(x,target_array,net_layers,options);
With this method you can easily use deep nn models to train your data
Trick is in reshaping your data and defining of layer architecture accordingly.
  댓글 수: 10
NICOLE MIN
NICOLE MIN 2020년 5월 18일
i got this issue, is matlab version incompatible?
NICOLE MIN
NICOLE MIN 2020년 5월 18일
firstly, ive copy the whole chuck of coding from the dic under read entire dataset, issue arises. secondly, ive tried replacing 'TEMPERATURE' TO 'X' same issue occur too. im not sure what is going on . i appreviacte very much if this issue can find a solution. thanks

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

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by