如何解决有没有办法用@tf.function 解码 base64 编码的字符串?
我使用的是 TensorFlow 2.4.1。我尝试使用 tf.strings.unicode_decode 用@tf.function 解码 base64 编码的字符串,但发生了错误,其中 ValueError: Rank of input
必须是静态已知的。我检查了 tf.strings.unicode_decode 在没有@tf.function 的情况下工作正常。有没有办法用@tf.function 解码 base64 编码的字符串?非常感谢您的回答。
我加载了 SavedModel 并想更改 serving_default
。但是我在将输入转换为 UTF-8
时遇到了困难。这是我试过的代码。
class CustomTransformer(tf.keras.Model):
def __init__(self):
super(CustomTransformer,self).__init__()
self.model = tf.saved_model.load('./models/transformer/1')
@tf.function(input_signature=[tf.TensorSpec(shape=None,dtype=tf.string)])
def call(self,input):
# Error occurred. ValueError: Rank of `input` must be statically known.
_input_str = tf.strings.unicode_decode(input_data,'UTF-8')
return _input_str
这是错误信息。
ValueError: Rank of `input` must be statically known.
在尝试从加载的 SavedModel 更改 UTF-8
时,是否有将输入转换为 serving_default
的方法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。