PondTensor¶
PondTensor is the tensor type you will interact with most.
Generally, you will never instantiate a tensor directly, rather you create them through protocol.
pondPrivateTensor = prot.define_private_variable(np.array([1,2,3,4]))
pondPublicTensor = prot.define_private_variable(np.array([1,2,3,4]))
-
class
tf_encrypted.protocol.pond.PondTensor(prot, is_scaled)[source]¶ This class functions mostly as a convenient way of exposing operations directly on the various tensor objects, ie allowing one to write x + y instead of prot.add(x, y). Since this functionality is shared among all tensors we put it in this superclass.
This class should never be instantiated on its own. Instead you should use your chosen protocols factory methods:
x = prot.define_private_input(tf.constant(np.array([1,2,3,4]))) y = prot.define_public_input(tf.constant(np.array([4,5,6,7]))) z = x + y with config.Session() as sess: answer = z.reveal().eval(sess) print(answer) # => [5, 7, 9, 11]
-
add(other)[source]¶ Add other to this PondTensor. This can be another tensor with the same backing or a primitive.
This function returns a new PondTensor and does not modify this one.
Parameters: other (PondTensor) – a or primitive (e.g. a float) Returns: A new PondTensor with other added. Return type: PondTensor
-
matmul(other)[source]¶ MatMul this tensor with other. This will perform matrix multiplication rather than elementwise like
mul()Parameters: other (PondTensor) – to subtract Returns: A new PondTensor Return type: PondTensor
-
mul(other)[source]¶ Multiply this tensor with other
Parameters: other (PondTensor) – to multiply Returns: A new PondTensor Return type: PondTensor
-
reduce_sum(axis=None, keepdims=None)[source]¶ Like
tensorflow.reduce_sum()Parameters: Returns: A new PondTensor
Return type: PondTensor
-
sub(other)[source]¶ Subtract other from this tensor.
Parameters: other (PondTensor) – to subtract Returns: A new PondTensor Return type: PondTensor
-