Ex4code.zip
and unzip it. This will create a directory
Ex4code
with two very simple PyTorch programs,
slope.py
and xor.py
.
The program slope.py
solves the simplest possible machine learning task:
solveF(x) = A*x
such thatF(1)=1
Run the program by typing
python3 slope.py --lr 0.1Try running the code using each of the following values for learning rate:
0.01, 0.1, 0.5, 1.0, 1.5, 1.9, 2.0, 2.1Describe what happens in each case, in terms of the success and speed of the algorithm.
python3 slope.py --mom 0.1Try running the code with learning rate kept at the default value of
1.9
but with
momentum equal to 0.1, 0.2,
etc. up to 0.9
.
For which value of momentum is the task solved in the fewest epochs?
What happens when the momentum is 1.0
?
What happens when it is 1.1
?
The program xor.py
trains a 2-layer neural network on the XOR task.
python3 xor.pyFor how many runs does it reach the global minimum? For how many runs does it reach a local minimum?
0.1
, can you find values of
momentum (--mom
) and initial weight size (--init
)
for which the code converges relatively quickly to the global minimum on virtually every run?