示例#1
0
def test_weights_derivative():
    ly = layers.Weights((num_vis, num_hid))
    p = penalties.l2_penalty(0.37)
    ly.add_penalty({'matrix': p})
    vis = be.randn((num_samples, num_vis))
    hid = be.randn((num_samples, num_hid))
    derivs = ly.derivatives(vis, hid)
示例#2
0
def test_exponential_conditional_params():
    ly = layers.ExponentialLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    scaled_units = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    beta = be.rand((num_samples, 1))
    ly._conditional_params(scaled_units, weights, beta)
示例#3
0
def test_bernoulli_derivatives():
    ly = layers.BernoulliLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    vis = ly.random((num_samples, num_vis))
    hid = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    ly.derivatives(vis, hid, weights)
示例#4
0
def test_onehot_derivatives():
    ly = layers.OneHotLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    vis = ly.random((num_samples, num_vis))
    hid = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    ly.derivatives(vis, hid, weights)
示例#5
0
def test_gaussian_derivatives():
    ly = layers.GaussianLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    vis = ly.random((num_samples, num_vis))
    hid = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    ly.derivatives(vis, hid, weights)
示例#6
0
def test_onehot_conditional_params():
    ly = layers.OneHotLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    scaled_units = [be.randn((num_samples, num_hid))]
    weights = [w.W(trans=True)]
    beta = be.rand((num_samples, 1))
    ly.conditional_params(scaled_units, weights, beta)
示例#7
0
def test_exponential_update():
    ly = layers.BernoulliLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    scaled_units = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    beta = be.rand((num_samples, 1))
    ly.update(scaled_units, weights, beta)
示例#8
0
def test_weights_build_from_config():
    ly = layers.Weights((num_vis, num_hid))
    ly.add_constraint({'matrix': constraints.non_negative})
    p = penalties.l2_penalty(0.37)
    ly.add_penalty({'matrix': p})
    ly_new = layers.Layer.from_config(ly.get_config())
    assert ly_new.get_config() == ly.get_config()
示例#9
0
def test_ising_update():
    ly = layers.IsingLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    scaled_units = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    beta = be.rand((num_samples, 1))
    ly.update(scaled_units, weights, beta)
示例#10
0
def test_ising_derivatives():
    ly = layers.IsingLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    vis = ly.random((num_samples, num_vis))
    hid = [be.randn((num_samples, num_hid))]
    weights = [w.W()]
    beta = be.rand((num_samples, 1))
    ly.derivatives(vis, hid, weights, beta)
示例#11
0
def test_exponential_derivatives():
    ly = layers.ExponentialLayer(num_vis)
    w = layers.Weights((num_vis, num_hid))
    vis = ly.random((num_samples, num_vis))
    hid = [be.randn((num_samples, num_hid))]
    weights = [w.W_T()]
    beta = be.rand((num_samples, 1))
    ly.derivatives(vis, hid, weights, beta)
示例#12
0
def test_Weights_creation():
    layers.Weights((num_vis, num_hid))
示例#13
0
def test_weights_energy():
    ly = layers.Weights((num_vis, num_hid))
    vis = be.randn((num_samples, num_vis))
    hid = be.randn((num_samples, num_hid))
    ly.energy(vis, hid)
示例#14
0
def test_enforce_constraints():
    ly = layers.Weights((num_vis, num_hid))
    ly.add_constraint({'matrix': constraints.non_negative})
    ly.enforce_constraints()
示例#15
0
def test_get_base_config():
    ly = layers.Weights((num_vis, num_hid))
    ly.add_constraint({'matrix': constraints.non_negative})
    p = penalties.l2_penalty(0.37)
    ly.add_penalty({'matrix': p})
    ly.get_base_config()
示例#16
0
def test_parameter_step():
    ly = layers.Weights((num_vis, num_hid))
    deltas = layers.ParamsWeights(be.randn(ly.shape))
    ly.parameter_step(deltas)
示例#17
0
def test_get_penalty_grad():
    ly = layers.Weights((num_vis, num_hid))
    p = penalties.l2_penalty(0.37)
    ly.add_penalty({'matrix': p})
    ly.get_penalty_grad(ly.W(), 'matrix')
示例#18
0
def test_add_penalty():
    ly = layers.Weights((num_vis, num_hid))
    p = penalties.l2_penalty(0.37)
    ly.add_penalty({'matrix': p})