r/KerasML•
ejiido

how to add tanh to one embedding layer in keras

I wanted to add one tanh layer to embedding layer with keras functional api: x=layers.Embedding(vocab_size, 8, input_length=max_length)(input) output=keras.activations.tanh(x)

model = Model(inputs=input, outputs=output) model.compile(optimizer='rmsprop',loss='categorical_crossentropy',metrics=['accuracy']) model.fit(data, labels) but system told me I must use keras layers ,not tensor. I searched a lot keras tutorials. There is only one way to solve this problem:

model.add(Activation('tanh')) but it is Sequential model which I don't want to use.Is there some ways to solve this with functional api?

Posted Dec 16, 2018, 11:05 PM UTC

21
Loading comments…