mirror of
https://github.com/wassname/ray.git
synced 2026-09-12 12:51:15 +08:00
clean up imports (#230)
This commit is contained in:
committed by
Philipp Moritz
parent
191909dd93
commit
5dd411546d
@@ -1,6 +1,5 @@
|
||||
import numpy as np
|
||||
import ray
|
||||
import ray.services as services
|
||||
import os
|
||||
|
||||
import functions
|
||||
@@ -11,7 +10,7 @@ epochs = 100
|
||||
|
||||
worker_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
worker_path = os.path.join(worker_dir, "worker.py")
|
||||
services.start_ray_local(num_workers=num_workers, worker_path=worker_path)
|
||||
ray.services.start_ray_local(num_workers=num_workers, worker_path=worker_path)
|
||||
|
||||
best_params = None
|
||||
best_accuracy = 0
|
||||
|
||||
@@ -38,12 +38,12 @@ def train_cnn(params, epochs):
|
||||
sess.run(train_step, feed_dict={x: batch[0], y: batch[1], keep_prob: keep})
|
||||
if i % 100 == 0: # checks if accuracy is low enough to stop early every set number of epochs
|
||||
train_ac = accuracy.eval(feed_dict={x: batch[0], y: batch[1], keep_prob: 1.0})
|
||||
if train_ac < 0.25: # Accuracy threshold is on a application to application basis.
|
||||
if train_ac < 0.25: # Accuracy threshold is on a application to application basis.
|
||||
totalacc = accuracy.eval(feed_dict={x: mnist.validation.images, y: mnist.validation.labels, keep_prob: 1.0})
|
||||
return totalacc
|
||||
totalacc = accuracy.eval(feed_dict={x: mnist.validation.images, y: mnist.validation.labels, keep_prob: 1.0})
|
||||
return totalacc
|
||||
|
||||
return totalacc.astype("float64")
|
||||
|
||||
def cnn_setup(x, y, keep_prob, lr, stddev):
|
||||
first_hidden = 32
|
||||
second_hidden = 64
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import argparse
|
||||
import ray
|
||||
import ray.worker as worker
|
||||
|
||||
import functions
|
||||
|
||||
@@ -13,4 +12,4 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
ray.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
ray.register_module(functions)
|
||||
worker.main_loop()
|
||||
ray.worker.main_loop()
|
||||
|
||||
@@ -3,20 +3,19 @@ import boto3
|
||||
import os
|
||||
import numpy as np
|
||||
import ray
|
||||
import ray.services as services
|
||||
import ray.datasets.imagenet as imagenet
|
||||
|
||||
import functions
|
||||
|
||||
parser = argparse.ArgumentParser(description="Parse information for data loading.")
|
||||
parser.add_argument("--s3-bucket", type=str, help="Name of the bucket that contains the image data.")
|
||||
parser.add_argument("--s3-bucket", type=str, required=True, help="Name of the bucket that contains the image data.")
|
||||
parser.add_argument("--key-prefix", default="ILSVRC2012_img_train/n015", type=str, help="Prefix for files to fetch.")
|
||||
parser.add_argument("--drop-ipython", default=False, type=bool, help="Drop into IPython at the end?")
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
worker_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "worker.py")
|
||||
services.start_ray_local(num_workers=5, worker_path=worker_path)
|
||||
ray.services.start_ray_local(num_workers=5, worker_path=worker_path)
|
||||
|
||||
s3 = boto3.resource("s3")
|
||||
imagenet_bucket = s3.Bucket(args.s3_bucket)
|
||||
|
||||
@@ -5,8 +5,6 @@ import numpy as np
|
||||
import ray.datasets.imagenet
|
||||
|
||||
import ray
|
||||
import ray.services as services
|
||||
import ray.worker as worker
|
||||
import ray.array.remote as ra
|
||||
import ray.array.distributed as da
|
||||
|
||||
@@ -19,7 +17,7 @@ parser.add_argument("--worker-address", default="127.0.0.1:40001", type=str, hel
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
worker.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
ray.worker.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
|
||||
ray.register_module(ray.datasets.imagenet)
|
||||
ray.register_module(functions)
|
||||
@@ -30,4 +28,4 @@ if __name__ == "__main__":
|
||||
ray.register_module(da.random)
|
||||
ray.register_module(da.linalg)
|
||||
|
||||
worker.main_loop()
|
||||
ray.worker.main_loop()
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import argparse
|
||||
|
||||
import ray
|
||||
import ray.worker as worker
|
||||
|
||||
import ray.array.remote as ra
|
||||
import ray.array.distributed as da
|
||||
@@ -15,7 +14,7 @@ parser.add_argument("--worker-address", default="127.0.0.1:40001", type=str, hel
|
||||
|
||||
if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
worker.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
ray.worker.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
|
||||
ray.register_module(functions)
|
||||
|
||||
@@ -26,4 +25,4 @@ if __name__ == "__main__":
|
||||
ray.register_module(da.random)
|
||||
ray.register_module(da.linalg)
|
||||
|
||||
worker.main_loop()
|
||||
ray.worker.main_loop()
|
||||
|
||||
@@ -5,14 +5,13 @@ import numpy as np
|
||||
import cPickle as pickle
|
||||
import gym
|
||||
import ray
|
||||
import ray.services as services
|
||||
import os
|
||||
|
||||
import functions
|
||||
|
||||
worker_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
worker_path = os.path.join(worker_dir, "worker.py")
|
||||
services.start_ray_local(num_workers=10, worker_path=worker_path)
|
||||
ray.services.start_ray_local(num_workers=10, worker_path=worker_path)
|
||||
|
||||
# hyperparameters
|
||||
H = 200 # number of hidden layer neurons
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import argparse
|
||||
import ray
|
||||
import ray.worker as worker
|
||||
import gym
|
||||
|
||||
import functions
|
||||
@@ -14,4 +13,4 @@ if __name__ == "__main__":
|
||||
args = parser.parse_args()
|
||||
ray.connect(args.scheduler_address, args.objstore_address, args.worker_address)
|
||||
ray.register_module(functions)
|
||||
worker.main_loop()
|
||||
ray.worker.main_loop()
|
||||
|
||||
Reference in New Issue
Block a user