comparison pylearn/algorithms/linear_regression.py @ 1504:bf5c0f797161

Fix test.
author Frederic Bastien <nouiz@nouiz.org>
date Mon, 12 Sep 2011 10:48:33 -0400
parents 9b371879c6ab
children 723e2d761985
comparison
equal deleted inserted replaced
1503:1ee532a6f33b 1504:bf5c0f797161
2 Implementation of linear regression, with or without L2 regularization. 2 Implementation of linear regression, with or without L2 regularization.
3 This is one of the simplest example of L{learner}, and illustrates 3 This is one of the simplest example of L{learner}, and illustrates
4 the use of theano. 4 the use of theano.
5 """ 5 """
6 6
7 from pylearn.old_dataset.learner import OfflineLearningAlgorithm,OnlineLearningAlgorithm 7 #from pylearn.old_dataset.learner import OfflineLearningAlgorithm,OnlineLearningAlgorithm
8 from theano import tensor as T 8 from theano import tensor as T
9 from theano.tensor.nnet import prepend_1_to_each_row 9 from theano.tensor.nnet import prepend_1_to_each_row
10 from theano.scalar import as_scalar 10 from theano.scalar import as_scalar
11 from common.autoname import AutoName 11 from common.autoname import AutoName
12 import theano 12 import theano
13 import numpy 13 import numpy
14 14
15 class LinearRegression(OfflineLearningAlgorithm): 15 class LinearRegression():#OfflineLearningAlgorithm):
16 """ 16 """
17 Implement linear regression, with or without L2 regularization 17 Implement linear regression, with or without L2 regularization
18 (the former is called Ridge Regression and the latter Ordinary Least Squares). 18 (the former is called Ridge Regression and the latter Ordinary Least Squares).
19 19
20 Usage: 20 Usage:
184 def linear_predictor(inputs,params,*otherargs): 184 def linear_predictor(inputs,params,*otherargs):
185 p = LinearPredictor(params) 185 p = LinearPredictor(params)
186 return p.compute_outputs(inputs) 186 return p.compute_outputs(inputs)
187 187
188 #TODO : an online version 188 #TODO : an online version
189 class OnlineLinearRegression(OnlineLearningAlgorithm): 189 class OnlineLinearRegression():#OnlineLearningAlgorithm):
190 """ 190 """
191 Training can proceed sequentially (with multiple calls to update with 191 Training can proceed sequentially (with multiple calls to update with
192 different disjoint subsets of the training sets). After each call to 192 different disjoint subsets of the training sets). After each call to
193 update the predictor is ready to be used (and optimized for the union 193 update the predictor is ready to be used (and optimized for the union
194 of all the training sets passed to update since construction or since 194 of all the training sets passed to update since construction or since