3D Loss Landscapes of SoftNet-based on the public code
May 30, 2023 · View on GitHub
@inproceedings{
kang2023on,
title={On the Soft-Subnetwork for Few-Shot Class Incremental Learning},
author={Haeyong Kang and Jaehong Yoon and Sultan Rizky Hikmawan Madjid and Sung Ju Hwang and Chang D. Yoo},
booktitle={The Eleventh International Conference on Learning Representations },
year={2023},
url={https://openreview.net/forum?id=z57WK5lGeHd}
}
Define the class distributions
In this example the target classes will be generated from 2 class distributions: blue circles () and red stars (). Samples from both classes are sampled from their respective distributions. These samples are plotted in the figure below. Note that is a vector of target values , and is a corresponding matrix of individual input samples . In what follows we will also sometimes refer to the -th sample of as which is a vector of size $2$.
Logistic function and cross-entropy loss function
Logistic function
The goal is to predict the target class from the input values . The network is defined as having an input which gets transformed by the weights to generate the probability that sample belongs to class . This probability is represented by the output of the network computed as . is the logistic function and is defined as:
The logistic function is implemented below by the logistic(z) method below.
Cross-entropy loss function
The loss function used to optimize the classification is the cross-entropy error function. And is defined for sample as:
Which will give if we average over all samples.
The loss function is implemented below by the loss(y, t) method, and its output with respect to the parameters over all samples is plotted in the figure below.
The neural network output is implemented by the nn(x, w) method, and the neural network prediction by the nn_predict(x,w) method.
The logistic function with the cross-entropy loss function and the derivatives are explained in detail in the tutorial on the [logistic classification with cross-entropy]({% post_url /blog/cross_entropy/2015-06-10-cross-entropy-logistic %}).
Gradient descent optimization of the loss function
The gradient descent algorithm works by taking the gradient (derivative) of the loss function with respect to the parameters , and updates the parameters in the direction of the negative gradient (down along the loss function).
The parameters are updated every iteration by taking steps proportional to the negative of the gradient: . is defined as: with the learning rate.
Following the chain rule then , for each sample can be computed as follows:
Where is the output of the logistic neuron, and the input to the logistic neuron.
- can be calculated as (see [this post]({% post_url /blog/cross_entropy/2015-06-10-cross-entropy-logistic %}) for the derivation):
- can be calculated as (see [this post]({% post_url /blog/cross_entropy/2015-06-10-cross-entropy-logistic %}) for the derivation):
- can be calculated as:
Bringing this together we can write:
Notice how this gradient is the same (negating the constant factor) as the gradient of the squared error regression from previous section.
So the full update function for the weights will become:
In the batch processing, we just average all the gradients for each sample:
To start out the gradient descent algorithm, you typically start with picking the initial parameters at random and start updating these parameters according to the delta rule with until convergence.
The gradient is implemented by the gradient(w, x, t) function. is computed by the delta_w(w_k, x, t, learning_rate).
Gradient descent updates
Gradient descent is run on the example inputs and targets for 10 iterations. The first 3 iterations are shown in the figure below. The blue dots represent the weight parameter values at iteration .
Visualization of the trained classifier
The resulting decision boundary of running gradient descent on the example inputs and targets is shown in the figure below. The background color refers to the classification decision of the trained classifier. Note that since this decision plane is linear that not all examples can be classified correctly. Two blue circles will be misclassified as red star, and four red stars will be misclassified as blue circles.
Note that the decision boundary goes through the point since we don't have a bias parameter on the logistic output unit.