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


Python backend.get_value方法代码示例

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


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

示例1: get_config

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def get_config(self):
        config = super(AdamW, self).get_config()
        config.update({
            'learning_rate': self._serialize_hyperparameter('learning_rate'),
            'decay': self._serialize_hyperparameter('decay'),
            'beta_1': self._serialize_hyperparameter('beta_1'),
            'beta_2': self._serialize_hyperparameter('beta_2'),
            'epsilon': self.epsilon,
            'amsgrad': self.amsgrad,
            'batch_size': int(self.batch_size),
            'total_iterations': int(self.total_iterations),
            'weight_decays': self.weight_decays,
            'use_cosine_annealing': self.use_cosine_annealing,
            't_cur': int(K.get_value(self.t_cur)),
            'eta_t': float(K.get_value(self.eta_t)),
            'eta_min': float(K.get_value(self.eta_min)),
            'eta_max': float(K.get_value(self.eta_max)),
            'init_verbose': self.init_verbose
        })
        return config 
开发者ID:OverLordGoldDragon,项目名称:keras-adamw,代码行数:22,代码来源:optimizers_225tf.py

示例2: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        polynet,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 331, 331) if is_channels_first(data_format) else (batch_saze, 331, 331, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != polynet or weight_count == 95366600) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:polynet.py

示例3: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        spnasnet,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 224, 224) if is_channels_first(data_format) else (batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != spnasnet or weight_count == 4421616) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:spnasnet.py

示例4: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    pretrained = False

    models = [
        fastseresnet101b,
    ]

    for model in models:

        net = model(pretrained=pretrained)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        # assert (model != fastseresnet101b or weight_count == 55697960) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:24,代码来源:fastseresnet.py

示例5: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        pnasnet5large,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 331, 331) if is_channels_first(data_format) else (batch_saze, 331, 331, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != pnasnet5large or weight_count == 86057668) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:pnasnet.py

示例6: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    pretrained = False

    models = [
        zfnet,
        zfnetb,
    ]

    for model in models:

        net = model(pretrained=pretrained)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != zfnet or weight_count == 62357608)
        assert (model != zfnetb or weight_count == 107627624) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:26,代码来源:zfnet.py

示例7: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        inceptionv4,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 299, 299) if is_channels_first(data_format) else (batch_saze, 299, 299, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != inceptionv4 or weight_count == 42679816) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:inceptionv4.py

示例8: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        ghostnet,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 224, 224) if is_channels_first(data_format) else (batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != ghostnet or weight_count == 5180840) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:ghostnet.py

示例9: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        wrn50_2,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 224, 224) if is_channels_first(data_format) else (batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != wrn50_2 or weight_count == 68849128) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:wrn.py

示例10: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        inceptionresnetv2,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 299, 299) if is_channels_first(data_format) else (batch_saze, 299, 299, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != inceptionresnetv2 or weight_count == 55843464) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:inceptionresnetv2.py

示例11: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        diracnet18v2,
        diracnet34v2,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 224, 224) if is_channels_first(data_format) else (batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != diracnet18v2 or weight_count == 11511784)
        assert (model != diracnet34v2 or weight_count == 21616232) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:27,代码来源:diracnetv2.py

示例12: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        xception,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 299, 299) if is_channels_first(data_format) else (batch_saze, 299, 299, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != xception or weight_count == 22855952) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:xception.py

示例13: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        bninception,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 224, 224) if is_channels_first(data_format) else (batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != bninception or weight_count == 11295240) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:bninception.py

示例14: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    pretrained = False

    models = [
        darknet53,
    ]

    for model in models:

        net = model(pretrained=pretrained)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 224, 224, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != darknet53 or weight_count == 41609928) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:24,代码来源:darknet53.py

示例15: _test

# 需要导入模块: from tensorflow.keras import backend [as 别名]
# 或者: from tensorflow.keras.backend import get_value [as 别名]
def _test():
    import numpy as np
    import tensorflow.keras.backend as K

    data_format = "channels_last"
    pretrained = False

    models = [
        inceptionv3,
    ]

    for model in models:

        net = model(pretrained=pretrained, data_format=data_format)

        batch_saze = 14
        x = tf.random.normal((batch_saze, 3, 299, 299) if is_channels_first(data_format) else (batch_saze, 299, 299, 3))
        y = net(x)
        assert (tuple(y.shape.as_list()) == (batch_saze, 1000))

        weight_count = sum([np.prod(K.get_value(w).shape) for w in net.trainable_weights])
        print("m={}, {}".format(model.__name__, weight_count))
        assert (model != inceptionv3 or weight_count == 23834568) 
开发者ID:osmr,项目名称:imgclsmob,代码行数:25,代码来源:inceptionv3.py


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