How to create nnet.layers usable for custom training loops as well as trainNetwork?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hei all,
I would like to create a layer that can be pretrained in a custom training loop and afterwards finetuned with the trainNetwork function. I created a class with the needed properties and a predict function:
function Z = predict(layer, X)
Z = sigmoid(fullyconnect(X, layer.weights, layer.biases));
end
Using this function works fine during the pretraining. Using trainNetwork afterwards leads to the error:
Error using validateDataFormat (line 14)
Specify 'DataFormat' when first argument is an unlabeled dlarray or numeric array.
This is caused by fullyconnect as it needs dlarrays or the correct format string. I try to make it as universal as possible, so i don't want to set the Format property on the fullyconnect command. Is there a way to force trainNetwork to use dlarrays?
Thanks in advance,
Niklas
0 commentaires
Réponses (1)
Sai Bhargav Avula
le 24 Oct 2019
Hi,
As you mentioned the fullyconnect applies fully connect operation to dlarray data. For your custom layer to be made compactable to trainNetwork you should convert that using the fullyConnetedLayer by following template.
Or
0 commentaires
Voir également
Catégories
En savoir plus sur Custom Layers dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!