Code

RMSprop (Deep Learning Optimization Algorithm) Python implementation

class RMSprop(): # Object of this classes goes together with a layer parameters def __init__(self, input_dims, nodes): self.learning_rate = 0.01 self.beta = 0.9 # G matrx for parameters self.G_weights = np.zeros((input_dims, nodes)) # G matrix for biases self.G_biases = np.zeros(nodes) # Function gets gradient of the weigths and biases # Returns the update that we need to substract from # the current weights and biases def get_steps(self, grad_weights, grad_biases): eps = 1e-8 # updating G matrixes self.G_weights = self.beta * self.G_weights + (1 - self.beta) * np.power(grad_weights, 2) self.G_biases = self.beta * self.G_biases + (1 - self.beta) * np.power(grad_biases, 2) weights_step = np.multiply((self.learning_rate / np.sqrt(self.G_weights + eps)), grad_weights) biases_step = np.multiply((self.learning_rate / np.sqrt(self.G_biases + eps)), grad_biases) return weights_step, biases_step

0

2

Updated 2020-11-16

Tags

Data Science