---
title: "softMaxGradient(withIncomingGradient:sourceTensor:axis:name:)"
framework: metalperformanceshadersgraph
role: symbol
role_heading: Instance Method
path: "metalperformanceshadersgraph/mpsgraph/softmaxgradient(withincominggradient:sourcetensor:axis:name:)"
---

# softMaxGradient(withIncomingGradient:sourceTensor:axis:name:)

Computes the gradient of the softmax function along the specified axis using the incoming gradient tensor.

## Declaration

```swift
func softMaxGradient(withIncomingGradient gradient: MPSGraphTensor, sourceTensor source: MPSGraphTensor, axis: Int, name: String?) -> MPSGraphTensor
```

## Parameters

- `gradient`: The incoming gradient tensor.
- `source`: The input tensor.
- `axis`: The axis along which softmax is computed.
- `name`: The name for the operation.

## Return Value

Return Value A valid MPSGraphTensor object
