CNNの入力層に対応したcsvデータのデータ処理
조회 수: 20 (최근 30일)
이전 댓글 표시
csvデータに対し1次元の畳み込みニューラルネットワークを作成する際に、複数のcsvデータを変数に格納しCNNの入力層に対応したデータの次元数を変えたいのですが、
wavedata = imageDatastore('C:\Users\MTL\Documents\notebook\matlabpracticecsv\drilldata','IncludeSubfolders',true, 'FileExtensions','.csv')
drilllabel = wavedata.Labels
[drilltrain,drilltest] = splitEachLabel(wavedata,0.8,'randomized');
Train_data = reshape(drilltrain, [1 4800 1 320]);
Test_data = reshape(drilltest, [1 4800 1 80]);
このコードで回すと エラー: reshape 要素数を RESHAPE するために変更してはいけません。 とエラーが出ます。
csvデータをCNNの入力層に対応するデータ処理はどう行えばよいのでしょうか?
댓글 수: 0
답변 (1개)
michio
2018년 6월 1일
reshape 関数 は数値配列に対して実行する関数ですので、
Train_data = reshape(drilltrain, [1 4800 1 320]);
と imageDatastore に対しては意味を持ちません。関数の挙動は
doc reshape
と実行するかウェブ上のドキュメンテーションページで確認してみてください。
では、どこで reshape が実行できるかといいますと、imageDatastore の ReadFcn プロパティで指定する読み込み関数内で実行するのがよいのではと。
wavedata = imageDatastore('C:\Users\MTL\Documents\notebook\matlabpracticecsv\drilldata','IncludeSubfolders',true, 'FileExtensions','.csv')
wavedata.ReadFcn = @readDatastoreCSV;
と設定します。readDatastoreCSV 関数は下記のような定義で試してください。
function data = readDatastoreCSV(filename)
data = csvread(filename);
data = reshape(data, [1 4800 1 80]);
何はともあれ、例えば csv ファイル単体で試してみるなどデバッグしやすいサイズでまず試してみることをお勧めします。 例:(test.csv) の読み込み
imds = imageDatastore('test.csv','ReadFcn',@csvread,'FileExtensions','.csv');
imds.ReadFcn = @readDatastoreCSV;
data = read(imds);
댓글 수: 4
참고 항목
카테고리
Help Center 및 File Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!