MCPcopy Index your code
hub / github.com/DeepLabCut/DeepLabCut / get_optimizer

Function get_optimizer

deeplabcut/pose_estimation_tensorflow/core/train.py:96–113  ·  view source on GitHub ↗
(loss_op, cfg)

Source from the content-addressed store, hash-verified

94
95
96def get_optimizer(loss_op, cfg):
97 tstep = tf.compat.v1.placeholder(tf.int32, shape=[], name="tstep")
98 if "efficientnet" in cfg["net_type"]:
99 print("Switching to cosine decay schedule with adam!")
100 cfg["optimizer"] = "adam"
101 learning_rate = tf.compat.v1.train.cosine_decay(cfg["lr_init"], tstep, cfg["decay_steps"], alpha=cfg["alpha_r"])
102 else:
103 learning_rate = tf.compat.v1.placeholder(tf.float32, shape=[])
104
105 if cfg["optimizer"] == "sgd":
106 optimizer = tf.compat.v1.train.MomentumOptimizer(learning_rate=learning_rate, momentum=0.9)
107 elif cfg["optimizer"] == "adam":
108 optimizer = tf.compat.v1.train.AdamOptimizer(learning_rate)
109 else:
110 raise ValueError("unknown optimizer {}".format(cfg["optimizer"]))
111 train_op = slim.learning.create_train_op(loss_op, optimizer)
112
113 return learning_rate, train_op, tstep
114
115
116def get_optimizer_with_freeze(loss_op, cfg):

Callers 2

trainFunction · 0.90
trainFunction · 0.85

Calls 1

formatMethod · 0.80

Tested by

no test coverage detected