def test_gatefunction_sigmoid(runtime, test_nodenet):
    # set a node function for gen gates, expect it to be used
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source, register = prepare(runtime, test_nodenet)
    register.set_gate_configuration("gen", "sigmoid", {'bias': 1.2})
    runtime.save_nodenet(test_nodenet)
    net.step()
    assert round(register.get_gate("gen").activation, 5) == round(sigmoid(1, 1.2), 5)
    runtime.revert_nodenet(test_nodenet)
    net = runtime.nodenets[test_nodenet]
    net.step()
    assert round(net.get_node(register.uid).get_gate("gen").activation, 5) == round(sigmoid(1, 1.2), 5)
def test_gatefunctions(fixed_nodenet):
    # call every gatefunction once
    import micropsi_core.nodenet.gatefunctions as funcs
    assert funcs.absolute(-1., 0, 0) == 1
    assert funcs.one_over_x(2., 0, 0) == 0.5
    assert funcs.identity(1, 0, 0) == 1
    assert funcs.sigmoid(0, 0, 0) == 0.5
def test_gatefunction_sigmoid(fixed_nodenet):
    # set a node function for gen gates, expect it to be used
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source, register = prepare(fixed_nodenet)
    register.set_gatefunction_name("gen", "sigmoid")
    net.step()
    assert register.get_gate("gen").activation == sigmoid(1, 0, 0)
def test_node_activation_is_gen_gate_activation(runtime, test_nodenet):
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source, register = prepare(runtime, test_nodenet)
    register.set_gate_configuration('gen', 'sigmoid', {'bias': 1.3})
    sig = round(sigmoid(1, 1.3), 4)
    net.step()
    assert round(register.activation, 4) == sig
    assert round(register.get_gate('gen').activation, 4) == sig
Exemple #5
0
def test_node_activation_is_gen_gate_activation(fixed_nodenet):
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source, register = prepare(fixed_nodenet)
    register.set_gatefunction_name('gen', 'sigmoid')
    sig = round(sigmoid(1, 0, 0), 4)
    net.step()
    assert round(register.activation, 4) == sig
    assert round(register.get_gate('gen').activation, 4) == sig
Exemple #6
0
def test_gatefunction_sigmoid(fixed_nodenet):
    # set a node function for gen gates, expect it to be used
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source, register = prepare(fixed_nodenet)
    register.set_gatefunction_name("gen", "sigmoid")
    net.step()
    assert round(register.get_gate("gen").activation,
                 5) == round(sigmoid(1, 0, 0), 5)
def test_node_activation_is_gen_gate_activation(fixed_nodenet):
    from micropsi_core.nodenet.gatefunctions import sigmoid

    net, netapi, source, register = prepare(fixed_nodenet)
    register.set_gatefunction_name("gen", "sigmoid")
    sig = round(sigmoid(1, 0, 0), 4)
    net.step()
    assert round(register.activation, 4) == sig
    assert round(register.get_gate("gen").activation, 4) == sig
def test_set_gate_function(fixed_nodenet):
    # test setting a custom gate function
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source = prepare(fixed_nodenet)

    some_other_node_type = netapi.create_node("Pipe", None)
    netapi.unlink(source, "gen")

    net.step()
    assert source.get_gate("gen").activation == 0

    netapi.set_gatefunction(netapi.get_nodespace(None).uid, "Register", "gen", "sigmoid")

    source.set_gate_parameter('gen', 'theta', 1)

    net.step()

    assert round(source.get_gate("gen").activation, 5) == round(sigmoid(0, 0, 1), 5)
    assert some_other_node_type.get_gate("gen").activation == 0
def test_set_gate_function(fixed_nodenet):
    # test setting a custom gate function
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source = prepare(fixed_nodenet)

    some_other_node_type = netapi.create_node("Concept", "Root")
    netapi.unlink(source, "gen")

    net.step()
    assert source.get_gate("gen").activation == 0

    netapi.set_gatefunction("Root", "Register", "gen", "sigmoid")

    source.set_gate_parameter('gen', 'theta', 1)

    net.step()

    assert source.get_gate("gen").activation == sigmoid(0, 0, 1)
    assert some_other_node_type.get_gate("gen").activation == 0
Exemple #10
0
def test_set_gate_function(fixed_nodenet):
    # test setting a custom gate function
    from micropsi_core.nodenet.gatefunctions import sigmoid
    net, netapi, source = prepare(fixed_nodenet)

    some_other_node_type = netapi.create_node("Pipe", None)
    netapi.unlink(source, "gen")

    net.step()
    assert source.get_gate("gen").activation == 0

    netapi.set_gatefunction(
        netapi.get_nodespace(None).uid, "Register", "gen", "sigmoid")

    source.set_gate_parameter('gen', 'theta', 1)

    net.step()

    assert round(source.get_gate("gen").activation,
                 5) == round(sigmoid(0, 0, 1), 5)
    assert some_other_node_type.get_gate("gen").activation == 0