Skip to content

Commit d451e31

Browse files
committed
updated grph
1 parent 326a72e commit d451e31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3070
-67
lines changed

.idea/workspace.xml

Lines changed: 30 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/dkeras_design.png

43.3 KB

assets/inference_comparison.png

-24.2 KB

assets/profile.png

74 KB

dkeras/dkeras.py

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import os
99
import time
10-
import keras
1110

1211
import ray
1312

@@ -139,12 +138,15 @@ def make_model():
139138
else:
140139
time.sleep(1e-3)
141140

142-
def predict(self, data, distributed=True, stop_ray=False):
141+
def predict(self, data, distributed=True, close=False):
143142
"""
143+
Run inference on a data batch, returns predictions
144144
145-
:param data:
146-
:param distributed:
147-
:return:
145+
Arguments:
146+
data: numpy array of images
147+
distributed: True for distributed inference, false for serial
148+
close: boolean value for whether to stop workers
149+
return: Predictions
148150
"""
149151
if distributed:
150152
n_data = len(data)
@@ -161,14 +163,27 @@ def predict(self, data, distributed=True, stop_ray=False):
161163
print("Completed!")
162164
else:
163165
return self.model.predict(data)
164-
if stop_ray:
165-
ray.shutdown()
166+
if close:
167+
self.close()
166168

167169
def close(self, stop_ray=False):
170+
"""
171+
Close the Ray workers for the model
172+
173+
Arguments:
174+
stop_ray: Boolean value for whether to close Ray cluster
175+
176+
return: None
177+
"""
168178
self.data_server.close.remote()
169179
if stop_ray:
170180
ray.shutdown()
171181
time.sleep(5e-2)
172182

173183
def is_ready(self):
184+
"""
185+
Wait for workers to initialize
186+
187+
:return: True
188+
"""
174189
return ray.get(self.data_server.all_ready.remote())

dkeras/servers/data_server.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111

1212
@ray.remote
1313
class DataServer(object):
14+
"""
15+
Data server for transferring data to workers
1416
15-
def __init__(self, n_workers, worker_ids):
16-
"""
17+
Arguments:
18+
n_workers: Number of workers
19+
worker_ids: List of worker IDs
20+
"""
1721

18-
:param n_workers:
19-
:param worker_ids:
20-
"""
22+
def __init__(self, n_workers, worker_ids):
2123
self.n_workers = n_workers
2224
self.id_indexes = {}
2325
self.id = 0
@@ -32,8 +34,9 @@ def __init__(self, n_workers, worker_ids):
3234

3335
def pull_results(self):
3436
"""
37+
Pull the prediction results
3538
36-
:return:
39+
:return: Numpy array with the output of the workers
3740
"""
3841
output = []
3942
for n in self.results:
@@ -45,8 +48,10 @@ def pull_results(self):
4548

4649
def close(self):
4750
"""
51+
Set the close flag to True, which will close the workers
52+
on the next worker data pull request
4853
49-
:return:
54+
:return: None
5055
"""
5156
self.closed = True
5257

dkeras/worker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
@ray.remote(num_cpus=cpus_per_worker, num_gpus=gpus_per_worker)
1515
def worker_task(weights, ds, make_model):
1616
"""
17+
Worker function loop
1718
1819
:param weights:
1920
:param ds:

docs/build/doctrees/basic.doctree

3.25 KB
Binary file not shown.

docs/build/doctrees/contact.doctree

3.48 KB
Binary file not shown.
14 Bytes
Binary file not shown.
3.21 KB
Binary file not shown.

docs/build/doctrees/design.doctree

2.4 KB
Binary file not shown.
2.22 KB
Binary file not shown.
21.1 KB
Binary file not shown.
10.7 KB
Binary file not shown.
14 Bytes
Binary file not shown.

docs/build/doctrees/index.doctree

4.94 KB
Binary file not shown.

docs/build/doctrees/install.doctree

1.81 KB
Binary file not shown.

docs/build/doctrees/model_api.doctree

4.43 KB
Binary file not shown.
14 Bytes
Binary file not shown.
3.28 KB
Binary file not shown.

docs/build/doctrees/profiling.doctree

3.58 KB
Binary file not shown.
2.21 KB
Binary file not shown.

docs/build/doctrees/why.doctree

2.01 KB
Binary file not shown.

docs/build/doctrees/worker.doctree

3.17 KB
Binary file not shown.
43.3 KB
63.8 KB

docs/build/html/_images/profile.png

74 KB
Lines changed: 16 additions & 0 deletions
Lines changed: 9 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Lines changed: 2 additions & 0 deletions
Lines changed: 5 additions & 0 deletions

docs/build/html/_sources/index.rst.txt

Lines changed: 62 additions & 4 deletions
Lines changed: 19 additions & 0 deletions
Lines changed: 1 addition & 0 deletions
Lines changed: 22 additions & 0 deletions
Lines changed: 23 additions & 0 deletions
Lines changed: 2 additions & 0 deletions

docs/build/html/_sources/why.rst.txt

Lines changed: 15 additions & 0 deletions
Lines changed: 5 additions & 0 deletions

0 commit comments

Comments
 (0)