当前位置: 首页>>代码示例>>Python>>正文


Python framework.load_variable方法代码示例

本文整理汇总了Python中tensorflow.contrib.framework.load_variable方法的典型用法代码示例。如果您正苦于以下问题:Python framework.load_variable方法的具体用法?Python framework.load_variable怎么用?Python framework.load_variable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tensorflow.contrib.framework的用法示例。


在下文中一共展示了framework.load_variable方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_weights

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def get_weights(self, model_dir):
    """Returns weights per feature of the linear part.

    Args:
      model_dir: Directory where model parameters, graph and etc. are saved.

    Returns:
      The weights created by this model (without the optimizer weights).
    """
    all_variables = [name for name, _ in list_variables(model_dir)]
    values = {}
    optimizer_regex = r".*/" + self._get_optimizer().get_name() + r"(_\d)?$"
    for name in all_variables:
      if (name.startswith(self._scope + "/") and
          name != self._scope + "/bias_weight" and
          not re.match(optimizer_regex, name)):
        values[name] = load_variable(model_dir, name)
    if len(values) == 1:
      return values[list(values.keys())[0]]
    return values 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:22,代码来源:composable_model.py

示例2: get_bias

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def get_bias(self, model_dir):
    """Returns bias of the model.

    Args:
      model_dir: Directory where model parameters, graph and etc. are saved.

    Returns:
      The bias weights created by this model.
    """
    return load_variable(model_dir, name=(self._scope + "/bias_weight")) 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:12,代码来源:composable_model.py

示例3: fit

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def fit(self, x=None, y=None, input_fn=None, steps=None, batch_size=None,
          monitors=None, max_steps=None):
    # pylint: disable=g-doc-args,g-doc-return-or-yield
    """See `Trainable`.

    Raises:
      ValueError: If `x` or `y` are not `None` while `input_fn` is not `None`.
      ValueError: If both `steps` and `max_steps` are not `None`.
    """
    if (steps is not None) and (max_steps is not None):
      raise ValueError('Can not provide both steps and max_steps.')
    _verify_input_args(x, y, input_fn, None, batch_size)
    if x is not None:
      SKCompat(self).fit(x, y, batch_size, steps, max_steps, monitors)
      return self

    if max_steps is not None:
      try:
        start_step = load_variable(self._model_dir, ops.GraphKeys.GLOBAL_STEP)
        if max_steps <= start_step:
          logging.info('Skipping training since max_steps has already saved.')
          return self
      except:  # pylint: disable=bare-except
        pass

    hooks = monitor_lib.replace_monitors_with_hooks(monitors, self)
    if steps is not None or max_steps is not None:
      hooks.append(basic_session_run_hooks.StopAtStepHook(steps, max_steps))

    loss = self._train_model(input_fn=input_fn, hooks=hooks)
    logging.info('Loss for final step: %s.', loss)
    return self 
开发者ID:ryfeus,项目名称:lambda-packs,代码行数:34,代码来源:estimator.py

示例4: _initialize_deep_lab_rgb_weights

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def _initialize_deep_lab_rgb_weights(self, fn):
    vars_ = tf.global_variables()
    var_w = [x for x in vars_ if x.name == "xception_65/entry_flow/conv1_1/weights:0"]
    assert len(var_w) == 1, len(var_w)
    var_w = var_w[0]
    w = load_variable(fn, "xception_65/entry_flow/conv1_1/weights")
    val_new_w = self.session.run(var_w)
    val_new_w[:, :, :3, :] = w
    placeholder_w = tf.placeholder(tf.float32)
    assign_op_w = tf.assign(var_w, placeholder_w)
    self.session.run(assign_op_w, feed_dict={placeholder_w: val_new_w}) 
开发者ID:tobiasfshr,项目名称:MOTSFusion,代码行数:13,代码来源:Saver.py

示例5: weights_

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def weights_(self):
    values = {}
    optimizer_regex = r".*/"+self._optimizer.get_name() + r"(_\d)?$"
    for name, _ in list_variables(self._model_dir):
      if (name.startswith("linear/") and
          name != "linear/bias_weight" and
          not re.match(optimizer_regex, name)):
        values[name] = load_variable(self._model_dir, name)
    if len(values) == 1:
      return values[list(values.keys())[0]]
    return values 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:13,代码来源:svm.py

示例6: bias_

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def bias_(self):
    return load_variable(self._model_dir, name="linear/bias_weight") 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:4,代码来源:svm.py

示例7: get_bias

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def get_bias(self, model_dir):
    """Returns bias of the model.

    Args:
      model_dir: Directory where model parameters, graph and etc. are saved.

    Returns:
      The bias weights created by this model.
    """
    return load_variable(model_dir, name=(self._scope+"/bias_weight")) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:12,代码来源:composable_model.py

示例8: get_variable_value

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def get_variable_value(self, name):
    """Returns value of the variable given by name.

    Args:
      name: string, name of the tensor.

    Returns:
      `Tensor` object.
    """
    return load_variable(self._model_dir, name) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:12,代码来源:dnn.py

示例9: weights_

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def weights_(self):
    hiddenlayer_weights = [load_variable(
        self._model_dir, name=("dnn/hiddenlayer_%d/weights" % i))
                           for i, _ in enumerate(self._hidden_units)]
    logits_weights = [load_variable(self._model_dir, name="dnn/logits/weights")]
    return hiddenlayer_weights + logits_weights 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:8,代码来源:dnn.py

示例10: bias_

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def bias_(self):
    hiddenlayer_bias = [load_variable(
        self._model_dir, name=("dnn/hiddenlayer_%d/biases" % i))
                        for i, _ in enumerate(self._hidden_units)]
    logits_bias = [load_variable(self._model_dir, name="dnn/logits/biases")]
    if self._estimator.params["enable_centered_bias"]:
      centered_bias = [
          load_variable(self._model_dir, name=_CENTERED_BIAS_WEIGHT)]
    else:
      centered_bias = []
    return hiddenlayer_bias + logits_bias + centered_bias 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:13,代码来源:dnn.py

示例11: get_variable_value

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def get_variable_value(self, name):
    """Returns value of the variable given by name.

    Args:
      name: string, name of the tensor.

    Returns:
      Numpy array - value of the tensor.
    """
    return load_variable(self.model_dir, name) 
开发者ID:tobegit3hub,项目名称:deep_image_model,代码行数:12,代码来源:estimator.py

示例12: _initialize_deep_lab_rgb_weights

# 需要导入模块: from tensorflow.contrib import framework [as 别名]
# 或者: from tensorflow.contrib.framework import load_variable [as 别名]
def _initialize_deep_lab_rgb_weights(self, fn):
    vars_ = tf.global_variables()
    var_w = [x for x in vars_ if x.name == "xception_65/entry_flow/conv1_1/weights:0"]
    assert len(var_w) == 1, len(var_w)
    var_w = var_w[0]
    from tensorflow.contrib.framework import load_variable
    w = load_variable(fn, "xception_65/entry_flow/conv1_1/weights")
    val_new_w = self.session.run(var_w)
    val_new_w[:, :, :3, :] = w
    placeholder_w = tf.placeholder(tf.float32)
    assign_op_w = tf.assign(var_w, placeholder_w)
    self.session.run(assign_op_w, feed_dict={placeholder_w: val_new_w}) 
开发者ID:VisualComputingInstitute,项目名称:TrackR-CNN,代码行数:14,代码来源:Saver.py


注:本文中的tensorflow.contrib.framework.load_variable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。