本文整理汇总了Python中keras.layers.activations.get方法的典型用法代码示例。如果您正苦于以下问题:Python activations.get方法的具体用法?Python activations.get怎么用?Python activations.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类keras.layers.activations
的用法示例。
在下文中一共展示了activations.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self,output_dim,mem_vec_dim,init='glorot_uniform', activation='linear', weights=None,
activity_regularizer=None,input_dim=None, **kwargs):
'''
Params:
output_dim: ?????
mem_vec_dim: query?????
'''
self.init = initializations.get(init)
self.activation = activations.get(activation)
self.output_dim = output_dim
self.input_dim = input_dim
self.mem_vector_dim=mem_vec_dim
self.activity_regularizer = regularizers.get(activity_regularizer)
self.initial_weights = weights
if self.input_dim:
kwargs['input_shape'] = (self.input_dim,)
super(MemoryNet,self).__init__(**kwargs)
示例2: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, output_dim,
init='glorot_uniform', inner_init='orthogonal',
activation='tanh', inner_activation='hard_sigmoid',
W_regularizer=None, U_regularizer=None, b_regularizer=None,
dropout_W=0., dropout_U=0., **kwargs):
self.output_dim = output_dim
self.init = initializations.get(init)
self.inner_init = initializations.get(inner_init)
self.activation = activations.get(activation)
self.inner_activation = activations.get(inner_activation)
self.W_regularizer = regularizers.get(W_regularizer)
self.U_regularizer = regularizers.get(U_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.dropout_W = dropout_W
self.dropout_U = dropout_U
if self.dropout_W or self.dropout_U:
self.uses_learning_phase = True
super(MGU, self).__init__(**kwargs)
示例3: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, output_dim, attention_vec, attn_activation='tanh', single_attention_param=False, **kwargs):
self.attention_vec = attention_vec
self.attn_activation = activations.get(attn_activation)
self.single_attention_param = single_attention_param
super(AttentionLSTM, self).__init__(output_dim, **kwargs)
示例4: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, nb_filter, filter_length,
init='glorot_uniform', activation=None, weights=None,
border_mode='valid', subsample_length=1,
W_regularizer=None, b_regularizer=None, activity_regularizer=None,
W_constraint=None, b_constraint=None,
bias=True, input_dim=None, input_length=None, **kwargs):
if border_mode != 'valid':
raise Exception('Invalid border mode for LocallyConnected1D '
'(only "valid" is supported):', border_mode)
self.nb_filter = nb_filter
self.filter_length = filter_length
self.init = initializations.get(init, dim_ordering='th')
self.activation = activations.get(activation)
self.border_mode = border_mode
self.subsample_length = subsample_length
self.W_regularizer = regularizers.get(W_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.activity_regularizer = regularizers.get(activity_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
self.input_spec = [InputSpec(ndim=3)]
self.initial_weights = weights
self.input_dim = input_dim
self.input_length = input_length
if self.input_dim:
kwargs['input_shape'] = (self.input_length, self.input_dim)
super(LocallyConnected1D, self).__init__(**kwargs)
示例5: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, layer, attention_vec, attn_activation='tanh', single_attention_param=False, **kwargs):
assert isinstance(layer, LSTM) or isinstance(layer, GRU)
super(AttentionWrapper, self).__init__(layer, **kwargs)
self.supports_masking = True
self.attention_vec = attention_vec
self.attn_activation = activations.get(attn_activation)
self.single_attention_param = single_attention_param
示例6: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, nb_filter, filter_length,
init='glorot_uniform', activation=None, weights=None,
border_mode='valid', subsample_length=1,
W_regularizer=None, b_regularizer=None, activity_regularizer=None,
W_constraint=None, b_constraint=None,
bias=True, input_dim=None, input_length=None, **kwargs):
if border_mode != 'valid':
raise ValueError('Invalid border mode for LocallyConnected1D '
'(only "valid" is supported):', border_mode)
self.nb_filter = nb_filter
self.filter_length = filter_length
self.init = initializations.get(init, dim_ordering='th')
self.activation = activations.get(activation)
self.border_mode = border_mode
self.subsample_length = subsample_length
self.W_regularizer = regularizers.get(W_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.activity_regularizer = regularizers.get(activity_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
self.input_spec = [InputSpec(ndim=3)]
self.initial_weights = weights
self.input_dim = input_dim
self.input_length = input_length
if self.input_dim:
kwargs['input_shape'] = (self.input_length, self.input_dim)
super(LocallyConnected1D, self).__init__(**kwargs)
示例7: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self,output_dim,attention_vec,attn_activation='tanh',
attn_inner_activation='tanh', single_attn=False,
n_attention_dim=None,**kwargs):
'''
attention_vec: ???????attention????????????????attention??
??attention_vec=None,????attention
'''
self.attention_vec=attention_vec
self.attn_activation = activations.get(attn_activation)
self.attn_inner_activation = activations.get(attn_inner_activation)
self.single_attention_param = single_attn
self.n_attention_dim = output_dim if n_attention_dim is None else n_attention_dim
super(AttentionLSTM,self).__init__(output_dim,**kwargs)
示例8: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self,output_dim,att_dim,attn_activation='tanh',
attn_inner_activation='tanh',
single_attn=False,**kwargs):
'''
attention_vec: ???????attention????????????????attention??
single_attention_param: ????t,??????????????attention?
'''
self.attn_activation=activations.get(attn_activation)
self.attn_inner_activation=activations.get(attn_inner_activation)
self.single_attention_param=single_attn
self.input_spec=None
self.att_dim=att_dim
super(AttentionLSTM,self).__init__(output_dim,**kwargs)
示例9: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, output_dim,
init='glorot_uniform', inner_init='orthogonal',
activation='tanh', inner_activation='hard_sigmoid', **kwargs):
self.output_dim = output_dim
self.init = initializations.get(init)
self.inner_init = initializations.get(inner_init)
self.activation = activations.get(activation)
self.inner_activation = activations.get(inner_activation)
super(DecoderGRU, self).__init__(**kwargs)
示例10: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, output_dim, attention_vec, attn_activation='tanh',
attn_inner_activation='tanh', single_attn=False,
n_attention_dim=None, **kwargs):
self.attention_vec = attention_vec
self.attn_activation = activations.get(attn_activation)
self.attn_inner_activation = activations.get(attn_inner_activation)
self.single_attention_param = single_attn
self.n_attention_dim = output_dim if n_attention_dim is None else n_attention_dim
super(AttentionLSTM, self).__init__(output_dim, **kwargs)
示例11: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, nb_filter, shared_pool, nb_row=1, nb_col=1,
init='glorot_uniform', activation='linear', weights=None,
border_mode='valid', subsample=(1, 1),
dim_ordering=K.image_dim_ordering(),
W_regularizer=None, b_regularizer=None, activity_regularizer=None,
W_constraint=None, b_constraint=None,
bias=True, **kwargs):
if border_mode != 'valid':
raise Exception('Invalid border mode for Convolution2D '
'(only "valid" is supported):', border_mode)
if tuple(subsample) != (nb_row,nb_col): #model.to_json saves subsample as list and not as tuple
raise Exception('Local layer only works with equal filter dimensions and strides')
self.nb_filter = nb_filter
self.shared_pool = shared_pool
self.nb_row = nb_row
self.nb_col = nb_col
self.init = initializations.get(init, dim_ordering=dim_ordering)
self.activation = activations.get(activation)
self.border_mode = border_mode
self.subsample = tuple(subsample)
assert dim_ordering in {'tf', 'th'}, 'dim_ordering must be in {tf, th}'
self.dim_ordering = dim_ordering
self.W_regularizer = regularizers.get(W_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.activity_regularizer = regularizers.get(activity_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
self.input_spec = [InputSpec(ndim=4)]
self.initial_weights = weights
super(SemiShared, self).__init__(**kwargs)
示例12: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, nb_filter, filter_length,
init='uniform', activation='linear', weights=None,
border_mode='valid', subsample_length=1,
W_regularizer=None, b_regularizer=None, activity_regularizer=None,
W_constraint=None, b_constraint=None,
bias=True, input_dim=None, input_length=None, **kwargs):
if border_mode != 'valid':
raise Exception('Invalid border mode for LocallyConnected1D '
'(only "valid" is supported):', border_mode)
self.nb_filter = nb_filter
self.filter_length = filter_length
self.init = initializations.get(init, dim_ordering='th')
self.activation = activations.get(activation)
self.border_mode = border_mode
self.subsample_length = subsample_length
self.W_regularizer = regularizers.get(W_regularizer)
self.b_regularizer = regularizers.get(b_regularizer)
self.activity_regularizer = regularizers.get(activity_regularizer)
self.W_constraint = constraints.get(W_constraint)
self.b_constraint = constraints.get(b_constraint)
self.bias = bias
self.input_spec = [InputSpec(ndim=3)]
self.initial_weights = weights
self.input_dim = input_dim
self.input_length = input_length
if self.input_dim:
kwargs['input_shape'] = (self.input_length, self.input_dim)
super(LocallyConnected1D, self).__init__(**kwargs)
示例13: __init__
# 需要导入模块: from keras.layers import activations [as 别名]
# 或者: from keras.layers.activations import get [as 别名]
def __init__(self, output_dim, init='glorot_uniform', attn_activation='tanh', **kwargs):
self.output_dim = output_dim
self.init = initializations.get(init)
self.attn_activation = activations.get(attn_activation)
super(AttentionLayer, self).__init__(**kwargs)