how to train dataset

1 Ansicht (letzte 30 Tage)
Kamil Kacer
Kamil Kacer am 20 Nov. 2020
Kommentiert: Walter Roberson am 20 Nov. 2020
Hi Iam trying to train a dataset on a short term basis of 1 Sample with 3 Features so I expect 3 row matrix.
The problem is i get an empty matrix.
Do you know where the problem is ? example would be helpfull
function kNN_model_add_class(modelName, className, classPath, ...
stWin, stStep)
%
% function kNN_model_add_class(modelName, className, classPath, ...
% listOfStatistics, stWin, stStep, mtWin, mtStep)
%
% This function adds an audio class to the kNN classification model
%
% ARGUMENTS;
% - modelName: the filename of the model (mat file)
% - className: the name of the audio class to be added to the model
% - classPath: the path of the directory where the audio segments of the
% new class are stored
% - listOfStatistics: list of mid-term statistics (cell array)
% - stWin, stStep: short-term window size and step
% - mtWin, mtStep: mid-term window size and step
%
% Example:
% kNN_model_add_class('modelSpeech.mat', 'speech', './Music/', ...
% {'mean','std',}, 0.050, 0.025, 2.0, 1.0);
%
if ~exist(classPath,'dir')
error('Audio sample path is not valid!');
else
classPath = [classPath filesep];
end
% check if the model elaready exists:
fp = fopen(modelName, 'r');
if fp>0 % check if file already exists
load(modelName);
end
% Feature extraction:
D = dir([classPath '*.wav']);
F = [];
for (i=1:length(D)) % for each wav file in the given path:
curFileName = [classPath D(i).name];
FileNamesTemp{i} = curFileName;
% mid-term feature extraction for each wav file:
% [data, fs] = audioread(curFileName);
% signal = struct('Filt_data', data, 'SampleRate', fs);
Features = stFeatureExtraction(curFileName, 44100, stWin, stStep)
% midFeatures = featureExtractionFile(curFileName, ...
% stWin, stStep, mtWin, mtStep, listOfStatistics);
% long-term averaging:
longFeatures = mean(Features,2);
F = [F longFeatures];
end
% save the model:
if ~exist(modelName, 'file') % model does not exist --> generate
ClassNames{1} = className;
Features{1} = F;
FileNames{1} = FileNamesTemp;
save(modelName, 'ClassNames', 'Features', ...
'stWin', 'stStep','FileNames');
else
load(modelName);
ClassNames{end+1} = className;
Features{end+1} = F;
FileNames{end+1} = FileNamesTemp;
save(modelName, 'ClassNames', 'Features', ...
'stWin', 'stStep','FileNames');
end
  1 Kommentar
Walter Roberson
Walter Roberson am 20 Nov. 2020
Are you saying that longFeatures is empty after stFeatureExtraction ?
Or is it possible that nothing is being matched in D and so stFeatureExtraction is not being called?

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Pretrained Models finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by