-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d12741
commit 590684a
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import umbridge | ||
import time | ||
import os | ||
|
||
class TestModel(umbridge.Model): | ||
|
||
def __init__(self): | ||
super().__init__("forward") | ||
|
||
def get_input_sizes(self, config): | ||
return [1] | ||
|
||
def get_output_sizes(self, config): | ||
return [1] | ||
|
||
def __call__(self, parameters, config): | ||
# Sleep for number of milliseconds defined in env var | ||
time.sleep(int(os.getenv("TEST_DELAY", 0)) / 1000) | ||
|
||
posterior = 2*parameters[0][0] | ||
return [[posterior]] | ||
|
||
def supports_evaluate(self): | ||
return True | ||
|
||
def gradient(self,out_wrt, in_wrt, parameters, sens, config): | ||
# Sleep for number of milliseconds defined in env var | ||
time.sleep(int(os.getenv("TEST_DELAY", 0)) / 1000) | ||
return [2*sens[0]] | ||
|
||
def supports_gradient(self): | ||
return True | ||
|
||
umbridge.serve_models([TestModel()], int(os.getenv("PORT", 4242))) |