From 89ba97bca929ebce0d7464b13a6ebc629a31f77a Mon Sep 17 00:00:00 2001 From: William Darling Date: Thu, 7 Apr 2016 17:02:37 +0200 Subject: [PATCH] added skeleton code and basic documentation for ElementDivide --- contrib/Python/cntk/graph.py | 12 ++++++++++++ contrib/Python/cntk/ops/linear.py | 17 ++++++++++++++--- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/contrib/Python/cntk/graph.py b/contrib/Python/cntk/graph.py index 95480e75c..dd468eeaf 100644 --- a/contrib/Python/cntk/graph.py +++ b/contrib/Python/cntk/graph.py @@ -93,6 +93,18 @@ class ComputationNode(object): # NOTE supported in Python 3.5 return Times(other, self) + def __div__(self, other): + if not isinstance(other, ComputationNode): + # TODO: in case of non-scalars we have to pull in a reader + other = constant(other) + return ElementDivide(self, other) + + def __rdiv__(self, other): + if not isinstance(other, ComputationNode): + # TODO: in case of non-scalars we have to pull in a reader + other = constant(other) + return ElementDivide(other, self) + def __abs__(self): return Abs(self) diff --git a/contrib/Python/cntk/ops/linear.py b/contrib/Python/cntk/ops/linear.py index 1b15482c5..3aee56b82 100644 --- a/contrib/Python/cntk/ops/linear.py +++ b/contrib/Python/cntk/ops/linear.py @@ -12,7 +12,7 @@ from cntk.ops.cntk1 import Times, Plus def plus(left_operand, right_operand, name=None): """ - tensor addition opearation + tensor addition operation Args: left_operand: Left side tensor right_operand: Right side tensor @@ -25,7 +25,7 @@ def plus(left_operand, right_operand, name=None): def times(left_operand, right_operand, name=None): """ - tensor times opearation + tensor times operation Args: left_operand: Left side tensor right_operand: Right side tensor @@ -36,4 +36,15 @@ def times(left_operand, right_operand, name=None): return Times(left_operand, right_operand, var_name = name) - +def element_divide(left_operand, right_operand, name=None): + """ + element-wise division operation + Args: + left_operand: Left side tensor + right_operand: Right side tensor + var_name: the name of the node in the network + Returns: + ElementDivide node + """ + + return ElementDivide(left_operand, right_operand, var_name = name) \ No newline at end of file