Closed chopsuey5000 closed 3 years ago
Can you one of our VMs and see if this issue persists?
Hi Sayak,
I've tried with the VM and the problem persists.
With 10 iterations the output is:
$ python regularization.py --dataset ../datasets/animals
[INFO] loading images...
[INFO] processed 500/3000
[INFO] processed 1000/3000
[INFO] processed 1500/3000
[INFO] processed 2000/3000
[INFO] processed 2500/3000
[INFO] processed 3000/3000
[INFO] tranining model with 'None' penalty
[INFO] 'None' penalty accuracy: 53.73%
[INFO] tranining model with 'l1' penalty
[INFO] 'l1' penalty accuracy: 53.33%
[INFO] tranining model with 'l2' penalty
[INFO] 'l2' penalty accuracy: 54.53%
(dl4cv) pyimagesearch@pyimagesearch-dl4cv:~/Documents/deep_learning/c9_optimization_methods$ python regularization.py --dataset ../datasets/animals
[INFO] loading images...
[INFO] processed 500/3000
[INFO] processed 1000/3000
[INFO] processed 1500/3000
[INFO] processed 2000/3000
[INFO] processed 2500/3000
[INFO] processed 3000/3000
[INFO] tranining model with 'None' penalty
/home/pyimagesearch/.virtualenvs/dl4cv/lib/python3.6/site-packages/sklearn/linear_model/stochastic_gradient.py:561: ConvergenceWarning: Maximum number of iteration reached before convergence. Consider increasing max_iter to improve the fit.
ConvergenceWarning)
[INFO] 'None' penalty accuracy: 45.07%
[INFO] tranining model with 'l1' penalty
/home/pyimagesearch/.virtualenvs/dl4cv/lib/python3.6/site-packages/sklearn/linear_model/stochastic_gradient.py:561: ConvergenceWarning: Maximum number of iteration reached before convergence. Consider increasing max_iter to improve the fit.
ConvergenceWarning)
[INFO] 'l1' penalty accuracy: 43.07%
[INFO] tranining model with 'l2' penalty
/home/pyimagesearch/.virtualenvs/dl4cv/lib/python3.6/site-packages/sklearn/linear_model/stochastic_gradient.py:561: ConvergenceWarning: Maximum number of iteration reached before convergence. Consider increasing max_iter to improve the fit.
ConvergenceWarning)
[INFO] 'l2' penalty accuracy: 51.87%
And with 100 iterations the output is:
$ python regularization.py --dataset ../datasets/animals
[INFO] loading images...
[INFO] processed 500/3000
[INFO] processed 1000/3000
[INFO] processed 1500/3000
[INFO] processed 2000/3000
[INFO] processed 2500/3000
[INFO] processed 3000/3000
[INFO] tranining model with 'None' penalty
[INFO] 'None' penalty accuracy: 53.73%
[INFO] tranining model with 'l1' penalty
[INFO] 'l1' penalty accuracy: 53.33%
[INFO] tranining model with 'l2' penalty
[INFO] 'l2' penalty accuracy: 54.53%
I see. What happens when you up it 1000?
Same result as with 100
$ python regularization.py --dataset ../datasets/animals
[INFO] loading images...
[INFO] processed 500/3000
[INFO] processed 1000/3000
[INFO] processed 1500/3000
[INFO] processed 2000/3000
[INFO] processed 2500/3000
[INFO] processed 3000/3000
[INFO] tranining model with 'None' penalty
[INFO] 'None' penalty accuracy: 53.73%
[INFO] tranining model with 'l1' penalty
[INFO] 'l1' penalty accuracy: 53.33%
[INFO] tranining model with 'l2' penalty
[INFO] 'l2' penalty accuracy: 54.53%
You meant 1000, right?
Yes
I took a look at the original results again:
They don't vary that much from what you have gotten. The increased performance might just have been due to the stochasticity that is induced in the algorithm under consideration.
Issue
I'm running the regularization.py code with 10 iterations and I get a warning saying (ConvergenceWarning: Maximum number of iteration reached before convergence. Consider increasing max_iter to improve the fit.):
Then I increased the number of iterations until 70 and the warning have disappeared but I cannot see any accuracy improvement using L1 or L2 regularizations as the textbook mentions.
Could please tell what is the issue?
Thanks in advance,