Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Disable weight update for the vgg parameters (#2990)
Browse files Browse the repository at this point in the history
* Disable weight update for the vgg parameters

* Updated true to True and false to False

* Switched double quotes to single quotes
  • Loading branch information
abhishekpratapa authored Feb 10, 2020
1 parent 4ae2c65 commit 43ee1d1
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@ def define_tensorflow_variables(net_params, trainable=True):
Parameters
----------
trainable: boolean
If `true` the network updates the convolutional layers as well as the
instance norm layers of the network. If `false` only the instance norm
layers of the network are updated.
If `True` the transformer network updates the convolutional layers as
well as the instance norm layers of the network. If `False` only the
instance norm layers of the network are updated.
Note the VGG network's parameters aren't updated
Returns
-------
out: dict
Expand All @@ -35,21 +37,24 @@ def define_tensorflow_variables(net_params, trainable=True):
tensorflow_variables = dict()
for key in net_params.keys():
if "weight" in key:
# only set the parameter to train if in the transformer network
train_param = trainable and "transformer_" in key
if "conv" in key:
tensorflow_variables[key] = _tf.Variable(
initial_value=_utils.convert_conv2d_coreml_to_tf(net_params[key]),
name=key,
trainable=trainable,
trainable=train_param,
)
else:
# This is the path that the instance norm takes
tensorflow_variables[key] = _tf.Variable(
initial_value=_utils.convert_dense_coreml_to_tf(net_params[key]),
name=key,
trainable=trainable,
trainable=True,
)
else:
tensorflow_variables[key] = _tf.Variable(
initial_value=net_params[key], name=key, trainable=trainable
initial_value=net_params[key], name=key, trainable=False
)
return tensorflow_variables

Expand Down

0 comments on commit 43ee1d1

Please sign in to comment.