pytorch/test
fehiepsi 91ea2cd5a7 clip sigmoid to prevent transforms return inf/nan values (#20288)
Summary:
This PR addresses some numerical issues of Sigmoid/StickBreakingTransform, where these transforms give +-inf when the unconstrained values move to +-20 areas.

For example, with
```
t = torch.distributions.SigmoidTransform()
x = torch.tensor(20.)
t.inv(t(x)), t.log_abs_det_jacobian(x, t(x))
```
current behaviour the inverse will return `inf` and logdet return `-inf` while this PR makes it to `15.9424` and `-15.9424`.

And for
```
t = torch.distributions.StickBreakingTransform()
x = torch.tensor([20., 20.])
t.inv(t(x)), t.log_abs_det_jacobian(x, t(x))
```
current value is `(inf, nan)` and `-inf` for logdet, while this PR makes it `[16.6355, 71.3942]` and `-47.8272` for logdet.

Although these finite values are wrong and seems unavoidable, it is better than returning `inf` or `nan` in my opinion. This is useful in HMC where despite that the grad will be zero when the unconstrained parameter moves to unstable area (due to clipping), velocity variable will force the parameter move to another area which by chance can move the parameter out of unstable area. But inf/nan can be useful to stop doing inference early. So the changes in this PR might be inappropriate.

I also fix some small issues of `_Simplex` and `_RealVector` constraints where batch shape of the input is not respected when checking validation.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/20288

Differential Revision: D15742047

Pulled By: ezyang

fbshipit-source-id: b427ed1752c41327abb3957f98d4b289307a7d17
2019-06-10 11:16:31 -07:00
..
bottleneck
cpp Change compiler to use Load/Stores, then transform to SSA (#21101) 2019-06-10 10:26:43 -07:00
cpp_extensions Remove Variable::Impl and DifferentiableViewImpl (#17072) 2019-05-23 21:09:04 -07:00
custom_operator improve error message on inferred type (#21058) 2019-05-30 10:50:34 -07:00
data Implement kthvalue in ATen (#17544) 2019-03-01 19:00:10 -08:00
error_messages
expect Remove onnx export expects (#21238) 2019-06-03 10:30:12 -07:00
jit use fully qualified name for ScriptClasses (#19239) 2019-04-26 19:17:21 -07:00
onnx ONNX Export Slice and Flip ops for opset 10 2019-06-07 10:03:26 -07:00
optim Turn on F401: Unused import warning. (#18598) 2019-03-30 09:01:17 -07:00
test_module Turn on F401: Unused import warning. (#18598) 2019-03-30 09:01:17 -07:00
common_cuda.py Revert replicate.py to disallow replicating multi-device modules (#19278) 2019-04-16 10:03:38 -07:00
common_methods_invocations.py Add autograd for to_sparse. (#20458) 2019-06-06 14:23:51 -07:00
common_nn.py Turn on F401: Unused import warning. (#18598) 2019-03-30 09:01:17 -07:00
common_utils.py Don't leak threads on exit (#21438) 2019-06-10 09:14:13 -07:00
expecttest.py Add support for inline expect tests. (#12825) 2018-10-22 19:29:04 -07:00
HowToWriteTestsUsingFileCheck.md Add a document 'How to Write Tests Using FileCheck' (#19005) 2019-04-08 12:12:30 -07:00
hypothesis_utils.py Quantized Max Pool op (#20474) 2019-05-29 15:01:01 -07:00
jit_utils.py Interpreter support for CallFunction/CallMethod (#21562) 2019-06-09 15:28:26 -07:00
run_test.py add handle to run all jit tests (#21161) 2019-05-30 14:12:21 -07:00
test_autograd.py Don't leak threads on exit (#21438) 2019-06-10 09:14:13 -07:00
test_c10d.py Make CUDACachingAllocator::recordStream() a no-op on null ptrs (#20658) 2019-05-20 07:13:51 -07:00
test_cpp_extensions.py Test the exceptions raised by isfinite and isinf (#21168) 2019-06-06 10:30:26 -07:00
test_cuda_primary_ctx.py Lazily load libcuda libnvrtc from c++ (#17317) 2019-02-22 13:51:45 -08:00
test_cuda.py Change PyTorch tests to use non-default CUDA stream (#21474) 2019-06-07 10:24:48 -07:00
test_dataloader.py Сhange type of a tensor with bools (#19097) 2019-06-05 10:19:27 -07:00
test_distributed.py add process_group in convert_sync_batchnorm (#19240) 2019-05-07 06:51:18 -07:00
test_distributions.py clip sigmoid to prevent transforms return inf/nan values (#20288) 2019-06-10 11:16:31 -07:00
test_docs_coverage.py improve test_docs_coverage error messages (#21029) 2019-05-31 11:13:39 -07:00
test_expecttest.py Add support for inline expect tests. (#12825) 2018-10-22 19:29:04 -07:00
test_fake_quant.py replace num_bits with quant_min and quant_max (#21097) 2019-05-30 20:57:57 -07:00
test_indexing_cuda.py Speed-up "advanced" indexing operations (#13420) 2018-11-27 15:23:59 -08:00
test_indexing.py Added possibility to index scalars by bool masks (#21030) 2019-05-29 09:32:55 -07:00
test_jit_fuser.py JIT: Eliminate SumToSize by using Optional Lists (#18697) 2019-05-24 11:24:17 -07:00
test_jit_py3.py Support for rudimentary f-strings (#21037) 2019-05-30 15:50:45 -07:00
test_jit.py Change compiler to use Load/Stores, then transform to SSA (#21101) 2019-06-10 10:26:43 -07:00
test_logging.py Don't leak threads on exit (#21438) 2019-06-10 09:14:13 -07:00
test_mkldnn.py Add mkldnn softmax operator 2019-06-07 15:22:18 -07:00
test_multiprocessing_spawn.py Binding for prctl(PR_SET_PDEATHSIG) (#14491) 2018-11-29 20:09:19 -08:00
test_multiprocessing.py fixes multiprocessing serialization for integer nn.Parameter (#18639) 2019-04-01 17:15:42 -07:00
test_namedtensor.py Add test/test_namedtensor.py (#20168) 2019-05-09 09:09:22 -07:00
test_namedtuple_return_api.py Fix test_namedtuple_return (#20212) 2019-05-07 15:58:25 -07:00
test_nccl.py Shard all of tests based on how many tests exist. (#13160) 2018-10-26 18:20:34 -07:00
test_nn_quantized.py remaining use of t.quantize_linear (#21219) 2019-05-31 16:05:44 -07:00
test_nn.py Change PyTorch tests to use non-default CUDA stream (#21474) 2019-06-07 10:24:48 -07:00
test_numba_integration.py "CharTensor" numpy conversion is supported now (#21458) 2019-06-06 10:06:41 -07:00
test_optim.py Addresses bad behavior with overridden optimizer.step by #20124 (#21460) 2019-06-06 13:54:42 -07:00
test_quantized.py Fix a bug in qconv (#21294) 2019-06-05 10:19:31 -07:00
test_quantizer.py Add observer nodes for input data nodes (#19232) 2019-05-01 03:49:14 -07:00
test_sparse.py Shallow-copy indices and values in sparse tensor ctor (#20614) 2019-05-16 18:35:05 -07:00
test_tensorboard.py replace LegacyTracedModule with torchscript used in add_graph (#21339) 2019-06-07 10:43:08 -07:00
test_thd_distributed.py Turn on F401: Unused import warning. (#18598) 2019-03-30 09:01:17 -07:00
test_torch.py fix segfault in cat on CPU with tensors that can't be indexed with 32-bit ints. (#21530) 2019-06-09 15:28:06 -07:00
test_type_hints.py Turn on F401: Unused import warning. (#18598) 2019-03-30 09:01:17 -07:00
test_type_info.py Allow converting char tensor to numpy; add [fi]info.min (#15046) 2018-12-24 09:11:24 -08:00
test_utils.py remove import torchvision when testing torch.hub (#21132) 2019-05-31 07:38:30 -07:00