java.lang.Object
qupath.bioimageio.spec.tensor.BaseTensor
Direct Known Subclasses:
InputTensor, OutputTensor

public abstract class BaseTensor extends Object
The basic tensor representation for inputs and outputs.
  • Field Details

    • axes

      protected Axis[] axes
  • Constructor Details

    • BaseTensor

      public BaseTensor()
  • Method Details

    • getAxes

      public Axis[] getAxes()
      Get the axes of the tensor. In the 0.4 spec, this is something like "bcxy" In the 0.5 spec, axes are defined more explicitly. Therefore, this can be a simple or complex object...
      Returns:
      a clone of the axes.
    • getDataType

      public String getDataType()
      Get the data type of the tensor. Inputs can be one of "float32", "uint8", "uint16". Outputs can be one of "float32", "float64", "uint8", "int8", "uint16", "int16", "uint32", "int32", "uint64", "int64", "bool".
      Returns:
      the data type
    • getName

      public String getName()
      Get the tensor name
      Returns:
      the name
    • getId

      public String getId()
      Get the ID of the tensor. Should be unique, though we do not enforce this on the Java side.
      Returns:
      The tensor.
    • getShape

      public Shape getShape()
      Get the shape of the tensor. Implementation in 0.4 spec is for the tensor to hold the shape of all axes as a field. In 0.5, each axis specifies its own size, possibly relative to another tensor.
      Returns:
      The shape.
    • getDataRange

      public double[] getDataRange()
      Tuple `(minimum, maximum)` specifying the allowed range of the data in this tensor. If not specified, the full data range that can be expressed in `data_type` is allowed.
      Returns:
      the data range.
    • validate

      public void validate(List<? extends BaseTensor> otherTensors)
      Validate a tensor by resolving links between tensors and other parameter settings.
      Parameters:
      otherTensors - other tensors that may be linked to by this tensor.
    • getTestTensor

      public Optional<FileDescription> getTestTensor()
      An example tensor to use for testing. Using the model with the test input tensors is expected to yield the test output tensors. Each test tensor has to be a ndarray in the numpy.lib file format, The file extension must be '.npy'. This will always be null in 0.4.x models, but shouldn't be in 0.5
      Returns:
      null
    • getSampleTensor

      public Optional<FileDescription> getSampleTensor()
      A sample tensor to illustrate a possible input/output for the model, The sample image primarily serves to inform a human user about an example use case and is typically stored as .hdf5, .png or .tiff. It has to be readable by the imageio library (numpy's `.npy` format is not supported). The image dimensionality has to match the number of axes specified in this tensor description. This will always be null in 0.4.x models, but may not be in 0.5
      Returns:
      maybe a sample tensor, maybe nothing!
    • getDataDescription

      public TensorDataDescription getDataDescription()
      get the data description object.
      Returns:
      The data description.