24小时热门版块排行榜    

查看: 634  |  回复: 1

yliueagle

新虫 (初入文坛)

[交流] 1stopt 神经网络 已有1人参与

想用1stopt做一个约束神经网络,大概意思是 Predicted = ANN (Input,w),Input 为 [x1, x2, ... , xp] , Output 为 y. 目标函数写成  sum(Output - Predicted) + lambda* sum (w^2) (对权重进行惩罚).
遇到的问题是,不知道1stopt怎么表述 目标函数 sum(Output - Predicted) + lambda* sum (w^2) .

大致的代码已经写在下面,请高手指点
Variables x(1:3), y;   //Define input and output, read from data

Parameter w10(1:3), w11(1), w12(1), w13(1); //Weight of 1st layer of ANN
Parameter w20(1:2), w21(1:2), w22(1:2), w23(1:2); //Weight of 2nd layer of ANN
Parameter w30(1),   w31(1),   w32(1); //Weight of 3rd layer of ANN
Parameter w40(1),   w41(1);  //Weight of last layer

Constant lambda=10;  //penalty rate

ParameterDomain = [-10,10];

//construct a neural network
//such that predicted = ANN (input, w)

ConstStr s11=1*w10[1] + x[1]*w11[1];
ConstStr s12=1*w10[2] + x[2]*w12[1];
ConstStr s13=1*w10[3] + x[3]*w13[1];

ConstStr x11=(Exp(s11)-Exp(-s11))/(Exp(s11)+Exp(-s11));
ConstStr x12=(Exp(s12)-Exp(-s12))/(Exp(s12)+Exp(-s12));
ConstStr x13=(Exp(s13)-Exp(-s12))/(Exp(s13)+Exp(-s13));

ConstStr s21=1*w20[1] + x11*w21[1] + x12*w22[1] + x13*w23[1];
ConstStr s22=1*w20[2] + x11*w21[2] + x12*w22[2] + x13*w23[2];

ConstStr x21=(Exp(s21)-Exp(-s21))/(Exp(s21)+Exp(-s21));
ConstStr x22=(Exp(s22)-Exp(-s22))/(Exp(s22)+Exp(-s22));


ConstStr s31=1*w30[1] + x21*w31[1] + x22*w32[1];

ConstStr x31=(Exp(s31)-Exp(-s31))/(Exp(s31)+Exp(-s31));
ConstStr x41=1*w40[1] + x31*w41[1];

//penalize the weight
ConstStr Pen=(Abs(w11[1]) + Abs(w12[1]) + Abs(w13[1]));


//define the object function
//my problem is HOW to define the object function!!!!!!!!!!

Function y=x41 + lambda*Pen;

Data;
-1.681641572        1.093582247        1.100830272        -0.48571944
-0.729512802        0.650622043        0.741604004        -0.306203759
0.196395049        -1.03441539        -1.226583404        1.266410248
0.30027026        0.704671974        0.848601676        0.79683285
0.061931399        0.020863468        0.860518704        0.062366683
1.698784087        -0.61912183        0.432315092        2.082095927
1.14679752        0.427830798        -0.263937473        1.329836712
0.214324781        0.091548418        0.793921988        0.222705894
-0.830169848        -0.921937213        -0.935921936        0.019798377
0.586923897        0.59702383        0.533025371        0.943361351
1.588602336        -0.089786046        -1.069348399        1.59666387
-0.090178631        1.302791573        1.490152267        1.607087252
-1.23330565        -0.158105757        0.240996113        -1.20830822
0.614905436        -2.105734619        -0.696701884        5.049023722
-1.140435923        -1.370486438        -1.064975242        0.737797153
-0.703690339        1.41065294        -1.784497148        1.286251379

另外感觉1stopt的手册讲得好不全啊,一些基本关键词和语法都没有讲明怎么用,哪儿可以找到详细一点的用法?

谢谢!
回复此楼

» 猜你喜欢

» 本主题相关价值贴推荐,对您同样有帮助:

已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

dingd

铁杆木虫 (职业作家)

★ ★
小木虫: 金币+0.5, 给个红包,谢谢回帖
fegg7502: 金币+1, 鼓励交流 2014-02-14 10:03:34
楼主神经网络中的转换函数是用的tanh函数,范围在[-1,1]之间,楼主似乎并没有进行数据均匀化,比如时间输出值y有不少点都在[-1,1]之外,没问题吗?
2楼2014-02-13 10:18:25
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 yliueagle 的主题更新
普通表情 高级回复 (可上传附件)
信息提示
请填处理意见