當前位置: 首頁>>代碼示例>>Python>>正文


Python initializers.get方法代碼示例

本文整理匯總了Python中keras.initializers.get方法的典型用法代碼示例。如果您正苦於以下問題:Python initializers.get方法的具體用法?Python initializers.get怎麽用?Python initializers.get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在keras.initializers的用法示例。


在下文中一共展示了initializers.get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 filters,
                 pooling='sum',
                 kernel_initializer='glorot_uniform',
                 kernel_regularizer=None,
                 bias_initializer='zeros',
                 activation=None,
                 **kwargs):
        self.activation = activations.get(activation)
        self.kernel_initializer = initializers.get(kernel_initializer)
        self.bias_initializer = initializers.get(bias_initializer)
        self.kernel_regularizer = regularizers.get(kernel_regularizer)
        self.filters = filters
        self.pooling = pooling

        super(GraphConvS, self).__init__(**kwargs) 
開發者ID:blackmints,項目名稱:3DGCN,代碼行數:18,代碼來源:layer.py

示例2: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 W_regularizer=None, u_regularizer=None, b_regularizer=None,
                 W_constraint=None, u_constraint=None, b_constraint=None,
                 bias=True, **kwargs):


        self.init = initializers.get('glorot_uniform')

        self.W_regularizer = regularizers.get(W_regularizer)
        self.u_regularizer = regularizers.get(u_regularizer)
        self.b_regularizer = regularizers.get(b_regularizer)

        self.W_constraint = constraints.get(W_constraint)
        self.u_constraint = constraints.get(u_constraint)
        self.b_constraint = constraints.get(b_constraint)

        self.bias = bias
        super(AttentionWithContext, self).__init__(**kwargs) 
開發者ID:AlexGidiotis,項目名稱:Document-Classifier-LSTM,代碼行數:20,代碼來源:attention.py

示例3: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 W_regularizer=None, u_regularizer=None, b_regularizer=None,
                 W_constraint=None, u_constraint=None, b_constraint=None,
                 bias=True, **kwargs):

        self.supports_masking = True
        self.init = initializers.get('glorot_uniform')

        self.W_regularizer = regularizers.get(W_regularizer)
        self.u_regularizer = regularizers.get(u_regularizer)
        self.b_regularizer = regularizers.get(b_regularizer)

        self.W_constraint = constraints.get(W_constraint)
        self.u_constraint = constraints.get(u_constraint)
        self.b_constraint = constraints.get(b_constraint)

        self.bias = bias
        super(AttentionWithContext, self).__init__(**kwargs) 
開發者ID:Hsankesara,項目名稱:DeepResearch,代碼行數:20,代碼來源:attention_with_context.py

示例4: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self, init='glorot_uniform',
                 U_regularizer=None,
                 b_start_regularizer=None,
                 b_end_regularizer=None,
                 U_constraint=None,
                 b_start_constraint=None,
                 b_end_constraint=None,
                 weights=None,
                 **kwargs):
        super(ChainCRF, self).__init__(**kwargs)
        self.init = initializers.get(init)
        self.U_regularizer = regularizers.get(U_regularizer)
        self.b_start_regularizer = regularizers.get(b_start_regularizer)
        self.b_end_regularizer = regularizers.get(b_end_regularizer)
        self.U_constraint = constraints.get(U_constraint)
        self.b_start_constraint = constraints.get(b_start_constraint)
        self.b_end_constraint = constraints.get(b_end_constraint)

        self.initial_weights = weights

        self.supports_masking = True
        self.uses_learning_phase = True
        self.input_spec = [InputSpec(ndim=3)] 
開發者ID:UKPLab,項目名稱:elmo-bilstm-cnn-crf,代碼行數:25,代碼來源:ChainCRF.py

示例5: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 epsilon=1e-4,
                 axis=-1,
                 beta_init='zeros',
                 gamma_init='ones',
                 gamma_regularizer=None,
                 beta_regularizer=None,
                 **kwargs):

        self.supports_masking = True
        self.beta_init = initializers.get(beta_init)
        self.gamma_init = initializers.get(gamma_init)
        self.epsilon = epsilon
        self.axis = axis
        self.gamma_regularizer = regularizers.get(gamma_regularizer)
        self.beta_regularizer = regularizers.get(beta_regularizer)

        super(LayerNormalization, self).__init__(**kwargs) 
開發者ID:ChihebTrabelsi,項目名稱:deep_complex_networks,代碼行數:20,代碼來源:norm.py

示例6: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 axis=None,
                 epsilon=1e-3,
                 center=True,
                 scale=True,
                 beta_initializer='zeros',
                 gamma_initializer='ones',
                 beta_regularizer=None,
                 gamma_regularizer=None,
                 beta_constraint=None,
                 gamma_constraint=None,
                 **kwargs):
        super(InstanceNormalization, self).__init__(**kwargs)
        self.supports_masking = True
        self.axis = axis
        self.epsilon = epsilon
        self.center = center
        self.scale = scale
        self.beta_initializer = initializers.get(beta_initializer)
        self.gamma_initializer = initializers.get(gamma_initializer)
        self.beta_regularizer = regularizers.get(beta_regularizer)
        self.gamma_regularizer = regularizers.get(gamma_regularizer)
        self.beta_constraint = constraints.get(beta_constraint)
        self.gamma_constraint = constraints.get(gamma_constraint) 
開發者ID:emilwallner,項目名稱:Coloring-greyscale-images,代碼行數:26,代碼來源:instance_normalization.py

示例7: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 W_regularizer=None, b_regularizer=None,
                 W_constraint=None, b_constraint=None,
                 bias=True,
                 return_attention=False,
                 **kwargs):

        self.supports_masking = True
        self.return_attention = return_attention
        self.init = initializers.get('glorot_uniform')

        self.W_regularizer = regularizers.get(W_regularizer)
        self.b_regularizer = regularizers.get(b_regularizer)

        self.W_constraint = constraints.get(W_constraint)
        self.b_constraint = constraints.get(b_constraint)

        self.bias = bias
        super(Attention, self).__init__(**kwargs) 
開發者ID:jiujiezz,項目名稱:deephlapan,代碼行數:21,代碼來源:attention.py

示例8: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self,
                 W_regularizer=None, u_regularizer=None, b_regularizer=None,
                 W_constraint=None, u_constraint=None, b_constraint=None,
                 bias=True,
                 return_attention=False, **kwargs):

        self.supports_masking = True
        self.return_attention = return_attention
        self.init = initializers.get('glorot_uniform')

        self.W_regularizer = regularizers.get(W_regularizer)
        self.u_regularizer = regularizers.get(u_regularizer)
        self.b_regularizer = regularizers.get(b_regularizer)

        self.W_constraint = constraints.get(W_constraint)
        self.u_constraint = constraints.get(u_constraint)
        self.b_constraint = constraints.get(b_constraint)

        self.bias = bias
        super(AttentionWithContext, self).__init__(**kwargs) 
開發者ID:cbaziotis,項目名稱:keras-utilities,代碼行數:22,代碼來源:layers.py

示例9: on_epoch_end

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def on_epoch_end(self, epoch, logs=None):
        logs = logs or {}
        self.epochs_since_last_save += 1
        if self.epochs_since_last_save >= self.period:
            self.epochs_since_last_save = 0
            #filepath = self.filepath.format(epoch=epoch + 1, **logs)
            current = logs.get(self.monitor)
            if current is None:
                warnings.warn('Can pick best model only with %s available, '
                              'skipping.' % (self.monitor), RuntimeWarning)
            else:
                if self.monitor_op(current, self.best):
                    if self.verbose > 0:
                        print('\nEpoch %05d: %s improved from %0.5f to %0.5f,'
                              ' storing weights.'
                              % (epoch + 1, self.monitor, self.best,
                                 current))
                    self.best = current
                    self.best_epochs = epoch + 1
                    self.best_weights = self.model.get_weights()
                else:
                    if self.verbose > 0:
                        print('\nEpoch %05d: %s did not improve' %
                              (epoch + 1, self.monitor)) 
開發者ID:WeavingWong,項目名稱:DigiX_HuaWei_Population_Age_Attribution_Predict,代碼行數:26,代碼來源:models.py

示例10: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(
        self,
        heads,
        head_size,
        key_size=None,
        use_bias=True,
        attention_scale=True,
        kernel_initializer='glorot_uniform',
        **kwargs
    ):
        super(MultiHeadAttention, self).__init__(**kwargs)
        self.heads = heads
        self.head_size = head_size
        self.out_dim = heads * head_size
        self.key_size = key_size or head_size
        self.use_bias = use_bias
        self.attention_scale = attention_scale
        self.kernel_initializer = initializers.get(kernel_initializer) 
開發者ID:bojone,項目名稱:bert4keras,代碼行數:20,代碼來源:layers.py

示例11: evaluate

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def evaluate(self, inputs, fn_inverse=None, fn_plot=None):
        try:
            X, y = inputs
            inputs = X
        except:
            X, conditions, y = inputs
            inputs = [X, conditions]

        y_hat = self.predict(inputs)

        if fn_inverse is not None:
            y_hat = fn_inverse(y_hat)
            y = fn_inverse(y)

        if fn_plot is not None:
            fn_plot([y, y_hat])

        results = []
        for m in self.model.metrics:
            if isinstance(m, str):
                results.append(K.eval(K.mean(get(m)(y, y_hat))))
            else:
                results.append(K.eval(K.mean(m(y, y_hat))))
        return results 
開發者ID:albertogaspar,項目名稱:dts,代碼行數:26,代碼來源:FFNN.py

示例12: emit_Affine

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def emit_Affine(self, IR_node, in_scope=False):
        if in_scope:
            raise NotImplementedError
        else:
            self.used_layers.add('Affine')
            if IR_node.layer.attr.get('beta', None) is None:
                bias = None
            else:
                bias = IR_node.layer.attr['beta'].f
            code = "{:<15} = Affine(name='{}', scale={}, bias={})({})".format(
                IR_node.variable_name,
                IR_node.name,
                IR_node.layer.attr['gamma'].f,
                bias,
                self.parent_variable_name(IR_node))
            return code 
開發者ID:microsoft,項目名稱:MMdnn,代碼行數:18,代碼來源:keras2_emitter.py

示例13: _emit_h_zero

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def _emit_h_zero(self, IR_node):
        if not self.layers_codes.get(IR_node.pattern, None):
            class_code = '''
class my_h_zero(keras.layers.Layer):
    def __init__(self, **kwargs):
        super(my_h_zero, self).__init__(**kwargs)
    
    def call(self, dummy):
        {:<15} = K.constant(np.full((1, {}), {}))

        return {}
            '''.format(IR_node.variable_name,
            IR_node.get_attr('fill_size'),
            IR_node.get_attr('fill_value'),
            IR_node.variable_name)
            self.layers_codes[IR_node.pattern] = class_code

        code = "{:<15} = my_h_zero()({})".format(IR_node.variable_name, self.parent_variable_name(IR_node))

        return code 
開發者ID:microsoft,項目名稱:MMdnn,代碼行數:22,代碼來源:keras2_emitter.py

示例14: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self, filters,
                 kernel_size,
                 strides=(1, 1),
                 padding='valid',
                 data_format=None,
                 depth_multiplier=1,
                 activation=None,
                 use_bias=True,
                 depthwise_initializer='glorot_uniform',
                 bias_initializer='zeros',
                 depthwise_regularizer=None,
                 bias_regularizer=None,
                 activity_regularizer=None,
                 depthwise_constraint=None,
                 bias_constraint=None,
                 **kwargs):
        super(DepthwiseConv2D, self).__init__(
            filters=filters,
            kernel_size=kernel_size,
            strides=strides,
            padding=padding,
            data_format=data_format,
            activation=activation,
            use_bias=use_bias,
            bias_regularizer=bias_regularizer,
            activity_regularizer=activity_regularizer,
            bias_constraint=bias_constraint,
            **kwargs)

        self.depth_multiplier = depth_multiplier
        self.depthwise_initializer = initializers.get(depthwise_initializer)
        self.depthwise_regularizer = regularizers.get(depthwise_regularizer)
        self.depthwise_constraint = constraints.get(depthwise_constraint) 
開發者ID:rcmalli,項目名稱:keras-mobilenet,代碼行數:35,代碼來源:depthwise_conv2d.py

示例15: __init__

# 需要導入模塊: from keras import initializers [as 別名]
# 或者: from keras.initializers import get [as 別名]
def __init__(self, return_attention=False, **kwargs):
        self.init = initializers.get('uniform')
        self.supports_masking = True
        self.return_attention = return_attention
        super(AttentionWeightedAverage, self).__init__(**kwargs) 
開發者ID:minerva-ml,項目名稱:steppy-toolkit,代碼行數:7,代碼來源:contrib.py


注:本文中的keras.initializers.get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。