automl / Auto-PyTorch

Automatic architecture search and hyperparameter optimization for PyTorch
Apache License 2.0
2.37k stars 287 forks source link

Error from example code #76

Closed iksooman closed 3 years ago

iksooman commented 3 years ago

Hello,

I have tried the example code on the GitHub page

from autoPyTorch import AutoNetClassification

# data and metric imports
import sklearn.model_selection
import sklearn.datasets
import sklearn.metrics
X, y = sklearn.datasets.load_digits(return_X_y=True)
X_train, X_test, y_train, y_test = \
        sklearn.model_selection.train_test_split(X, y, random_state=1)

# running Auto-PyTorch
autoPyTorch = AutoNetClassification("tiny_cs",  # config preset
                                    log_level='info',
                                    max_runtime=300,
                                    min_budget=30,
                                    max_budget=90)

autoPyTorch.fit(X_train, y_train, validation_split=0.3)
y_pred = autoPyTorch.predict(X_test)

print("Accuracy score", sklearn.metrics.accuracy_score(y_test, y_pred))

When running the code, I get the following error:

16:15:39 Start Refitting
16:15:39 [AutoNet] CV split 0 of 1
16:15:39 Reduced initial budget 29.954998016357422 to cv budget 29.954998016357422 compensate for 0.0
Traceback (most recent call last):
  File "C:/Users/admin/PycharmProjects/autopytorch_proj/main.py", line 16, in <module>
    autoPyTorch_t.fit(X_train, y_train, validation_split=0.2)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\core\api.py", line 156, in fit
    self.refit(X_train, Y_train, X_valid, Y_valid)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\core\api.py", line 202, in refit
    X_train=X_train, Y_train=Y_train, X_valid=X_valid, Y_valid=Y_valid)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\base\pipeline.py", line 60, in fit_pipeline
    return self.root.fit_traverse(**kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\base\node.py", line 115, in fit_traverse
    node.fit_output = node.fit(**required_kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\nodes\optimization_algorithm.py", line 103, in fit
    optimize_start_time=time.time(), refit=True, hyperparameter_config_id=None, dataset_info=dataset_info)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\base\pipeline.py", line 60, in fit_pipeline
    return self.root.fit_traverse(**kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\base\node.py", line 115, in fit_traverse
    node.fit_output = node.fit(**required_kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\nodes\cross_validation.py", line 109, in fit
    result = self.sub_pipeline.fit_pipeline(X=X, Y=Y, **sub_pipeline_kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\base\pipeline.py", line 60, in fit_pipeline
    return self.root.fit_traverse(**kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\base\node.py", line 115, in fit_traverse
    node.fit_output = node.fit(**required_kwargs)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\pipeline\nodes\preprocessor_selector.py", line 28, in fit
    preprocessor.fit(X[train_indices], Y[train_indices])
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\autopytorch-0.0.2-py3.7.egg\autoPyTorch\components\preprocessing\feature_preprocessing\truncated_svd.py", line 23, in fit
    self.preprocessor.fit(X, Y)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\sklearn\decomposition\_truncated_svd.py", line 143, in fit
    self.fit_transform(X)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\sklearn\decomposition\_truncated_svd.py", line 180, in fit_transform
    random_state=random_state)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\sklearn\utils\extmath.py", line 354, in randomized_svd
    Uhat, s, V = linalg.svd(B, full_matrices=False)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\scipy\linalg\decomp_svd.py", line 106, in svd
    a1 = _asarray_validated(a, check_finite=check_finite)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\scipy\_lib\_util.py", line 272, in _asarray_validated
    a = toarray(a)
  File "C:\Users\admin\iCloudDrive\Auto-PyTorch\autoPyTorch\lib\site-packages\numpy\lib\function_base.py", line 486, in asarray_chkfinite
    "array must not contain infs or NaNs")
ValueError: array must not contain infs or NaNs

Process finished with exit code 1

Could you give me some advice?

ravinkohli commented 3 years ago

Hey, thanks for this question. Actually, we have been working on a new version of autopytorch that is available on the branch `development, for docs, see this. Now we feel it's ready for people to test their workflows with this version.

So I suggest you to try out your data with the development version. For an example on how to use the API, find it here

Feel free to ask any questions about the implementation here. And if you feel the issue is resolved, kindly close it.

iksooman commented 3 years ago

Thank you for the answer.