# 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:

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) A new PondTensor with other added. PondTensor
dot(other)[source]

Alias for matmul()

Returns: A new PondTensor PondTensor
expand_dims(axis=None)[source]
See: tf.expand_dims A new PondTensor PondTensor
matmul(other)[source]

MatMul this tensor with other. This will perform matrix multiplication, rather than elementwise like mul()

Parameters: other (PondTensor) – to subtract A new PondTensor PondTensor
mul(other)[source]

Multiply this tensor with other

Parameters: other (PondTensor) – to multiply A new PondTensor PondTensor
negative() → tf_encrypted.protocol.pond.pond.PondTensor[source]
See: tf.negative PondTensor A new tensor with numerical negative value element-wise computed.
reduce_max(axis: int) → tf_encrypted.protocol.pond.pond.PondTensor[source]
See: tf.reduce_max axis (int) – The axis to take the max along PondTensor A new pond tensor with the max value from each axis.
reduce_sum(axis=None, keepdims=None)[source]

Like tensorflow.reduce_sum()

Parameters: axis (int) – The axis to reduce along keepdims (bool) – If true, retains reduced dimensions with length 1. A new PondTensor PondTensor
reshape(shape: List[int]) → tf_encrypted.protocol.pond.pond.PondTensor[source]
See: tf.reshape shape (List[int]) – The new shape of the tensor. PondTensor A new tensor with the contents of this tensor, but with the new specified shape.
shape
Return type: List[int] The shape of this tensor.
square()[source]

Square this tensor.

Returns: A new PondTensor PondTensor
sub(other)[source]

Subtract other from this tensor.

Parameters: other (PondTensor) – to subtract A new PondTensor PondTensor
sum(axis=None, keepdims=None)[source]
transpose(perm=None)[source]

Transpose this tensor.

See tensorflow.transpose()

Parameters: List[int] – A permutation of the dimensions of this tensor. A new PondTensor PondTensor
truncate()[source]

Truncate this tensor.

TODO

Returns: A new PondTensor PondTensor