【发布时间】:2018-01-29 17:48:59
【问题描述】:
在 tensorflow 中,我需要从 inception_v3 预训练模型中加载权重,以便在以下代码中使用:
with tf.variable_scope(scope, "InceptionV3", [images]) as scope:
with slim.arg_scope(
[slim.conv2d, slim.fully_connected],
weights_regularizer=weights_regularizer,
trainable=False):
with slim.arg_scope(
[slim.conv2d],
weights_initializer=tf.truncated_normal_initializer(stddev=stddev),
activation_fn=tf.nn.relu,
normalizer_fn=slim.batch_norm,
normalizer_params=batch_norm_params):
net, end_points = inception_v3_base(images, scope=scope)
with tf.variable_scope("logits"):
shape = net.get_shape()
net = slim.avg_pool2d(net, shape[1:3], padding="VALID", scope="pool")
net = slim.dropout(
net,
keep_prob=dropout_keep_prob,
is_training=False,
scope="dropout")
net = slim.flatten(net, scope="flatten")
image_embeddings = tf.contrib.layers.fully_connected(
inputs=net,
num_outputs=512,
activation_fn=None,
weights_initializer=initializer,
biases_initializer=None,
scope=scope)
怎么可能做到这一点?可以举个简单的例子吗?
上面的代码中有两个权重初始化器。我不知道我必须在哪一个初始化模型中的权重,以及如何初始化?
谢谢,
【问题讨论】:
-
您只有一个
.ckpt文件还是更多? (例如,.meta或.pbtxt/.pb) -
我只有一个 .ckpt 文件,@GPhilo。
-
您能否发布您获得检查点的页面的链接?它是来自 Tensorflow 模型动物园的预训练模型之一吗?
-
好的,该检查点的匹配 Tensorflow 模型在检查点附带的python file 中定义。我假设您已经下载了(如果没有,请下载并将其放在与您的脚本相同的文件夹中)
标签: python tensorflow