neureka.backend.api.Result Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of neureka Show documentation
Show all versions of neureka Show documentation
A platform independent tensor library written in Java.
The newest version!
package neureka.backend.api;
import neureka.Tensor;
import neureka.autograd.ADAction;
import neureka.backend.api.fun.ADActionSupplier;
import neureka.backend.api.fun.Execution;
import neureka.common.utility.LogUtil;
/**
* An immutable wrapper for a tensor as a result of anb {@link Execution}
* as well as an {@link ADActionSupplier} for providing auto-differentiation support.
*/
public final class Result
{
private final Tensor> _tensor;
private final ADActionSupplier _agent;
public static Result of( Tensor> tensor ) {
LogUtil.nullArgCheck( tensor, "tensor", Tensor.class, "An operation may not return 'null'!" );
return new Result(tensor, null);
}
private Result(Tensor> tensor, ADActionSupplier agent ) {
_tensor = tensor;
_agent = agent;
}
public Result withADAction( ADAction action ) {
return this.withAutoDiff( (caller, call) -> ADAction.of(action) );
}
public Result withAutoDiff( ADActionSupplier agent ) {
LogUtil.nullArgCheck( agent, "agent", ADAction.class );
if ( _agent != null )
throw new IllegalArgumentException("Autograd algorithm already specified!");
return new Result( _tensor, agent );
}
public Tensor get() { return (Tensor) _tensor; }
public ADActionSupplier getAgentSupplier() { return _agent; }
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy