相关疑难解决方法(0)

使用实例键进行培训和预测

我能够训练我的模型并使用ML Engine进行预测,但我的结果不包括任何识别信息.这在一次提交一行进行预测时工作正常但在提交多行时我无法将预测连接回原始输入数据.该GCP文件讨论了使用实例密钥,但我无法找到训练和使用实例密钥预测任何示例代码.采用GCP人口普查示例如何更新输入函数以通过图表传递唯一ID并在训练期间忽略它并返回带预测的唯一ID?或者,如果有人知道已经使用了也有帮助的键的另一个例子.

来自Census Estimator Sample

def serving_input_fn():
    feature_placeholders = {
      column.name: tf.placeholder(column.dtype, [None])
      for column in INPUT_COLUMNS
    }

    features = {
      key: tf.expand_dims(tensor, -1)
      for key, tensor in feature_placeholders.items()
    }

    return input_fn_utils.InputFnOps(
      features,
      None,
      feature_placeholders
    )


def generate_input_fn(filenames,
                  num_epochs=None,
                  shuffle=True,
                  skip_header_lines=0,
                  batch_size=40):

    def _input_fn():
        files = tf.concat([
          tf.train.match_filenames_once(filename)
          for filename in filenames
        ], axis=0)

        filename_queue = tf.train.string_input_producer(
          files, num_epochs=num_epochs, shuffle=shuffle)
        reader = tf.TextLineReader(skip_header_lines=skip_header_lines)

        _, rows = reader.read_up_to(filename_queue, num_records=batch_size)

        row_columns = tf.expand_dims(rows, -1)
        columns = tf.decode_csv(row_columns, record_defaults=CSV_COLUMN_DEFAULTS)
        features …
Run Code Online (Sandbox Code Playgroud)

tensorflow google-cloud-ml-engine

12
推荐指数
1
解决办法
2635
查看次数

标签 统计

google-cloud-ml-engine ×1

tensorflow ×1