【发布时间】:2015-11-12 14:14:40
【问题描述】:
当我从 git 克隆 AlexNet 时,它的基准是 Tensorflow 存储库的一部分。基准实现了这些层,但在我看来,AlexNet 的实际权重在任何时候都没有加载。
我想玩转 Tensorflow,但我的应用程序(在 caffe 中)使用的是预训练的 AlexNet。
你认为他们也会释放重量吗?
【问题讨论】:
当我从 git 克隆 AlexNet 时,它的基准是 Tensorflow 存储库的一部分。基准实现了这些层,但在我看来,AlexNet 的实际权重在任何时候都没有加载。
我想玩转 Tensorflow,但我的应用程序(在 caffe 中)使用的是预训练的 AlexNet。
你认为他们也会释放重量吗?
【问题讨论】:
我不知道现有的,但有人写了converter to import Caffe models into tensorflow,你可以找到pre-trained Alexnet models for Caffe(另见the BVLC Model-Zoo)。我不能保证它会起作用,但你很可能将这两者粘合在一起以获得你想要的。
【讨论】:
是的,有可用于 Tensorflow 的 AlexNet 预训练权重,您可以下载它here
要将它们加载到您的项目中,您可以使用以下代码(改编自here)
# Load the weights into memory
weights_dict = np.load('./weight-path/bvlc_alexnet.npy', encoding='bytes').item()
# Loop over all layer names stored in the weights dict
for op_name in weights_dict:
# Check if layer should be trained from scratch
if op_name not in self.SKIP_LAYER:
with tf.variable_scope(op_name, reuse=True):
# Assign weights/biases to their corresponding tf variable
for data in weights_dict[op_name]:
# Biases
if len(data.shape) == 1:
var = tf.get_variable('biases', trainable=False)
session.run(var.assign(data))
# Weights
else:
var = tf.get_variable('weights', trainable=False)
session.run(var.assign(data))
【讨论】:
http://www.cs.toronto.edu/~guerzhoy/tf_alexnet/ 的权重是 AlexNet 上经过训练的权重的 numpy 数组。您可以在 TensorFlow 中使用它们。
【讨论】:
不,基准文件只是实现,你必须训练和评估
【讨论】: