def test_updates_algorithm():
    n = shared_floatx(1)
    algorithm = UpdatesAlgorithm(updates=[(n, n + 1)])
    algorithm.initialize()
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 2)
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 3)
Beispiel #2
0
def test_updates_algorithm():
    n = shared_floatx(1)
    algorithm = UpdatesAlgorithm(updates=[(n, n + 1)])
    algorithm.initialize()
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 2)
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 3)
def test_updates_algorithm_data():
    n = shared_floatx(1)
    m = tensor.scalar('m')
    algorithm = UpdatesAlgorithm(updates=[(n, m + 1)])
    algorithm.initialize()
    algorithm.process_batch({'m': 5})
    assert_allclose(n.get_value(), 6)
    algorithm.process_batch({'m': 3})
    assert_allclose(n.get_value(), 4)
Beispiel #4
0
def test_updates_algorithm_data():
    n = shared_floatx(1)
    m = tensor.scalar('m')
    algorithm = UpdatesAlgorithm(updates=[(n, m + 1)])
    algorithm.initialize()
    algorithm.process_batch({'m': 5})
    assert_allclose(n.get_value(), 6)
    algorithm.process_batch({'m': 3})
    assert_allclose(n.get_value(), 4)
def test_updates_algorithm_add_updates():
    n = shared_floatx(1)
    m = shared_floatx(0)
    algorithm = UpdatesAlgorithm(updates=[(n, n + 1)])
    algorithm.add_updates([(m, n % 2)])
    assert len(algorithm.updates) == 2
    algorithm.initialize()
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 2)
    assert_allclose(m.get_value(), 1)
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 3)
    assert_allclose(m.get_value(), 0)
Beispiel #6
0
def test_updates_algorithm_add_updates():
    n = shared_floatx(1)
    m = shared_floatx(0)
    algorithm = UpdatesAlgorithm(updates=[(n, n + 1)])
    algorithm.add_updates([(m, n % 2)])
    assert len(algorithm.updates) == 2
    algorithm.initialize()
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 2)
    assert_allclose(m.get_value(), 1)
    algorithm.process_batch({})
    assert_allclose(n.get_value(), 3)
    assert_allclose(m.get_value(), 0)