Skip to content

Instantly share code, notes, and snippets.

@limzunyuan
Created January 2, 2016 18:03
Show Gist options
  • Save limzunyuan/2ba543b263300a874853 to your computer and use it in GitHub Desktop.
Save limzunyuan/2ba543b263300a874853 to your computer and use it in GitHub Desktop.
function [net] = create_traingd(x, y, list_num_hidden_neurons, ...
num_epochs, train_idx, validation_idx, test_idx, lr)
%[x2, y2] = ANNdata(x, y);
net = feedforwardnet(list_num_hidden_neurons);
net = configure(net, x, y);
net.trainFcn = 'traingd';
net.divideFcn = 'divideind';
net.divideParam.trainInd = train_idx;
net.divideParam.valInd = validation_idx;
net.divideParam.testInd = test_idx;
net.trainParam.lr = lr;
net.trainParam.epochs = num_epochs;
net.performFcn = 'crossentropy';
net.layers{3}.transferFcn = 'logsig';
net = train(net, x, y);
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment