---
title: "ClikaRT::ops::one_hot"
sidebar_label: "one_hot"
description: "Expands an integer index tensor into a trailing one-hot dimension. indices integer indices, any shape; each value must lie in [0, num_classes). num_classes the one-hot width."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## one\_hot() {#one_hot}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`one_hot`**([`Tensor`](../Tensor.md) `indices`, `int64_t` `num_classes`)

</div>

Expands an integer index tensor into a trailing one-hot dimension.

**Parameters**

- `indices`: integer indices, any shape; each value must lie in `[0, num_classes)`.
- `num_classes`: the one-hot width.

**Throws**

- `ClikaRT::Error`: when `indices` is not an integer dtype or a value is out of range (`code_name()` carries the reason).

**Returns:** `indices.shape ++ [num_classes]`, Int64.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 2164

</div>
