【deep learning学习笔记】注释yusugomori的LR代码 --- LogisticRegression.h

继续看yusugomori的代码,看逻辑回归。在DBN(Deep Blief Network)中,下面几层是RBM,最上层就是LR了。关于回归、二类回归、以及逻辑回归,资料就是前面转的几篇。套路就是设定目标函数(softmax损失函数),对参数求偏导数,得出权重更新公式等。

LogisticRegression.h注释如下:

class LogisticRegression 
{
public:
  	int N;  		// number of input samples
  	int n_in;		// number of input nodes
  	int n_out;		// number of output nodes
  	double **W;		// weights connecting the input nodes and the output nodes
  	double *b;		// bias of the output nodes
  	// allocate memory and initialize the parameters
  	LogisticRegression(
  			int, 	// N
  			int, 	// n_in
  			int		// n_out
		  	);
  	~LogisticRegression();
  
public:
	// train the logistic regression model, update the value of W and b
  	void train (
	  		int*, 	// the input from input nodes in training set
	  		int*, 	// the output from output nodes in training set
	  		double	// the learning rate
		  );
 	// calculate the softmax for a input vector
 	// dSoftMax = exp(d_i - Max) / sum_i( exp(d_i - Max) )
  	void softmax (
	  		double*	// the calculated softmax probabiltiy -- input & output
			  );
	// do prediction by calculating the softmax probability from input
  	void predict (
	  		int*, 	// the input from input nodes in testing set
	  		double*	// the calculated softmax probability
			  );
};

顺便提一句。从前RBM的那个注释,是在家用VS2008写的;现在这个,用CFree5.0,轻量级、编辑器操作贴心,赞一下!


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值