如何打印张量流对象?

时间:2019-12-23 17:08:48

标签: python tensorflow

def model_fn_builder(num_labels, learning_rate, num_train_steps,
                     num_warmup_steps):
  """Returns `model_fn` closure for TPUEstimator."""
  def model_fn(features, labels, mode, params):  # pylint: disable=unused-argument
    """The `model_fn` for TPUEstimator."""

    input_ids = features["input_ids"]
    input_mask = features["input_mask"]
    segment_ids = features["segment_ids"]
    label_ids = features["label_ids"]

    is_predicting = (mode == tf.estimator.ModeKeys.PREDICT)         

    # TRAIN and EVAL
    if not is_predicting:
      (loss, predicted_labels, log_probs) = create_model(
        is_predicting, input_ids, input_mask, segment_ids, label_ids, num_labels)



      train_op = bert.optimization.create_optimizer(
          loss, learning_rate, num_train_steps, num_warmup_steps, use_tpu=False)


  # Return the actual model function in the closure
  return model_fn

我想打印label_idspredicted_labelslog_probs,但是我无法使用tf.print来实现。

我的模型准确性很差,因此我需要逐步检查它。因此,我想在校准函数时逐步打印张量对象。

请帮助我使用tf 1.15

0 个答案:

没有答案