# silence tensorflow import verbose messages: import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense from tensorflow.keras import initializers, layers, activations, optimizers import numpy as np import matplotlib.pyplot as plt from inspect import getmembers, isfunction input = np.arange(-1,1.1,.1) actlist = getmembers(activations, predicate=isfunction) for (act,_) in actlist: #print(act) try: act_layer = layers.Activation(act) # run input through the activation function output = act_layer(input) print('found activation',act) plt.plot(input,output,'-',label=str(act)) except: # some functions are not activations pass plt.title('All Keras built-in activation functions') plt.axhline(color='black') plt.axvline(color='black') plt.legend() plt.show()