コード例 #1
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_negative(array):
    result = 0.5 + torch_interp(array, [0.0, 0.5, 1.0], [-2.0, 0.0, 2.0]) / 4.0
    assert pytest.approx(0.0, abs=1e-6) == torch.mean(array - result)
コード例 #2
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_multiply(array):
    result = (torch_interp(array, [0.0, 1.0], [2.0, 4.0]) - 2.0) * 0.5
    assert pytest.approx(0.0, abs=1e-6) == torch.mean(array - result)
コード例 #3
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_clamp(array):
    result = torch_interp(array, [0.2, 0.8], [0.2, 0.8])
    print(array.clamp(0.2, 0.8), result)
    assert pytest.approx(
        0.0, abs=1e-6) == torch.mean(array.clamp(0.2, 0.8) - result)
コード例 #4
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_offset(array):
    result = torch_interp(array, [0.0, 1.0], [2.0, 3.0]) - 2.0
    assert pytest.approx(0.0, abs=1e-6) == torch.mean(array - result)
コード例 #5
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_inverse(array):
    result = 1.0 - torch_interp(array, [0.0, 0.75, 1.0], [1.0, 0.25, 0.0])
    assert pytest.approx(0.0, abs=1e-6) == torch.mean(array - result)
コード例 #6
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_nonlinear_intervals(array):
    result = torch_interp(array, [0.0, 0.1, 0.8, 1.0], [0.0, 0.1, 0.8, 1.0])
    assert pytest.approx(0.0, abs=1e-6) == torch.mean(array - result)
コード例 #7
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_linear_extrapolate(array):
    result = torch_interp(array, [-1.0, 2.0], [-1.0, 2.0])
    assert pytest.approx(0.0, abs=1e-6) == torch.mean(array - result)
コード例 #8
0
ファイル: prop_utils.py プロジェクト: xnyr/neural-imagen
def test_interp_linear_unit(array):
    result = torch_interp(array, [0.0, 0.5, 1.0], [0.0, 0.5, 1.0])
    assert (array == result).all()