Beispiel #1
0
	def connect(self,layer_below):
		self.layer_below = layer_below
		self.inputD = layer_below.size
		self.Wuh = self.init((self.inputD,self.size))
		self.Whh = self.init((self.size,self.size))
		self.buh = zero0s((1,self.size))
		self.h0 = zero0s((1,self.size))
		self.params = [self.Wuh, self.Whh, self.buh]

		if self.weights is not None:
			for param, weight in zip(self.params,self.weights):
				param.set_value(np.asarray(weight, dtype=theano.config.floatX))

		self.L2_sqr = (self.Wuh ** 2).sum() + (self.Whh ** 2).sum()
Beispiel #2
0
	def connect(self,layer_below):
		self.layer_below = layer_below
		self.inputD = layer_below.size

		self.W_i = self.init((self.inputD,self.size))
		self.W_f = self.init((self.inputD,self.size))
		self.W_o = self.init((self.inputD,self.size))
		self.W_c = self.init((self.inputD,self.size))

		self.U_i = self.init((self.size,self.size))
		self.U_f = self.init((self.size,self.size))
		self.U_o = self.init((self.size,self.size))
		self.U_c = self.init((self.size,self.size))

		self.b_i = zero0s((1,self.size)) 
		self.b_f = zero0s((1,self.size))
		self.b_o = zero0s((1,self.size))
		self.b_c = zero0s((1,self.size))

		self.h0 = zero0s((1,self.size))
		self.c0 = zero0s((1,self.size))

		self.params = [self.W_i, self.W_f, self.W_o, self.W_c,
			self.U_i, self.U_f, self.U_o, self.U_c,
			self.b_i, self.b_f, self.b_o, self.b_c
			]

		if self.weights is not None:
			for param, weight in zip(self.params,self.weights):
				param.set_value(np.asarray(weight, dtype=theano.config.floatX))

		self.L2_sqr = (
				(self.W_i ** 2).sum() +
				(self.W_f ** 2).sum() +
				(self.W_o ** 2).sum() +
				(self.W_c ** 2).sum() +
				(self.U_i ** 2).sum() +
				(self.U_f ** 2).sum() +
				(self.U_o ** 2).sum() +
				(self.U_c ** 2).sum() 
			)