本文整理汇总了Python中lasagne.layers.ReshapeLayer方法的典型用法代码示例。如果您正苦于以下问题:Python layers.ReshapeLayer方法的具体用法?Python layers.ReshapeLayer怎么用?Python layers.ReshapeLayer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lasagne.layers
的用法示例。
在下文中一共展示了layers.ReshapeLayer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_generator_32
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_generator_32(noise=None, ngf=128):
# noise input
InputNoise = InputLayer(shape=(None, 100), input_var=noise)
#FC Layer
gnet0 = DenseLayer(InputNoise, ngf*4*4*4, W=Normal(0.02), nonlinearity=relu)
print ("Gen fc1:", gnet0.output_shape)
#Reshape Layer
gnet1 = ReshapeLayer(gnet0,([0],ngf*4,4,4))
print ("Gen rs1:", gnet1.output_shape)
# DeConv Layer
gnet2 = Deconv2DLayer(gnet1, ngf*2, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=relu)
print ("Gen deconv1:", gnet2.output_shape)
# DeConv Layer
gnet3 = Deconv2DLayer(gnet2, ngf, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=relu)
print ("Gen deconv2:", gnet3.output_shape)
# DeConv Layer
gnet4 = Deconv2DLayer(gnet3, 3, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=tanh)
print ("Gen output:", gnet4.output_shape)
return gnet4
示例2: build_generator_64
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_generator_64(noise=None, ngf=128):
# noise input
InputNoise = InputLayer(shape=(None, 100), input_var=noise)
#FC Layer
gnet0 = DenseLayer(InputNoise, ngf*8*4*4, W=Normal(0.02), nonlinearity=relu)
print ("Gen fc1:", gnet0.output_shape)
#Reshape Layer
gnet1 = ReshapeLayer(gnet0,([0],ngf*8,4,4))
print ("Gen rs1:", gnet1.output_shape)
# DeConv Layer
gnet2 = Deconv2DLayer(gnet1, ngf*8, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=relu)
print ("Gen deconv2:", gnet2.output_shape)
# DeConv Layer
gnet3 = Deconv2DLayer(gnet2, ngf*4, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=relu)
print ("Gen deconv3:", gnet3.output_shape)
# DeConv Layer
gnet4 = Deconv2DLayer(gnet3, ngf*4, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=relu)
print ("Gen deconv4:", gnet4.output_shape)
# DeConv Layer
gnet5 = Deconv2DLayer(gnet4, ngf*2, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=relu)
print ("Gen deconv5:", gnet5.output_shape)
# DeConv Layer
gnet6 = Deconv2DLayer(gnet5, 3, (3,3), (1,1), crop='same', W=Normal(0.02),nonlinearity=tanh)
print ("Gen output:", gnet6.output_shape)
return gnet6
示例3: OrthoInitRecurrent
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def OrthoInitRecurrent(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1, n_hid=200, init_val=0.9, out_nlin=lasagne.nonlinearities.linear):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var==None:
l_mask=None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_in_hid = DenseLayer(lasagne.layers.InputLayer((None, n_in)), n_hid, W=lasagne.init.GlorotNormal(0.95), nonlinearity=lasagne.nonlinearities.linear)
l_hid_hid = DenseLayer(lasagne.layers.InputLayer((None, n_hid)), n_hid, W=lasagne.init.Orthogonal(gain=init_val), nonlinearity=lasagne.nonlinearities.linear)
l_rec = lasagne.layers.CustomRecurrentLayer(l_in, l_in_hid, l_hid_hid, nonlinearity=lasagne.nonlinearities.tanh, mask_input=l_mask, grad_clipping=100)
# Output Layer
l_shp = ReshapeLayer(l_rec, (-1, n_hid))
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.GlorotNormal(0.95), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec
示例4: LeInitRecurrent
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def LeInitRecurrent(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1, n_hid=200, diag_val=0.9, offdiag_val=0.01, out_nlin=lasagne.nonlinearities.linear):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var==None:
l_mask=None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_in_hid = DenseLayer(lasagne.layers.InputLayer((None, n_in)), n_hid, W=lasagne.init.GlorotNormal(0.95), nonlinearity=lasagne.nonlinearities.linear)
l_hid_hid = DenseLayer(lasagne.layers.InputLayer((None, n_hid)), n_hid, W=LeInit(diag_val=diag_val, offdiag_val=offdiag_val), nonlinearity=lasagne.nonlinearities.linear)
l_rec = lasagne.layers.CustomRecurrentLayer(l_in, l_in_hid, l_hid_hid, nonlinearity=lasagne.nonlinearities.rectify, mask_input=l_mask, grad_clipping=100)
# Output Layer
l_shp = ReshapeLayer(l_rec, (-1, n_hid))
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.GlorotNormal(0.95), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec
示例5: model
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def model(input_var, batch_size=1):
l_input = InputLayer((batch_size, None, 8), input_var=input_var)
batch_size_var, seqlen, _ = l_input.input_var.shape
# Neural Turing Machine Layer
memory = Memory((128, 20), name='memory')
controller = DenseController(l_input, memory_shape=(128, 20),
num_units=100, num_reads=1, name='controller')
heads = [
WriteHead(controller, num_shifts=3, memory_shape=(128, 20), name='write'),
ReadHead(controller, num_shifts=3, memory_shape=(128, 20), name='read')
]
l_ntm = NTMLayer(l_input, memory=memory, controller=controller, heads=heads)
# Output Layer
l_output_reshape = ReshapeLayer(l_ntm, (-1, 100))
l_output_dense = DenseLayer(l_output_reshape, num_units=8, name='dense')
l_output = ReshapeLayer(l_output_dense, (batch_size_var if batch_size \
is None else batch_size, seqlen, 8))
return l_output
示例6: build_critic
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_critic(input_var=None):
from lasagne.layers import (InputLayer, Conv2DLayer, ReshapeLayer,
DenseLayer)
try:
from lasagne.layers.dnn import batch_norm_dnn as batch_norm
except ImportError:
from lasagne.layers import batch_norm
from lasagne.nonlinearities import LeakyRectify
lrelu = LeakyRectify(0.2)
# input: (None, 1, 28, 28)
layer = InputLayer(shape=(None, 1, 28, 28), input_var=input_var)
# two convolutions
layer = batch_norm(Conv2DLayer(layer, 64, 5, stride=2, pad='same',
nonlinearity=lrelu))
layer = batch_norm(Conv2DLayer(layer, 128, 5, stride=2, pad='same',
nonlinearity=lrelu))
# fully-connected layer
layer = batch_norm(DenseLayer(layer, 1024, nonlinearity=lrelu))
# output layer (linear)
layer = DenseLayer(layer, 1, nonlinearity=None)
print ("critic output:", layer.output_shape)
return layer
示例7: build_critic
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_critic(input_var=None):
from lasagne.layers import (InputLayer, Conv2DLayer, ReshapeLayer,
DenseLayer)
try:
from lasagne.layers.dnn import batch_norm_dnn as batch_norm
except ImportError:
from lasagne.layers import batch_norm
from lasagne.nonlinearities import LeakyRectify
lrelu = LeakyRectify(0.2)
# input: (None, 1, 28, 28)
layer = InputLayer(shape=(None, 1, 28, 28), input_var=input_var)
# two convolutions
layer = batch_norm(Conv2DLayer(layer, 64, 5, stride=2, pad='same',
nonlinearity=lrelu))
layer = batch_norm(Conv2DLayer(layer, 128, 5, stride=2, pad='same',
nonlinearity=lrelu))
# fully-connected layer
layer = batch_norm(DenseLayer(layer, 1024, nonlinearity=lrelu))
# output layer (linear and without bias)
layer = DenseLayer(layer, 1, nonlinearity=None, b=None)
print ("critic output:", layer.output_shape)
return layer
示例8: build_generator_128
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_generator_128(noise=None, ngf=128):
lrelu = LeakyRectify(0.2)
# noise input
InputNoise = InputLayer(shape=(None, 100), input_var=noise)
#FC Layer
gnet0 = DenseLayer(InputNoise, ngf*16*4*4, W=Normal(0.02), nonlinearity=lrelu)
print ("Gen fc1:", gnet0.output_shape)
#Reshape Layer
gnet1 = ReshapeLayer(gnet0,([0],ngf*16,4,4))
print ("Gen rs1:", gnet1.output_shape)
# DeConv Layer
gnet2 = Deconv2DLayer(gnet1, ngf*8, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=lrelu)
print ("Gen deconv1:", gnet2.output_shape)
# DeConv Layer
gnet3 = Deconv2DLayer(gnet2, ngf*8, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=lrelu)
print ("Gen deconv2:", gnet3.output_shape)
# DeConv Layer
gnet4 = Deconv2DLayer(gnet3, ngf*4, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=lrelu)
print ("Gen deconv3:", gnet4.output_shape)
# DeConv Layer
gnet5 = Deconv2DLayer(gnet4, ngf*4, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=lrelu)
print ("Gen deconv4:", gnet5.output_shape)
# DeConv Layer
gnet6 = Deconv2DLayer(gnet5, ngf*2, (4,4), (2,2), crop=1, W=Normal(0.02),nonlinearity=lrelu)
print ("Gen deconv5:", gnet6.output_shape)
# DeConv Layer
gnet7 = Deconv2DLayer(gnet6, 3, (3,3), (1,1), crop='same', W=Normal(0.02),nonlinearity=tanh)
print ("Gen output:", gnet7.output_shape)
return gnet7
示例9: build_convpool_conv1d
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_convpool_conv1d(input_vars, nb_classes, imsize=32, n_colors=3, n_timewin=7):
"""
Builds the complete network with 1D-conv layer to integrate time from sequences of EEG images.
:param input_vars: list of EEG images (one image per time window)
:param nb_classes: number of classes
:param imsize: size of the input image (assumes a square input)
:param n_colors: number of color channels in the image
:param n_timewin: number of time windows in the snippet
:return: a pointer to the output of last layer
"""
convnets = []
w_init = None
# Build 7 parallel CNNs with shared weights
for i in range(n_timewin):
if i == 0:
convnet, w_init = build_cnn(input_vars[i], imsize=imsize, n_colors=n_colors)
else:
convnet, _ = build_cnn(input_vars[i], w_init=w_init, imsize=imsize, n_colors=n_colors)
convnets.append(FlattenLayer(convnet))
# at this point convnets shape is [numTimeWin][n_samples, features]
# we want the shape to be [n_samples, features, numTimeWin]
convpool = ConcatLayer(convnets)
convpool = ReshapeLayer(convpool, ([0], n_timewin, get_output_shape(convnets[0])[1]))
convpool = DimshuffleLayer(convpool, (0, 2, 1))
# input to 1D convlayer should be in (batch_size, num_input_channels, input_length)
convpool = Conv1DLayer(convpool, 64, 3)
# A fully-connected layer of 512 units with 50% dropout on its inputs:
convpool = DenseLayer(lasagne.layers.dropout(convpool, p=.5),
num_units=512, nonlinearity=lasagne.nonlinearities.rectify)
# And, finally, the output layer with 50% dropout on its inputs:
convpool = DenseLayer(lasagne.layers.dropout(convpool, p=.5),
num_units=nb_classes, nonlinearity=lasagne.nonlinearities.softmax)
return convpool
示例10: build_convpool_lstm
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def build_convpool_lstm(input_vars, nb_classes, grad_clip=110, imsize=32, n_colors=3, n_timewin=7):
"""
Builds the complete network with LSTM layer to integrate time from sequences of EEG images.
:param input_vars: list of EEG images (one image per time window)
:param nb_classes: number of classes
:param grad_clip: the gradient messages are clipped to the given value during
the backward pass.
:param imsize: size of the input image (assumes a square input)
:param n_colors: number of color channels in the image
:param n_timewin: number of time windows in the snippet
:return: a pointer to the output of last layer
"""
convnets = []
w_init = None
# Build 7 parallel CNNs with shared weights
for i in range(n_timewin):
if i == 0:
convnet, w_init = build_cnn(input_vars[i], imsize=imsize, n_colors=n_colors)
else:
convnet, _ = build_cnn(input_vars[i], w_init=w_init, imsize=imsize, n_colors=n_colors)
convnets.append(FlattenLayer(convnet))
# at this point convnets shape is [numTimeWin][n_samples, features]
# we want the shape to be [n_samples, features, numTimeWin]
convpool = ConcatLayer(convnets)
convpool = ReshapeLayer(convpool, ([0], n_timewin, get_output_shape(convnets[0])[1]))
# Input to LSTM should have the shape as (batch size, SEQ_LENGTH, num_features)
convpool = LSTMLayer(convpool, num_units=128, grad_clipping=grad_clip,
nonlinearity=lasagne.nonlinearities.tanh)
# We only need the final prediction, we isolate that quantity and feed it
# to the next layer.
convpool = SliceLayer(convpool, -1, 1) # Selecting the last prediction
# A fully-connected layer of 256 units with 50% dropout on its inputs:
convpool = DenseLayer(lasagne.layers.dropout(convpool, p=.5),
num_units=256, nonlinearity=lasagne.nonlinearities.rectify)
# And, finally, the output layer with 50% dropout on its inputs:
convpool = DenseLayer(lasagne.layers.dropout(convpool, p=.5),
num_units=nb_classes, nonlinearity=lasagne.nonlinearities.softmax)
return convpool
示例11: TanhRecurrent
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def TanhRecurrent(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1,
n_hid=200, wscale=1.0,
out_nlin=lasagne.nonlinearities.linear):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var == None:
l_mask = None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_in_hid = DenseLayer(lasagne.layers.InputLayer((None, n_in)), n_hid,
W=lasagne.init.HeNormal(0.95), nonlinearity=lasagne.nonlinearities.linear)
l_hid_hid = DenseLayer(lasagne.layers.InputLayer((None, n_hid)), n_hid,
W=lasagne.init.HeNormal(gain=wscale), nonlinearity=lasagne.nonlinearities.linear)
l_rec = lasagne.layers.CustomRecurrentLayer(l_in, l_in_hid, l_hid_hid, nonlinearity=lasagne.nonlinearities.tanh,
mask_input=l_mask, grad_clipping=100)
l_shp_1 = ReshapeLayer(l_rec, (-1, n_hid))
l_shp_2 = ReshapeLayer(l_hid_hid, (-1, n_hid))
l_shp = lasagne.layers.ElemwiseSumLayer((l_shp_1,l_shp_2),coeffs=(np.float32(0.2),np.float32(0.8)))
# Output Layer
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.HeNormal(0.95), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec
示例12: LeInitRecurrentWithFastWeights
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def LeInitRecurrentWithFastWeights(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1,
n_hid=200, diag_val=0.9, offdiag_val=0.01,
out_nlin=lasagne.nonlinearities.linear, gamma=0.9):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var==None:
l_mask=None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_in_hid = DenseLayer(lasagne.layers.InputLayer((None, n_in)), n_hid,
W=lasagne.init.GlorotNormal(0.95),
nonlinearity=lasagne.nonlinearities.linear)
l_hid_hid = DenseLayer(lasagne.layers.InputLayer((None, n_hid)), n_hid,
W=LeInit(diag_val=diag_val, offdiag_val=offdiag_val),
nonlinearity=lasagne.nonlinearities.linear)
l_rec = CustomRecurrentLayerWithFastWeights(l_in, l_in_hid, l_hid_hid,
nonlinearity=lasagne.nonlinearities.rectify,
mask_input=l_mask, grad_clipping=100, gamma=gamma)
# Output Layer
l_shp = ReshapeLayer(l_rec, (-1, n_hid))
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.GlorotNormal(0.95), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec
示例13: GRURecurrent
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def GRURecurrent(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1, n_hid=200, diag_val=0.9, offdiag_val=0.01, out_nlin=lasagne.nonlinearities.linear):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var==None:
l_mask = None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_rec = GRULayer(l_in, n_hid,
resetgate=lasagne.layers.Gate(W_in=lasagne.init.GlorotNormal(0.05),
W_hid=lasagne.init.GlorotNormal(0.05),
W_cell=None, b=lasagne.init.Constant(0.)),
updategate=lasagne.layers.Gate(W_in=lasagne.init.GlorotNormal(0.05),
W_hid=lasagne.init.GlorotNormal(0.05),
W_cell=None),
hidden_update=lasagne.layers.Gate(W_in=lasagne.init.GlorotNormal(0.05),
W_hid=LeInit(diag_val=diag_val, offdiag_val=offdiag_val),
W_cell=None, nonlinearity=lasagne.nonlinearities.rectify),
hid_init = lasagne.init.Constant(0.), backwards=False, learn_init=False,
gradient_steps=-1, grad_clipping=10., unroll_scan=False, precompute_input=True, mask_input=l_mask, only_return_final=False)
# Output Layer
l_shp = ReshapeLayer(l_rec, (-1, n_hid))
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.GlorotNormal(0.05), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec
示例14: LeInitRecurrent
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def LeInitRecurrent(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1,
n_hid=200, diag_val=0.9, offdiag_val=0.01,
out_nlin=lasagne.nonlinearities.linear):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var==None:
l_mask=None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_in_hid = DenseLayer(lasagne.layers.InputLayer((None, n_in)), n_hid,
W=lasagne.init.GlorotNormal(0.95),
nonlinearity=lasagne.nonlinearities.linear)
l_hid_hid = DenseLayer(lasagne.layers.InputLayer((None, n_hid)), n_hid,
W=LeInit(diag_val=diag_val, offdiag_val=offdiag_val),
nonlinearity=lasagne.nonlinearities.linear)
l_rec = lasagne.layers.CustomRecurrentLayer(l_in, l_in_hid, l_hid_hid, nonlinearity=lasagne.nonlinearities.rectify, mask_input=l_mask, grad_clipping=100)
# Output Layer
l_shp = ReshapeLayer(l_rec, (-1, n_hid))
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.GlorotNormal(0.95), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec
示例15: LeInitRecurrentWithFastWeights
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import ReshapeLayer [as 别名]
def LeInitRecurrentWithFastWeights(input_var, mask_var=None, batch_size=1, n_in=100, n_out=1,
n_hid=200, diag_val=0.9, offdiag_val=0.01,
out_nlin=lasagne.nonlinearities.linear, gamma=0.9):
# Input Layer
l_in = InputLayer((batch_size, None, n_in), input_var=input_var)
if mask_var==None:
l_mask=None
else:
l_mask = InputLayer((batch_size, None), input_var=mask_var)
_, seqlen, _ = l_in.input_var.shape
l_in_hid = DenseLayer(lasagne.layers.InputLayer((None, n_in)), n_hid,
W=lasagne.init.GlorotNormal(0.95),
nonlinearity=lasagne.nonlinearities.linear)
l_hid_hid = DenseLayer(lasagne.layers.InputLayer((None, n_hid)), n_hid,
W=LeInit(diag_val=diag_val, offdiag_val=offdiag_val),
nonlinearity=lasagne.nonlinearities.linear)
l_rec = CustomRecurrentLayerWithFastWeights(l_in, l_in_hid, l_hid_hid,
nonlinearity=lasagne.nonlinearities.rectify,
mask_input=l_mask, grad_clipping=100, gamma=gamma)
# Output Layer
l_shp = ReshapeLayer(l_rec, (-1, n_hid))
l_dense = DenseLayer(l_shp, num_units=n_out, W=lasagne.init.GlorotNormal(0.95), nonlinearity=out_nlin)
# To reshape back to our original shape, we can use the symbolic shape variables we retrieved above.
l_out = ReshapeLayer(l_dense, (batch_size, seqlen, n_out))
return l_out, l_rec