Skip to content

Instantly share code, notes, and snippets.

@xwjiang2010
xwjiang2010 / tune_example.py
Last active July 30, 2021 23:04
GPU not used
# flake8: noqa
# yapf: disable
# External PyTorch tutorial (https://github.com/pytorch/tutorials/pull/1066)
# If this script fails, fix it and submit a PR to pytorch/tutorials.
# In that PR, change the main call at the bottom to
# ``main(num_samples=10, max_num_epochs=10, gpus_per_trial=0)``
# Start below here:
# -*- coding: utf-8 -*-
@xwjiang2010
xwjiang2010 / stacktrace.txt
Created August 11, 2021 00:23
test_sample.py issues on clean head
(pid=92848) 2021-08-10 14:39:51,119 ERROR function_manager.py:505 -- Failed to load actor class ImplicitFunc.
(pid=92848) Traceback (most recent call last):
(pid=92848) File "/Users/xwjiang/ray/python/ray/_private/function_manager.py", line 503, in _load_actor_class_from_gcs
(pid=92848) actor_class = pickle.loads(pickled_class)
(pid=92848) ModuleNotFoundError: No module named 'test_sample'
(pid=92848) 2021-08-10 14:39:51,121 ERROR worker.py:428 -- Exception raised in creation task: The actor died because of an error raised in its creation task, ray::ImplicitFunc.__init__() (pid=92848, ip=10.0.0.111)
(pid=92848) File "python/ray/_raylet.pyx", line 531, in ray._raylet.execute_task
(pid=92848) with ray.worker._changeproctitle(title, next_title):
(pid=92848) File "python/ray/_raylet.pyx", line 535, in ray._raylet.execute_task
(pid=92848) outputs = function_executor(*args, **kwargs)
# flake8: noqa
# yapf: disable
# External PyTorch tutorial (https://github.com/pytorch/tutorials/pull/1066)
# If this script fails, fix it and submit a PR to pytorch/tutorials.
# In that PR, change the main call at the bottom to
# ``main(num_samples=10, max_num_epochs=10, gpus_per_trial=0)``
# Start below here:
# -*- coding: utf-8 -*-
# from torch.utils.tensorboard import SummaryWriter
import ray
from ray import tune
from ray.tune import CLIReporter
from ray.tune.schedulers import ASHAScheduler
# writer = SummaryWriter()
# import threading
# l = threading.Lock()
# An unique identifier for the head node and workers of this cluster.
cluster_name: basic
# The maximum number of workers nodes to launch in addition to the head
# node. This takes precedence over min_workers. min_workers default to 0.
min_workers: 1
initial_workers: 1
max_workers: 1
autoscaling_mode: aggressive
# -*- coding: utf-8 -*-
"""
Transfer Learning for Computer Vision Tutorial
==============================================
**Author**: `Sasank Chilamkurthy <https://chsasank.github.io>`_
In this tutorial, you will learn how to train a convolutional neural network for
image classification using transfer learning. You can read more about the transfer
learning at `cs231n notes <https://cs231n.github.io/transfer-learning/>`__
@xwjiang2010
xwjiang2010 / demo.py
Last active September 16, 2021 18:30
import pandas as pd
import numpy as np
import ray
from ray import tune
from sklearn.model_selection import RandomizedSearchCV, GridSearchCV
from sklearn.metrics import roc_auc_score
from sklearn.model_selection import StratifiedKFold
from tune_sklearn import TuneSearchCV
from xgboost import XGBClassifier
from ray.tune.suggest.bohb import TuneBOHB
cluster_name: RAT-cluster
min_workers: 20
initial_workers: 20
max_workers: 20
autoscaling_mode: aggressive
idle_timeout_minutes: 20
provider:
type: aws
region: us-west-2
), 'fit_params': {}, 'scoring': {'score': make_scorer(roc_auc_score, needs_threshold=True)}, 'max_iters': 1, 'return_train_score': False, 'n_jobs': 1, 'metric_name': 'average_test_score', 'estimator_ids': [ObjectRef(ffffffffffffffffffffffffffffffffffffffff0400000003000000), ObjectRef(ffffffffffffffffffffffffffffffffffffffff0400000004000000), ObjectRef(ffffffffffffffffffffffffffffffffffffffff0400000005000000)], 'learning_rate': 0.5, 'max_depth': 7, 'min_child_weight': 12.693991211112609, 'subsample': 0.9487633561935395, 'colsample_bylevel': 0.09369483441176749, 'colsample_bytree': 0.07057168621876451, 'reg_alpha': 0.7505014124392224, 'reg_lambda': 0.12635611014433654, 'scale_pos_weight': 1}. This trial completed.
Trial _Trainable_e0b9b48e reported average_test_score=0.62 with parameters={'early_stopping': True, 'early_stop_type': <EarlyStopping.XGB: 4>, 'X_id': ObjectRef(ffffffffffffffffffffffffffffffffffffffff0400000001000000), 'y_id': ObjectRef(ffffffffffffffffffffffffffffffffffffffff0400000002000000), 'grou
Trial _Trainable_e650adce reported average_test_score=0.62 with parameters={'early_stopping': True, 'early_stop_type': <EarlyStopping.XGB: 4>, 'X_id': ObjectRef(ffffffffffffffffffffffffffffffffffffffff0300000001000000), 'y_id': ObjectRef(ffffffffffffffffffffffffffffffffffffffff0300000002000000), 'groups': None, 'cv': StratifiedKFold(n_splits=3, random_state=None, shuffle=False), 'fit_params': {}, 'scoring': {'score': make_scorer(roc_auc_score, needs_threshold=True)}, 'max_iters': 1, 'return_train_score': False, 'n_jobs': 1, 'metric_name': 'average_test_score', 'estimator_ids': [ObjectRef(ffffffffffffffffffffffffffffffffffffffff0300000003000000), ObjectRef(ffffffffffffffffffffffffffffffffffffffff0300000004000000), ObjectRef(ffffffffffffffffffffffffffffffffffffffff0300000005000000)], 'learning_rate': 0.02, 'n_estimators': 50, 'max_depth': 9, 'min_child_weight': 0.6517251422621152, 'subsample': 0.851443194454984, 'colsample_bylevel': 0.7572946541950561, 'colsample_bytree': 0.9161297067290879, 'reg_alpha': 0.0293