def gradient(self, x, t):
    self.loss(x, t)
    dout = 1
    dout = self.lastLayer.backward(dout)
    layers = list(self.layers.values())
    layers.reverse()
    for layer in layers:
        dout = layer.backward(dout)
    grads = {}
    (grads['W1'], grads['b1']) = (self.layers['Affine1'].dW, self.layers['Affine1'].db)
    (grads['W2'], grads['b2']) = (self.layers['Affine2'].dW, self.layers['Affine2'].db)
    return grads
def gradient(self, x, t):
    self.loss(x, t)
    dout = 1
    dout = self.lastLayer.backward(dout)
    layers = list(self.layers.values())
    layers.reverse()
    for layer in layers:
        dout = layer.backward(dout)
    grads = {}
    (grads['W1'], grads['b1']) = (self.layers['Affine1'].dW, self.layers['Affine1'].db)
    (grads['W2'], grads['b2']) = (self.layers['Affine2'].dW, self.layers['Affine2'].db)
    return grads