Vin*_*ier 5 python protocol-buffers tensorflow tensorflow-data-validation
TFDV 生成模式作为模式协议缓冲区。然而,似乎没有帮助函数来向/从文件写入/读取模式。
schema = tfdv.infer_schema(stats)
Run Code Online (Sandbox Code Playgroud)
如何保存/加载它?
小智 6
您可以使用以下方法向/从文件写入/加载架构。
from google.protobuf import text_format
from tensorflow.python.lib.io import file_io
from tensorflow_metadata.proto.v0 import schema_pb2
def write_schema(schema, output_path):
schema_text = text_format.MessageToString(schema)
file_io.write_string_to_file(output_path, schema_text)
def load_schema(input_path):
schema = schema_pb2.Schema()
schema_text = file_io.read_file_to_string(input_path)
text_format.Parse(schema_text, schema)
return schema
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1273 次 |
| 最近记录: |