def test_rgb_image_hand_fitting_tensorflow():

    tf.config.set_visible_devices(
        [], "GPU")  # Running on CPU to get determinisic results

    energies = run(
        dl_library="tensorflow",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    if os.name == "nt":  # windows
        assert abs(energies[49] - 2112.9566220857746) < 1e-10
        # Running on CPU because it seems to change a lot
        # from one run to the next when using GPU
        # could use os.environ['TF_DETERMINISTIC_OPS'] = '1'
        # github action 2132.9307950405196

    elif os.name == "posix":  # linux
        assert ((abs(energies[49] - 2115.9320061795634) < 1e-10)
                or (abs(energies[49] - 2107.962374538259) < 1e-10)
                or (abs(energies[49] - 2115.9974345976066) < 1e-10))
        # github workflow linux 2115.9320061795634 or 2115.9974345976066
        # google colab 2107.962374538259
    else:
        raise BaseException(f"No results for os.name={os.name}")
def test_rgb_image_hand_fitting_pytorch():

    energies = run(
        dl_library="pytorch",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    assert abs(energies[49] - 2106.5436357944604) < 12
def test_rgb_image_hand_fitting_tensorflow():

    energies = run(
        dl_library="tensorflow",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    assert abs(energies[49] - 2107.0089187104204) < 1
def test_rgb_image_hand_fitting_numpy():

    energies = run(
        dl_library="none",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    assert abs(energies[49] - 2113.7013184079137) < 2
Beispiel #5
0
def test_rgb_image_hand_fitting_numpy():

    energies = run(
        dl_library="none",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    assert abs(energies[49] - 2122.2359691357165) < 2
def test_rgb_image_hand_fitting_numpy():

    energies = run(
        dl_library="none",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    # getting different result on python 3.6 or 3.7 in the github action, not sure why
    if os.name == "nt":  # windows
        assert abs(energies[49] - 2107.850380422819) < 1e-10
    else:
        # google colab Intel(R) Xeon(R) CPU @ 2.20GHz: 251.3164914350016
        assert abs(energies[49] - 2107.850380422819) < 2
def test_rgb_image_hand_fitting_pytorch():

    energies = run(
        dl_library="pytorch",
        plot_curves=False,
        display=False,
        save_images=False,
        max_iter=50,
    )
    if os.name == "nt":  # windows
        assert (abs(energies[49] - 2100.0239709048583) <
                1e-10) or (abs(energies[49] - 2132.9307950405196) < 1e-10)
        # 2100.0239709048583 : result on Intel(R) Xeon(R) W-2155 CPU @ 3.30GHz 3.31GHz
        # 2132.9307950405196 : result on Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz 2.40GHz
        # Possible explanation https://github.com/pytorch/pytorch/issues/54684
    else:
        assert abs(energies[49] - 2106.5436357944604) < 12