Package com.yahoo.tensor.functions
Class TensorFunction<NAMETYPE extends Name>
java.lang.Object
com.yahoo.tensor.functions.TensorFunction<NAMETYPE>
- Direct Known Subclasses:
CompositeTensorFunction
,CosineSimilarity
,EuclideanDistance
,PrimitiveTensorFunction
A representation of a tensor function which is able to be translated to a set of primitive
tensor functions if necessary.
All tensor functions are immutable.
- Author:
- bratseth
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionabstract List<TensorFunction<NAMETYPE>>
Returns the function arguments of this node in the order they are appliedReturns this as a scalar function, or empty if it cannot be represented as a scalar functionfinal Tensor
evaluate()
Evaluate with no contextabstract Tensor
evaluate
(EvaluationContext<NAMETYPE> context) Evaluates this tensor.abstract int
hashCode()
Returns a hashcode computed from the data in thisabstract PrimitiveTensorFunction<NAMETYPE>
Translate this function - and all of its arguments recursively - to a tree of primitive functions only.toString()
abstract String
toString
(ToStringContext<NAMETYPE> context) Return a string representation of this context.abstract TensorType
type
(TypeContext<NAMETYPE> context) Returns the type of the tensor this produces given the input types in the contextabstract TensorFunction<NAMETYPE>
withArguments
(List<TensorFunction<NAMETYPE>> arguments) Returns a copy of this tensor function with the arguments replaced by the given list of arguments.withTransformedFunctions
(Function<ScalarFunction<NAMETYPE>, ScalarFunction<NAMETYPE>> transformer)
-
Constructor Details
-
TensorFunction
public TensorFunction()
-
-
Method Details
-
arguments
Returns the function arguments of this node in the order they are applied -
withArguments
Returns a copy of this tensor function with the arguments replaced by the given list of arguments.- Throws:
IllegalArgumentException
- if the argument list has the wrong size for this function
-
toPrimitive
Translate this function - and all of its arguments recursively - to a tree of primitive functions only.- Returns:
- a tree of primitive functions implementing this
-
evaluate
Evaluates this tensor.- Parameters:
context
- a context which must be passed to all nested functions when evaluating
-
type
Returns the type of the tensor this produces given the input types in the context- Parameters:
context
- a context which must be passed to all nexted functions when evaluating
-
evaluate
Evaluate with no context -
toString
Return a string representation of this context.- Parameters:
context
- a context which must be passed to all nested functions when requesting the string value
-
asScalarFunction
Returns this as a scalar function, or empty if it cannot be represented as a scalar function -
toString
-
hashCode
public abstract int hashCode()Returns a hashcode computed from the data in this -
withTransformedFunctions
public TensorFunction<NAMETYPE> withTransformedFunctions(Function<ScalarFunction<NAMETYPE>, ScalarFunction<NAMETYPE>> transformer)
-