From d36b5e51b41fb0158b07f7220e80f082399118c4 Mon Sep 17 00:00:00 2001 From: K Pranit Abhinav Date: Fri, 4 Nov 2022 12:23:55 +0530 Subject: [PATCH 1/2] get layer result op added --- ravpy/distributed/op_functions/dl_ops.py | 7 ++++++- ravpy/strings.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ravpy/distributed/op_functions/dl_ops.py b/ravpy/distributed/op_functions/dl_ops.py index 92c3dc2..f026d8c 100644 --- a/ravpy/distributed/op_functions/dl_ops.py +++ b/ravpy/distributed/op_functions/dl_ops.py @@ -593,4 +593,9 @@ def backward_pass_flatten(accum_grad, params=None):#prev_input=None, input_layer backward_pass_output = { 'accum_grad': accum_grad.reshape(prev_shape).tolist() } - return backward_pass_output \ No newline at end of file + return backward_pass_output + + +def get_layer_result(X,params=None): + result=np.array(X['result']) + return result.tolist() \ No newline at end of file diff --git a/ravpy/strings.py b/ravpy/strings.py index 1e2b138..560f3ff 100644 --- a/ravpy/strings.py +++ b/ravpy/strings.py @@ -103,6 +103,7 @@ class Operators(object): ONE_HOT_ENCODING = "one_hot_encoding" SET_VALUE = "set_value" SQUEEZE = "squeeze" + GET_LAYER_RESULTS="get_layer_result" # Machine Learning Ops LINEAR_REGRESSION = "linear_regression" @@ -278,6 +279,7 @@ class TFJSOperators(object): 'federated_mean': Operators.FEDERATED_MEAN, 'federated_variance': Operators.FEDERATED_VARIANCE, 'federated_standard_deviation': Operators.FEDERATED_STANDARD_DEVIATION, + 'get_layer_result':Operators.GET_LAYER_RESULTS, } From d433e145a6475ca4b6dc5622eaaec001208da3f6 Mon Sep 17 00:00:00 2001 From: K Pranit Abhinav Date: Fri, 4 Nov 2022 12:36:01 +0530 Subject: [PATCH 2/2] get_layer_op added --- ravpy/distributed/compute.py | 5 ++++- ravpy/distributed/op_functions/dl_ops.py | 1 - 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ravpy/distributed/compute.py b/ravpy/distributed/compute.py index 6bb2444..ab01a36 100644 --- a/ravpy/distributed/compute.py +++ b/ravpy/distributed/compute.py @@ -38,7 +38,8 @@ def compute_locally_bm(*args, **kwargs): def compute_locally(payload, subgraph_id, graph_id): try: # print("Computing ",payload["operator"]) - # print('\n\nPAYLOAD: ',payload) + # print('\n\nPAYLOAD: ',payload['operator']) + values = [] @@ -273,6 +274,8 @@ def get_unary_result(value1, params, operator): result = forward_pass_flatten(value1, params=params) elif operator == "backward_pass_flatten": result = backward_pass_flatten(value1, params=params) + elif operator == "get_layer_result": + result = get_layer_result(value1, params=params) return result diff --git a/ravpy/distributed/op_functions/dl_ops.py b/ravpy/distributed/op_functions/dl_ops.py index f026d8c..784c494 100644 --- a/ravpy/distributed/op_functions/dl_ops.py +++ b/ravpy/distributed/op_functions/dl_ops.py @@ -595,7 +595,6 @@ def backward_pass_flatten(accum_grad, params=None):#prev_input=None, input_layer } return backward_pass_output - def get_layer_result(X,params=None): result=np.array(X['result']) return result.tolist() \ No newline at end of file