本文整理汇总了Python中lasagne.layers.concat方法的典型用法代码示例。如果您正苦于以下问题:Python layers.concat方法的具体用法?Python layers.concat怎么用?Python layers.concat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lasagne.layers
的用法示例。
在下文中一共展示了layers.concat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import concat [as 别名]
def __init__(self, incoming, channel_layer_class, name=None, **channel_layer_kwargs):
super(ChannelwiseLayer, self).__init__(incoming, name=name)
self.channel_layer_class = channel_layer_class
self.channel_incomings = []
self.channel_outcomings = []
for channel in range(lasagne.layers.get_output_shape(incoming)[0]):
channel_incoming = L.SliceLayer(incoming, indices=slice(channel, channel+1), axis=1,
name='%s.%s%d' % (name, 'slice', channel) if name is not None else None)
channel_outcoming = channel_layer_class(channel_incoming,
name='%s.%s%d' % (name, 'op', channel) if name is not None else None,
**channel_layer_kwargs)
self.channel_incomings.append(channel_incoming)
self.channel_outcomings.append(channel_outcoming)
self.outcoming = L.ConcatLayer(self.channel_outcomings, axis=1,
name='%s.%s' % (name, 'concat') if name is not None else None)
示例2: __create_toplogy__
# 需要导入模块: from lasagne import layers [as 别名]
# 或者: from lasagne.layers import concat [as 别名]
def __create_toplogy__(self, input_var_first=None, input_var_second=None):
# define network topology
if (self.conf.rep % 2 != 0):
raise ValueError("Representation size should be divisible by two as it's formed by combining two crossmodal translations", self.conf.rep)
# input layers
l_in_first = InputLayer(shape=(self.conf.batch_size, self.conf.mod1size), input_var=input_var_first)
l_in_second = InputLayer(shape=(self.conf.batch_size, self.conf.mod2size), input_var=input_var_second)
# first -> second
l_hidden1_first = DenseLayer(l_in_first, num_units=self.conf.hdn, nonlinearity=self.conf.act, W=GlorotUniform()) # enc1
l_hidden2_first = DenseLayer(l_hidden1_first, num_units=self.conf.rep//2, nonlinearity=self.conf.act, W=GlorotUniform()) # enc2
l_hidden2_first_d = DropoutLayer(l_hidden2_first, p=self.conf.dropout)
l_hidden3_first = DenseLayer(l_hidden2_first_d, num_units=self.conf.hdn, nonlinearity=self.conf.act, W=GlorotUniform()) # dec1
l_out_first = DenseLayer(l_hidden3_first, num_units=self.conf.mod2size, nonlinearity=self.conf.act, W=GlorotUniform()) # dec2
if self.conf.untied:
# FREE
l_hidden1_second = DenseLayer(l_in_second, num_units=self.conf.hdn, nonlinearity=self.conf.act, W=GlorotUniform()) # enc1
l_hidden2_second = DenseLayer(l_hidden1_second, num_units=self.conf.rep//2, nonlinearity=self.conf.act, W=GlorotUniform()) # enc2
l_hidden2_second_d = DropoutLayer(l_hidden2_second, p=self.conf.dropout)
l_hidden3_second = DenseLayer(l_hidden2_second_d, num_units=self.conf.hdn, nonlinearity=self.conf.act, W=GlorotUniform()) # dec1
l_out_second = DenseLayer(l_hidden3_second, num_units=self.conf.mod1size, nonlinearity=self.conf.act, W=GlorotUniform()) # dec2
else:
# TIED middle
l_hidden1_second = DenseLayer(l_in_second, num_units=self.conf.hdn, nonlinearity=self.conf.act, W=GlorotUniform()) # enc1
l_hidden2_second = DenseLayer(l_hidden1_second, num_units=self.conf.rep//2, nonlinearity=self.conf.act, W=l_hidden3_first.W.T) # enc2
l_hidden2_second_d = DropoutLayer(l_hidden2_second, p=self.conf.dropout)
l_hidden3_second = DenseLayer(l_hidden2_second_d, num_units=self.conf.hdn, nonlinearity=self.conf.act, W=l_hidden2_first.W.T) # dec1
l_out_second = DenseLayer(l_hidden3_second, num_units=self.conf.mod1size, nonlinearity=self.conf.act, W=GlorotUniform()) # dec2
l_out = concat([l_out_first, l_out_second])
return l_out, l_hidden2_first, l_hidden2_second