コード例 #1
0
ファイル: test_maui.py プロジェクト: hayat221/maui
def test_maui_updates_neural_weight_product_when_training():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)

    z_before = maui_model.fit_transform({"d1": df1, "d2": df2})
    nwp_before_fine_tuning = maui_model.get_neural_weight_product()

    maui_model.fine_tune({"d1": df1, "d2": df2})
    z_after = maui_model.transform({"d1": df1, "d2": df2})
    nwp_after_fine_tuning = maui_model.get_neural_weight_product()

    assert not np.allclose(z_before, z_after)
    assert not np.allclose(nwp_before_fine_tuning, nwp_after_fine_tuning)
コード例 #2
0
def test_maui_saves_neural_weight_product():
    maui_model = Maui(n_hidden=[10], n_latent=2, epochs=1)
    z = maui_model.fit_transform({"d1": df1, "d2": df2})
    nwp = maui_model.get_neural_weight_product()
    assert nwp is not None
    assert hasattr(maui_model, "nwp_")

    print(maui_model.encoder.summary())

    w1 = maui_model.encoder.layers[2].get_weights()[0]
    w2 = maui_model.encoder.layers[3].get_weights()[0]

    nwp_11 = np.dot(w1[0, :], w2[:, 0])
    assert np.allclose(nwp_11, nwp.iloc[0, 0])