We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
在创建了 Linear 类以后,第一次实例化这个类的时候 linear = Linear(units=8),系统报错。反复与原始代码比较,没发现不同的地方。
Linear
linear = Linear(units=8)
class Linear(layers.Layer): def __init__(self, units=32, **kwargs): super(Linear, self).__init__(**kwargs) self.units = units def build(self, input_shape): self.w = self.add_weight('w', shape=(input_shape[-1], self.units), initializer='random_normal', trainable=True) self.b = self.add_weight('b', shape=(self.units,), initializer='random_normal', trainable=True) super(Linear, self).build(input_shape) @tf.function def call(self, inputs): return tf.matmul(inputs, self.w) + self.b def get_config(self): config = super(Linear, self).get_config() config.update({'units':self.units}) return config linear = Linear(units=8) --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-5-efa0d9cd5402> in <module> ----> 1 linear = Linear(units=8) 2 print(linear.built) 3 linear.build(input_shape=(None, 16)) 4 print(linear.built) TypeError: __call__() missing 1 required positional argument: 'inputs'
谢谢!
The text was updated successfully, but these errors were encountered:
No branches or pull requests
在创建了
Linear
类以后,第一次实例化这个类的时候linear = Linear(units=8)
,系统报错。反复与原始代码比较,没发现不同的地方。谢谢!
The text was updated successfully, but these errors were encountered: