How to create a custom layer in Keras with 'stateful' variables/tensors?
问题 I would like to ask you some help for creating my custom layer. What I am trying to do is actually quite simple: generating an output layer with 'stateful' variables, i.e. tensors whose value is updated at each batch. In order to make everything more clear, here is a snippet of what I would like to do: def call(self, inputs) c = self.constant m = self.extra_constant update = inputs*m + c X_new = self.X_old + update outputs = X_new self.X_old = X_new return outputs The idea here is quite