BAYESIAN OPTIMIZATION OF A NEURAL NETWORK

I wrote the following code to optimize the architecture of a neural network via Bayesian optimization. What's wrong with it?
clc
clear
data = xlsread('Geor.xls')
t = data(:,5)'
x = data(:,1:4)'
trainFcn = 'trainbr';
hiddenLayerSize = optimizableVariable('hiddenLayerSize',[1,4]);
net.divideParam.trainRatio = optimizableVariable('net.divideParam.trainRatio',[0.4,0.75]);
vars =[hiddenLayerSize, net.divideParam.trainRatio]
net = fitnet(hiddenLayerSize,trainFcn);
net.divideParam.valRatio = 0.5*(100-net.divideParam.trainRatio*100)/100;
net.divideParam.testRatio = 0.5*(100-net.divideParam.trainRatio*100)/100;
[net,tr] = train(net,x,t);
y = net(x);
e = gsubtract(t,y);
mae = sum(abs(e))/40
performance = perform(net,t,y);
fun = @(x)mae(x, vars)
results = bayesopt(fun,vars)

3 件のコメント

Peter Meglis
Peter Meglis 2018 年 8 月 7 日
Georgios,
"What's wrong with it?" Is an incredibly vague question. People here most likely aren't going to go through your code line by line and debug it for you. It will be beneficial to yourself and everyone else here if you add some details behind your question. It is better if you can have some specific questions that we can help answer.
Is there a certain error you are getting? Are the values you are getting unexpected? Is there a certain line of code that you have narrowed the problem down to?
Thanks
Greg Heath
Greg Heath 2018 年 8 月 7 日
If you want to use data to explain your problem, use a MATLAB set:
help nndatasets
and
doc nndatasets
Greg
Greg Heath
Greg Heath 2018 年 8 月 7 日
close all, clear all, clc
x = [-1:.05:1]; % FROM HELP TRAINBR
t = sin(2*pi*x)+0.1*randn(size(x));
trainFcn = 'trainbr';
hiddenLayerSize = optimizableVariable ('hiddenLayerSize',[1,4]);
net.divideParam.trainRatio = optimizableVariable('net.divideParam.trainRatio',[0.4,0.75]);
vars =[hiddenLayerSize,net.divideParam.trainRatio]
net = fitnet(hiddenLayerSize,trainFcn);
Error using fitnet (line 69)
Parameters.hiddenSizes is not numeric.

サインインしてコメントする。

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

質問済み:

2018 年 8 月 7 日

コメント済み:

2018 年 8 月 7 日

Community Treasure Hunt

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

Start Hunting!

Translated by