I am trying to create a layer that takes x as is (so that I can merge it with other layers).
I have used the following two methods and they both give the same warning:
/Users/sachin/anaconda/lib/python3.5/site-packages/keras/engine/topology.py:1656: UserWarning: Model inputs must come from a Keras Input layer, they cannot be the output of a previous non-Input layer. Here, a tensor specified as input to "sequential_158_model" was not an Input tensor, it was generated by layer identity_15.
Note that input tensors are instantiated via `tensor = Input(shape)`.
The tensor that caused the issue was: identity_input_10
str(x.name))
x = Sequential()
x.add(Lambda(lambda x: x, input_shape=(x2.shape[1],)))
from keras import backend as K
from keras.engine.topology import Layer
class Identity(Layer):
def __init__(self,output_dim, **kwargs):
self.output_dim = kwargs['input_shape'][0]
super(Identity, self).__init__(**kwargs)
def call(self, x, mask=None):
return x
def get_output_shape_for(self, input_shape):
return (input_shape[0], self.output_dim)
x = Sequential()
x.add(Lambda(lambda x: x, input_shape=(x2.shape[1],)))
My questions are:
Is it safe to proceed with this warning?
Yes.
Is there a way of getting rid of the warning?
x.add(Lambda(lambda x: x + 0, input_shape=(x2.shape[1],)))
Is the Lambda option preferable simply for readability reasons?
Yes.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs, but feel free to re-open it if needed.
Most helpful comment
Yes.
Yes.