當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。