예제 #1
0
def test_dense_toy_dataset_model_with_missing_labels():
    model = dense_model(toy_dataset())
    x_train, y_train, x_test, y_test = toy_dataset()
    with pytest.raises(AssertionError) as err:
        plot_loss(model, ((x_train, y_train), (x_test, y_test)),
                  dataset_labels=('tranining set', ))

    assert err.type is AssertionError
    assert "Datasets and labels length must be the same" in str(err.value)
예제 #2
0
    def test_to_model_params_dense_net_values_are_close_to_original(self):
        model = dense_model(toy_dataset())
        sut, model_weights, is_bias, biases = self.get_sut_and_test_input(
            model)
        input = self.weights_as_single_vector(model_weights)

        recreated_params = sut.to_model_params(input)

        recreated_params = self.unwrap_list(recreated_params)
        for weights_matrix, is_b, bias, recreated_weights in zip(
                model_weights, is_bias, biases, recreated_params):
            self.is_close(recreated_weights, is_b, bias, weights_matrix)
예제 #3
0
def test_dense_toy_dataset_model():
    model = dense_model(toy_dataset())
    _, _, x_test, y_test = toy_dataset()
    plot_loss(model, (x_test, y_test))
예제 #4
0
def test_dense_toy_dataset_number_of_points_41():
    model = dense_model(toy_dataset())
    _, _, x_test, y_test = toy_dataset()
    plot_loss(model, (x_test, y_test), number_of_points=41)
예제 #5
0
def test_dense_toy_dataset_model_with_labels():
    model = dense_model(toy_dataset())
    x_train, y_train, x_test, y_test = toy_dataset()
    plot_loss(model, ((x_train, y_train), (x_test, y_test)),
              dataset_labels=('tranining set', 'test set'))
예제 #6
0
def test_dense_toy_dataset_model_multiple_datasets():
    model = dense_model(toy_dataset())
    x_train, y_train, x_test, y_test = toy_dataset()
    plot_loss(model, ((x_train, y_train), (x_test, y_test)))
예제 #7
0
def test_dense_toy_dataset_model():
    model = dense_model(toy_dataset())
    _, _, x_test, y_test = toy_dataset()
    plot_loss_3D(model, "levels", x_test, y_test)
예제 #8
0
def test_dense_toy_dataset_num_points_3():
    model = dense_model(toy_dataset())
    _, _, x_test, y_test = toy_dataset()
    plot_loss_3D(model, "levels", x_test, y_test, number_of_points=3)
예제 #9
0
 def setup(cls):
     if not hasattr(
             cls, 'initialized'):  # avoid learning networks multiple times
         cls.initialized = True
         cls.dense = dense_model(toy_dataset())
         cls.conv = conv_model(mnist_dataset())