---
title: "oneHot(withIndicesTensor:depth:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/onehot(withindicestensor:depth:name:)"
---

# oneHot(withIndicesTensor:depth:name:)

Creates a oneHot operation and returns the result tensor.

## Declaration

```swift
func oneHot(withIndicesTensor indicesTensor: MPSGraphTensor, depth: Int, name: String?) -> MPSGraphTensor
```

## Parameters

- `indicesTensor`: Tensor of indices for on values
- `depth`: Depth of the oneHot vector along the axis
- `name`: Name for the operation

## Return Value

Return Value A valid MPSGraphTensor object.

## Discussion

Discussion Creates a tensor of rank equal to the rank of indicesTensor + 1, of type MPSDataTypeFloat32. Inserts a new axis at the minor dimension. The values at the indices in the indicesTensor will be set to 1, and all other values will be set to 0.
