How to use trainNetwork with transform datastore with multiple outputs?

7 visualizaciones (últimos 30 días)
my code create a audioDataStore, transform it to yamnet features (mel spectrum) and try to train it.
But i get the following error:
Input datastore returned more than one observation per row for network input 1.
The code:
net = yamnet;
DS = audioDatastore(FolderName, ...
DS.Labels = setcats(DS.Labels,cellstr(net.Layers(86).Classes));
TR = transform(DS,@(audio,info)preProcess(audio,info),"IncludeInfo",true);
options = trainingOptions("adam");
function [data,info] = preProcess(audio,info)
data{1} = yamnetPreprocess(audio,info.SampleRate);
data{2} = repmat(info.Label,1,size(data{1},4));
Yamnet produce multiple observations for each audio file (for instance, for 10 seconds file it will create 96×64×1×19 matrix which are 19 observations. For some reason trainNetwork want only one observation, how do I fix it?

Respuesta aceptada

jibrahim el 9 de Feb. de 2023
Hi Noam,
Check out this example:
The example uses a transformed datastore as well. the transformation function is at the bottom:
function [data,info] = audioPreprocess(audioIn,info)
class = info.Label;
fs = info.SampleRate;
features = yamnetPreprocess(audioIn,fs);
numSpectrograms = size(features,4);
data = cell(numSpectrograms,2);
for index = 1:numSpectrograms
data{index,1} = features(:,:,:,index);
data{index,2} = class;

Más respuestas (0)


Más información sobre Image Data Workflows en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by