【发布时间】:2019-07-31 02:38:42
【问题描述】:
我尝试将 AlexNet 的某些层冻结为self.FROZEN_LAYER=['conv2', 'conv3']。
这是sn-p:
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]:
if len(data.shape) == 1:
var = tf.get_variable('biases',
trainable=[True if op_name not in self.FROZEN_LAYER else False][
0]) # todo: trainable
session.run(var.assign(data))
# Weights
else:
var = tf.get_variable('weights',
trainable=[True if op_name not in self.FROZEN_LAYER else False][0])
session.run(var.assign(data))
但是当我在tf.get_variable()函数中调试时(op_name: 'conv2'或'conv3'在调试器中),trainable参数不能设置为False。有谁知道问题出在哪里?
【问题讨论】:
标签: tensorflow