rapidsai / cuml

cuML - RAPIDS Machine Learning Library
https://docs.rapids.ai/api/cuml/stable/
Apache License 2.0
4.28k stars 536 forks source link

[BUG] Sporadic SGD test failures #2995

Open JohnZed opened 4 years ago

JohnZed commented 4 years ago

Reproduction is very inconsistent, but occasionally we see: ```

=================================== FAILURES =================================== ____ testsgd[dataframe-log-l1-float64-invscaling] ____

dtype = <class 'numpy.float64'>, lrate = 'invscaling', penalty = 'l1' loss = 'log', datatype = 'dataframe'

@pytest.mark.parametrize('lrate', ['constant', 'invscaling', 'adaptive'])
@pytest.mark.parametrize('dtype', [np.float32, np.float64])
@pytest.mark.parametrize('penalty', ['none', 'l1', 'l2', 'elasticnet'])
@pytest.mark.parametrize('loss', ['hinge', 'log', 'squared_loss'])
@pytest.mark.parametrize('datatype', ["dataframe", "numpy"])
def test_sgd(dtype, lrate, penalty, loss, datatype):

    X, y = make_blobs(n_samples=100,
                      n_features=3,
                      centers=2,
                      random_state=0)
    X = X.astype(dtype)
    y = y.astype(dtype)

    if loss == "hinge" or loss == "squared_loss":
        y[y == 0] = -1

    X_train, X_test, y_train, y_test = train_test_split(X, y,
                                                        train_size=0.8)

    if datatype == "dataframe":
        X_train = cudf.DataFrame(X_train)
        X_test = cudf.DataFrame(X_test)
        y_train = cudf.Series(y_train)

    cu_sgd = cumlSGD(learning_rate=lrate, eta0=0.005, epochs=2000,
                     fit_intercept=True, batch_size=4096,
                     tol=0.0, penalty=penalty, loss=loss)

    cu_sgd.fit(X_train, y_train)
    cu_pred = cu_sgd.predict(X_test)

    if datatype == "dataframe":
        assert isinstance(cu_pred, cudf.Series)
        cu_pred = cu_pred.to_array()

    else:
        assert isinstance(cu_pred, np.ndarray)

    if loss == "log":
        cu_pred[cu_pred < 0.5] = 0
        cu_pred[cu_pred >= 0.5] = 1
    elif loss == "squared_loss":
        cu_pred[cu_pred < 0] = -1
        cu_pred[cu_pred >= 0] = 1

    # Adjust for squared loss (we don't need to test for high accuracy,
    # just that the loss function tended towards the expected classes.
  assert np.array_equal(cu_pred, y_test)

E assert False E + where False = <function array_equal at 0x7f85083d24c0>(array([1., 1., 0., 1., 1., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 1., 0.,\n 1., 1., 1.]), array([1., 1., 0., 1., 0., 1., 1., 1., 1., 1., 1., 0., 0., 1., 1., 1., 0.,\n 1., 1., 1.])) E + where <function array_equal at 0x7f85083d24c0> = np.array_equal

cuml/test/test_sgd.py:75: AssertionError



e.g. in this pipeline: https://gpuci.gpuopenanalytics.com/blue/rest/organizations/jenkins/pipelines/rapidsai/pipelines/gpuci/pipelines/cuml/pipelines/prb/pipelines/cuml-gpu-build/runs/15441/log/?start=0
github-actions[bot] commented 3 years ago

This issue has been marked rotten due to no recent activity in the past 90d. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed.

github-actions[bot] commented 3 years ago

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.