Could somebody help to point out the meaning of values to compare statistics like std(), min() and max() in the test for mapping output?
Why values like .005, .3, -2, etc. are used to make the comparison in the snippet below:
# Test the mapping function
map_fn = MappingLayers(10,20,30)
map_fn(torch.randn(1000, 10))
# [Question] Why using values like .005, .3, -2, etc. to make comparison?
assert outputs.std() > 0.05 and outputs.std() < 0.3
assert outputs.min() > -2 and outputs.min() < 0
assert outputs.max() < 2 and outputs.max() > 0
@TRAN_KHANH1,
This is just a test the developer came up with to help confirm that your implementation matches the requested implementation of 3 linear layers.
The test starts by passing in torch.randn(1000, 10) to the map function, so we know all the values are between 0 and 1, and have a uniform distribution, which tells us what the std should be (roughly). We also know that we called map_fn once, and that the values for the Linear W and b values are initialized to be in a certain range, so we can calculate maximum and minimum possible outputs. The tests just check that all these values are within those ranges.
For more details on initial values for Linear and randn, you can look at the documentation: nn.Linear torch.randn
But, the key point is - if you are failing these tests, you probably haven’t implemented the MappingLayers neural network as expected. Take a look at the hints for MappingLayers to see if you can figure out what you need to change.