keras
keras copied to clipboard
Identity layer in Keras?
@fchollet @qlzh727
I was trying to resolve #425 of keras-cv by simply adding a single Identity layer in the layers
list in case it was empty or None.
However, there is no Identity layer in Keras and thus I had to do it using the Lambda layer. Thus, I thought it would be good to have an Identity layer in Keras as there is one in torch (nn.Identity). We can support a subset of the same (leaving out the argument insensitive part, since I think it will be a nuisance for serialization).
I will be happy to code it up if you give the go-ahead.
Usually single op layer can use Lambda layer or will be auto wrapped by a TFOpLayer in functional model.
Layer usually should contain a block of predefined logic and I don't think we want to add any layer that only contains single op.
@qlzh727
I see. However, I think there are valid use cases of an Identity layer. For example, keras_cv.layers.RandomChoice
can contain keras.layers.Identity
as one of the possible augmentations. I believe it can also be used as a placeholder in many cases.
More importantly, I believe it helps with the object-oriented style of code writing. Thus I think this would be a worthy addition.
/cc @fchollet
@AdityaKane2001 feel free to send a PR for this!