首页 > 解决方案 > 将张量的 dtype(来自现有模型)从 uint8 更改为 float

问题描述

嗨,我想将 exiqting 模型的输入 dtype 从 uint8 更改为 float,我加载了模型但我不知道如何修改输入 dtype,请帮助我

def load( checkpoint_filename, input_name="images",
             output_name="features"):
    session = tf.compat.v1.Session()
    with tf.io.gfile.GFile(checkpoint_filename, "rb") as file_handle:
        graph_def =  tf.compat.v1.GraphDef()
        graph_def.ParseFromString(file_handle.read())
    tf.import_graph_def(graph_def, name="net")
    input_var = tf.compat.v1.get_default_graph().get_tensor_by_name(
        "net/%s:0" % input_name)
    print(input_var.dtype.as_numpy_dtype)
load('./converttf2tflite/mars-small128TOtrt.pb')

标签: pythontensorflowtensor

解决方案


推荐阅读