| """Tests for time Tensor t.""" | |
| # Author: Kilian Fatras <kilian.fatras@mila.quebec> | |
| import pytest | |
| import torch | |
| from torchcfm.conditional_flow_matching import ( | |
| ConditionalFlowMatcher, | |
| ExactOptimalTransportConditionalFlowMatcher, | |
| SchrodingerBridgeConditionalFlowMatcher, | |
| TargetConditionalFlowMatcher, | |
| VariancePreservingConditionalFlowMatcher, | |
| ) | |
| seed = 1994 | |
| batch_size = 128 | |
| def test_random_Tensor_t(FM): | |
| # Test sample_location_and_conditional_flow functions | |
| x0 = torch.randn(batch_size, 2) | |
| x1 = torch.randn(batch_size, 2) | |
| torch.manual_seed(seed) | |
| t_given = torch.rand(batch_size) | |
| t_given, xt, ut = FM.sample_location_and_conditional_flow(x0, x1, t=t_given) | |
| torch.manual_seed(seed) | |
| t_random, xt, ut = FM.sample_location_and_conditional_flow(x0, x1, t=None) | |
| assert any(t_given == t_random) | |
| def test_guided_random_Tensor_t(FM, return_noise): | |
| # Test guided_sample_location_and_conditional_flow functions | |
| x0 = torch.randn(batch_size, 2) | |
| y0 = torch.randint(high=10, size=(batch_size, 1)) | |
| x1 = torch.randn(batch_size, 2) | |
| y1 = torch.randint(high=10, size=(batch_size, 1)) | |
| torch.manual_seed(seed) | |
| t_given = torch.rand(batch_size) | |
| t_given = FM.guided_sample_location_and_conditional_flow( | |
| x0, x1, y0=y0, y1=y1, t=t_given, return_noise=return_noise | |
| )[0] | |
| torch.manual_seed(seed) | |
| t_random = FM.guided_sample_location_and_conditional_flow( | |
| x0, x1, y0=y0, y1=y1, t=None, return_noise=return_noise | |
| )[0] | |
| assert any(t_given == t_random) | |
Xet Storage Details
- Size:
- 2.11 kB
- Xet hash:
- 5d682da9396f09509913ef2bd9936a865643acd480b8bc8d9b5337bb6b760766
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.