Merge pull request #218 from phreeza/conv_reg

Add regularization and constraints for Convolution1D and Convolution2D
Esse commit está contido em:
François Chollet
2015-06-12 11:07:22 -07:00
+10 -2
Ver Arquivo
@@ -13,7 +13,8 @@ from ..layers.core import Layer
class Convolution1D(Layer):
def __init__(self, nb_filter, stack_size, filter_length,
init='uniform', activation='linear', weights=None,
image_shape=None, border_mode='valid', subsample_length=1):
image_shape=None, border_mode='valid', subsample_length=1,
W_regularizer=None, b_regularizer=None, W_constraint=None, b_constraint=None):
nb_row = 1
nb_col = filter_length
@@ -35,6 +36,9 @@ class Convolution1D(Layer):
self.params = [self.W, self.b]
self.regularizers = [W_regularizer, b_regularizer]
self.constraints = [W_constraint, b_constraint]
if weights is not None:
self.set_weights(weights)
@@ -82,7 +86,8 @@ class MaxPooling1D(Layer):
class Convolution2D(Layer):
def __init__(self, nb_filter, stack_size, nb_row, nb_col,
init='glorot_uniform', activation='linear', weights=None,
image_shape=None, border_mode='valid', subsample=(1,1)):
image_shape=None, border_mode='valid', subsample=(1,1),
W_regularizer=None, b_regularizer=None, W_constraint=None, b_constraint=None):
super(Convolution2D,self).__init__()
self.init = initializations.get(init)
@@ -102,6 +107,9 @@ class Convolution2D(Layer):
self.params = [self.W, self.b]
self.regularizers = [W_regularizer, b_regularizer]
self.constraints = [W_constraint, b_constraint]
if weights is not None:
self.set_weights(weights)