Posts

Showing posts from May, 2026
Image
 assignment 1 activation functions in nn: import numpy as np import matplotlib.pyplot as plt # Input values x = np.linspace(-10, 10, 100) # Activation functions sigmoid = 1 / (1 + np.exp(-x)) tanh = np.tanh(x) relu = np.maximum(0, x) linear = x # Plot all in one graph plt.figure(figsize=(8,6)) plt.plot(x, sigmoid, label="Sigmoid") plt.plot(x, tanh, label="Tanh") plt.plot(x, relu, label="ReLU") plt.plot(x, linear, label="Linear") # Labels and title plt.title("Activation Functions in Neural Networks") plt.xlabel("Input") plt.ylabel("Output") plt.legend() plt.grid() plt.show() orrrrrr import numpy as np import matplotlib . pyp lot as plt def sigmoid ( temp_arr ):     return 1 / ( 1 + np .exp( - temp_arr )) arr = np .linspace( - 8 , 8 ) plt . plot ( arr , sigmoid ( arr )) plt . axis ( 'tight' ) plt . title ( 'Activation Function : Sigmoid' ) # only for grid plt . grid () plt . show () print (...