need help to convert to a dlnetwork
14 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have this existing code
image = randi(255, [3,3,4]);
% create adder only network
inLayer = imageInputLayer(size(image), 'Name', 'data', 'Normalization', 'none');
addLayer = additionLayer(2, 'Name', 'add');
outLayer = regressionLayer('Name','output');
lgraph = layerGraph([inLayer, addLayer, outLayer]);
lgraph = connectLayers(lgraph, 'data', 'add/in2');
snet = assembleNetwork(lgraph);
I need to convert this to a dlnetwork and then train the dlnetwork using trainnet to replace the last regression output layer. How can I achieve the same?
0 Commenti
Risposta accettata
Ben
il 18 Set 2023
Modificato: Ben
il 18 Set 2023
The workflow for dlnetwork and trainnet would be something like the following:
image = randi(255,[3,3,4]);
% create network
net = [
imageInputLayer(size(image),Name="data",Normalization="none")
additionLayer(2,Name="add")];
% create as uninitialized so you can hook up the 2nd input to additionLayer before initializing
net = dlnetwork(net,Initialize = false);
net = connectLayers(net,"data","add/in2");
% initialize
net = initialize(net);
% train
opts = trainingOptions("adam");
% regressionLayer is not used, to specify loss you can use "mse" in trainnet
trainnet(image,image,net,"mse",opts);
0 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Data Workflows in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!