当前位置: 首页>>代码示例>>Python>>正文


Python backend.all方法代码示例

本文整理汇总了Python中keras.backend.all方法的典型用法代码示例。如果您正苦于以下问题:Python backend.all方法的具体用法?Python backend.all怎么用?Python backend.all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keras.backend的用法示例。


在下文中一共展示了backend.all方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _denormalize_tensorflow

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def _denormalize_tensorflow(D, hparams):
	if hparams.allow_clipping_in_normalization:
		if hparams.symmetric_mels:
			return (((tf.clip_by_value(D, -hparams.max_abs_value,
				hparams.max_abs_value) + hparams.max_abs_value) * -hparams.min_level_db / (2 * hparams.max_abs_value))
				+ hparams.min_level_db)
		else:
			return ((tf.clip_by_value(D, 0, hparams.max_abs_value) * -hparams.min_level_db / hparams.max_abs_value) + hparams.min_level_db)

	if hparams.symmetric_mels:
		return (((D + hparams.max_abs_value) * -hparams.min_level_db / (2 * hparams.max_abs_value)) + hparams.min_level_db)
	else:
		return ((D * -hparams.min_level_db / hparams.max_abs_value) + hparams.min_level_db)




# given a path, return list of all files in directory 
开发者ID:dessa-oss,项目名称:fake-voice-detection,代码行数:20,代码来源:utils.py

示例2: customPooling

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def customPooling(x):
    target = x[1]
    inputs = x[0]
    maskVal = 0
    #getting the mask by observing the model's inputs
    mask = K.equal(inputs, maskVal)
    mask = K.all(mask, axis=-1, keepdims=True)

    #inverting the mask for getting the valid steps for each sample
    mask = 1 - K.cast(mask, K.floatx())

    #summing the valid steps for each sample
    stepsPerSample = K.sum(mask, axis=1, keepdims=False)

    #applying the mask to the target (to make sure you are summing zeros below)
    target = target * mask

    #calculating the mean of the steps (using our sum of valid steps as averager)
    means = K.sum(target, axis=1, keepdims=False) / stepsPerSample

    return means 
开发者ID:dessa-oss,项目名称:fake-voice-detection,代码行数:23,代码来源:utils.py

示例3: contingency_table

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def contingency_table(y, z):
    """Compute contingency table."""
    y = K.round(y)
    z = K.round(z)

    def count_matches(a, b):
        tmp = K.concatenate([a, b])
        return K.sum(K.cast(K.all(tmp, -1), K.floatx()))

    ones = K.ones_like(y)
    zeros = K.zeros_like(y)
    y_ones = K.equal(y, ones)
    y_zeros = K.equal(y, zeros)
    z_ones = K.equal(z, ones)
    z_zeros = K.equal(z, zeros)

    tp = count_matches(y_ones, z_ones)
    tn = count_matches(y_zeros, z_zeros)
    fp = count_matches(y_zeros, z_ones)
    fn = count_matches(y_ones, z_zeros)

    return (tp, tn, fp, fn) 
开发者ID:cangermueller,项目名称:deepcpg,代码行数:24,代码来源:metrics.py

示例4: all_acc

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def all_acc(y_true, y_pred):
    """
        All Accuracy
        https://github.com/rasmusbergpalm/normalization/blob/master/train.py#L10
    """
    return K.mean(
        K.all(
            K.equal(
                K.max(y_true, axis=-1),
                K.cast(K.argmax(y_pred, axis=-1), K.floatx())
            ),
            axis=1)
    ) 
开发者ID:datalogue,项目名称:keras-attention,代码行数:15,代码来源:metrics.py

示例5: squash_mask

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def squash_mask(self, mask):
        if K.ndim(mask) == 2:
            return mask
        elif K.ndim(mask) == 3:
            return K.all(mask, axis=-1)
        return mask 
开发者ID:braingineer,项目名称:ikelos,代码行数:8,代码来源:attention.py

示例6: compute_mask

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def compute_mask(self, x, mask=None):
        if self.return_probabilities:
            mask2 = mask
            if mask is not None:
                mask2 = K.expand_dims(K.all(mask2, axis=-1))
            return [mask, mask2]
        return mask 
开发者ID:braingineer,项目名称:ikelos,代码行数:9,代码来源:attention.py

示例7: zero_one_accuracy

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def zero_one_accuracy(y_true, y_pred):
    y_true, y_pred = tensorify(y_true), tensorify(y_pred)
    n_instances, n_objects = get_instances_objects(y_true)
    equal_ranks = K.cast(K.all(K.equal(y_pred, y_true), axis=1), dtype="float32")
    denominator = K.cast(n_instances, dtype="float32")
    zero_one_loss = K.sum(equal_ranks) / denominator
    return zero_one_loss 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:9,代码来源:metrics.py

示例8: zero_one_accuracy_for_scores

# 需要导入模块: from keras import backend [as 别名]
# 或者: from keras.backend import all [as 别名]
def zero_one_accuracy_for_scores(y_true, y_pred):
    y_true, y_pred = tensorify(y_true), tensorify(y_pred)
    n_instances, n_objects = get_instances_objects(y_true)
    predicted_rankings = scores_to_rankings(n_objects, y_pred)
    y_true = K.cast(y_true, dtype="float32")
    equal_ranks = K.cast(
        K.all(K.equal(predicted_rankings, y_true), axis=1), dtype="float32"
    )
    denominator = K.cast(n_instances, dtype="float32")
    zero_one_loss = K.sum(equal_ranks) / denominator
    return zero_one_loss 
开发者ID:kiudee,项目名称:cs-ranking,代码行数:13,代码来源:metrics.py


注:本文中的keras.backend.all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。