How to use the algorithms.rbm.RBM function in algorithms

To help you get started, we’ve selected a few algorithms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_set_train_points_sets_same_train_points_passed_to_it():
    train_points = make_simple_train_points()
    model = algorithms.rbm.RBM()
    model.set_train_points(train_points)
    numpy.testing.assert_array_equal(model.train_points, train_points)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_initialize_weights_and_biases_sets_expected_hidden_bias_values():
    arbitrary_num_hidden = 5
    arbitrary_num_visible = 7
    # TODO: log of the base rate? see Gilles Louppe's paper
    expected_hidden_biases = numpy.zeros(arbitrary_num_hidden)
    model = algorithms.rbm.RBM(num_hidden=arbitrary_num_hidden)
    model.num_visible = arbitrary_num_visible
    model.initialize_weights()
    numpy.testing.assert_array_equal(model.hidden_biases,
                                     expected_hidden_biases)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_init_can_set_custom_num_hidden():
    from random import random
    unique_num_hidden = random()
    model = algorithms.rbm.RBM(num_hidden=unique_num_hidden)
    assert model.num_hidden == unique_num_hidden
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_initialize_weights_and_biases_sets_expected_visible_bias_zeros():
    arbitrary_num_hidden = 5
    arbitrary_num_visible = 7
    expected_visible_biases = numpy.zeros(arbitrary_num_visible)
    model = algorithms.rbm.RBM(num_hidden=arbitrary_num_hidden)
    model.num_visible = arbitrary_num_visible
    model.initialize_weights()
    numpy.testing.assert_array_equal(model.visible_biases,
                                     expected_visible_biases)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_positive_cd_results_gets_hidden_activations():
    model = algorithms.rbm.RBM()
    model.hidden_activations = MockToTrack()
    model.hidden_probabilities = MockToSkip()
    model.hidden_states = MockToSkip()
    model.positive_cd_results()
    assert model.hidden_activations.call_count == 1
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_run_one_epoch_gets_positive_associations_from_probabilities():
    model = algorithms.rbm.RBM()
    pos_hid_probs, pos_hid_states = object(), None
    neg_hid_probs, neg_vis_probs = None, None
    model.positive_cd_results = MockToSkip(return_value=(pos_hid_probs,
                                                         pos_hid_states))
    model.negative_cd_results = MockToSkip(return_value=(neg_hid_probs,
                                                         neg_vis_probs))
    model.positive_associations = MockToTrack()
    model.negative_associations = MockToSkip()
    model.update_weights = MockToSkip()
    model.run_one_epoch()
    model.positive_associations.assert_called_once_with(pos_hid_probs)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_train_runs_custom_number_of_epochs():
    custom_numbers_of_epochs = 2, 3, 10
    model = algorithms.rbm.RBM()
    model.initialize_weights = MockToSkip()
    model.set_train_points = MockToSkip()
    model.run_all_epochs = MockToTrack()
    for custom_number_of_epochs in custom_numbers_of_epochs:
        model.train(train_points=None, number_of_epochs=custom_number_of_epochs)
        model.run_all_epochs.assert_called_with(custom_number_of_epochs)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_init_can_create_instance():
    model = algorithms.rbm.RBM()
    assert isinstance(model, algorithms.rbm.RBM)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_train_sets_training_points():
    train_points = object()
    model = algorithms.rbm.RBM()
    model.initialize_weights = MockToSkip()
    model.set_train_points = MockToTrack()
    model.run_all_epochs = MockToSkip()
    model.train(train_points=train_points)
    model.set_train_points.assert_called_once_with(train_points)
github JanCVanB / netflix / tests / test_rbm.py View on Github external
def test_rbm_init_sets_null_weights():
    expected_weights = numpy.array([])
    model = algorithms.rbm.RBM()
    numpy.testing.assert_array_equal(model.weights, expected_weights)