本文整理匯總了Python中tensorflow.contrib.slim.get_trainable_variables方法的典型用法代碼示例。如果您正苦於以下問題:Python slim.get_trainable_variables方法的具體用法?Python slim.get_trainable_variables怎麽用?Python slim.get_trainable_variables使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tensorflow.contrib.slim
的用法示例。
在下文中一共展示了slim.get_trainable_variables方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_gradients
# 需要導入模塊: from tensorflow.contrib import slim [as 別名]
# 或者: from tensorflow.contrib.slim import get_trainable_variables [as 別名]
def get_gradients(self, optimizer, loss):
'''
:param optimizer:
:param loss:
:return:
return vars and grads that not be fixed
'''
# if cfgs.FIXED_BLOCKS > 0:
# trainable_vars = tf.trainable_variables()
# # trained_vars = slim.get_trainable_variables()
# start_names = [cfgs.NET_NAME + '/block%d'%i for i in range(1, cfgs.FIXED_BLOCKS+1)] + \
# [cfgs.NET_NAME + '/conv1']
# start_names = tuple(start_names)
# trained_var_list = []
# for var in trainable_vars:
# if not var.name.startswith(start_names):
# trained_var_list.append(var)
# # slim.learning.train()
# grads = optimizer.compute_gradients(loss, var_list=trained_var_list)
# return grads
# else:
# return optimizer.compute_gradients(loss)
return optimizer.compute_gradients(loss)