pub fn tensor3d_slice(
tensor: &ArrayBase<OwnedRepr<f32>, Dim<[usize; 3]>>,
index: usize,
) -> Result<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, OCRError>Expand description
Extracts a 2D slice from a 3D tensor at the specified index.
§Arguments
tensor- A reference to a 3D tensor.index- The index of the slice to extract.
§Returns
Ok(Tensor2D)- A 2D tensor slice extracted from the input tensor.Err(OCRError)- An error if the index is out of bounds.
§Examples
use oar_ocr_core::utils::tensor::{tensor3d_slice, vec_to_tensor3d};
// Create a tensor first
let data = vec![vec![vec![1.0, 2.0], vec![3.0, 4.0]]];
let tensor = vec_to_tensor3d(&data)?;
let slice = tensor3d_slice(&tensor, 0)?;