我希望更改已保存的模型的输入和输出签名,我使用tf.Module对象构建了主模型的操作。
class Generator(tf.Module):
def __init__(....):
super(Generator, self).__init__(name=name)
...
with self.name_scope:
...
@tf.Module.with_name_scope
def __call__(self, input):
...
@tf.function
def serve_function(self, input):
out = self.__call__(input)
return out
call = model.Generator.serve_function.get_concrete_function(tf.TensorSpec([None, 256, 256, 3], tf.float32))
tf.saved_model.save(model.Generator, os.path.join(train_log_dir, 'frozen'))
我正在加载模型,但是我的签名是"default_serving"和"output_0",我该如何更改?
self.serving._model
是什么?它是否因为我们使用的装饰器而始终可用? - Jash Shahself.serving._model
是从本地项目复制粘贴留下来的。我已经删除了这个引用,并用model
替换了它。所以,model
只是TensorFlow对象。它在调用model.fit()
时使用的是同一个对象。 - Eric McLachlan