Skip to content

Dnn Input & Output

DnnInput

DnnInput class that consists of input array of Dnn.

This is a private class of softneuro, instance can not be constructed directly,users can get DnnInput instance using Dnn.get_input().

Attributes

  • tensor: A Tensor object that represents input tensor.
  • blob: A Tensor object that stores entity of tensor depending on dtype of routines. Available after Dnn.compile().
  • attrs: A Params object as the attributes of the input.

Note If blob is accessed before Dnn.compile(), Dnn.compile() is automatically called so that blob gets available.

Examples

import softneuro
from PIL import Image

# Load dnn file and compile
dnn = softneuro.Dnn('model.dnn')
dnn.compile()

# Set image data to the input
image = Image.open('image001.jpg')
input = dnn.input[0]
input.set_blob(image)

set_blob

DnnInput.set_blob(data, batch=0)

Set input blob to DnnInput.

Arguments

  • data: A tensor as an input data.
  • batch: Batch size.

DnnOutput

DnnOutput class that consists of output array of Dnn.

This is a private class of softneuro, instance can not be constructed directly,users can get DnnOutput instance using Dnn.get_output().

Attributes

  • tensor: A Tensor object that represents output tensor.
  • blob: A Tensor object that stores entity of tensor depending on dtype of routines. Available after Dnn.compile().
  • attrs: A Params object as the attributes of the output.

Note If blob is accessed before Dnn.compile(), Dnn.compile() is automatically called so that blob gets available.

Examples

# Run inference
dnn.forward()

# Get output data
output = dnn.output[0]
params = output.attrs
labels_param = params['labels']
data   = output.blob.data