我正在尝试在 Tensorflow-Keras 的自定义层中使用多个输入。用法可以是任何东西,现在它被定义为将蒙版与图像相乘。我已经搜索过,我能找到的唯一答案是 TF 1.x,所以它没有任何好处。
class mul(layers.Layer):
def __init__(self, **kwargs):
super().__init__(**kwargs)
# I've added pass because this is the simplest form I can come up with.
pass
def call(self, inputs):
# magic happens here and multiplications occur
return(Z)
Run Code Online (Sandbox Code Playgroud) 我检查了其他问题,并阅读了他们的解决方案,但它们不起作用。我已经测试了它适用于非语言环境字符的正则表达式。代码只是在字符串中找到任何大写字母并对其进行一些处理。例如minik?eker bir kedi会返回k?e但是我的代码不能识别?为[A-Z]. 当我re.LOCALE按照某些人的要求尝试ValueError: cannot use LOCALE flag with a str pattern时,使用时出现错误re.UNICODE
import re
corp = "minik?eker bir kedi"
pattern = re.compile(r"([\w]{1})()([A-Z]{1})", re.U)
corp = re.sub(pattern, r"\1 \3", corp)
print(corp)
Run Code Online (Sandbox Code Playgroud)
适用于minikSeker bir kedi不适用于minik?eker bir kedi并为 引发错误re.L。我得到的错误是ValueError: cannot use LOCALE flag with a str pattern搜索它产生了一些 git 讨论,但没有任何用处。