本文整理汇总了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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)