Training with trainNetwork failed. Invalid transform function defined on datastore.
显示 更早的评论
I'm trying to perform Transfer Learnign starting from the pretrained Yamnet network. This is the code to split and preprocess data:
%Create datastore, label data and split data for training, validation and testing
pathToAudio = "Results\AudioFiles3";
AudioDS = audioDatastore(pathToAudio,"IncludeSubfolders",true,"FileExtensions",".flac","LabelSource","foldernames");
[AudioTrain,AudioValidation,AudioTest] = splitEachLabel(AudioDS,0.7,0.2,0.1,"randomized");
% Use the transform function to preprocess the data using the function audioPreprocess, found at the end of this example. For each signal:
% Use yamnetPreprocess (Audio Toolbox) to generate mel spectrograms suitable for training using YAMNet. Each audio signal produces multiple spectrograms.
% Duplicate the class label for each of the spectrograms.
tdsTrain = transform(AudioTrain,@audioPreprocess,IncludeInfo=true);
tdsValidation = transform(AudioValidation,@audioPreprocess,IncludeInfo=true);
tdsTest = transform(AudioTest,@audioPreprocess,IncludeInfo=true);
This is the supporting function:
% The function audioPreprocess uses yamnetPreprocess (Audio Toolbox) to generate mel spectrograms
% from audioIn that you can feed to the YAMNet pretrained network. Each input signal generates multiple spectrograms,
% so the labels must be duplicated to create a one-to-one correspondence with the spectrograms.
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;
end
end
Afterwards, I open the Deep Network Designer and and select the "YamNet" network, I substitute the last fullyConnected layer (to give 2 classes as output) and the classification layer. After starting to train the network, I get the following error after a few iterations:
"Training with trainNetwork failed.
Invalid transform function defined on datastore."
Basically I am trying to reproduce what is done at this page (https://it.mathworks.com/help/deeplearning/ug/transfer-learning-with-audio-networks-in-deep-network-designer.html) with my how data.
Do anybody have a clue about where I could act to solve this?
Thanks in advance
1 个评论
T.Nikhil kumar
2023-11-28
Can you please attach your dataset?
采纳的回答
更多回答(0 个)
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!