Is it possible to plot an activation function that I define using an already existing activation from Keras? I tried doing it simply like this:
import keras
from keras import backend as K
import numpy as np
import matplotlib.pyplot as plt
# Define swish activation:
def swish(x):
return K.sigmoid(x) * x
x = np.linspace(-10, 10, 100)
plt.plot(x, swish(x))
plt.show()
but the above code produces an error: AttributeError: 'Tensor' object has no attribute 'ndim'
.
I've noticed this similar question but I couldn't adjust it to my need. I also tried playing with the .eval()
like suggested here but also without success.