# tensorflow::ops::PreventGradient

`#include <array_ops.h>`

An identity op that triggers an error if a gradient is requested.

## Summary

When executed in a graph, this op outputs its input tensor as-is.

When building ops to compute gradients, the TensorFlow gradient system will return an error when trying to lookup the gradient of this op, because no gradient must ever be registered for this function. This op exists to prevent subtle bugs from silently returning unimplemented gradients in some corner cases.

Arguments:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- input: any tensor.

<br />

Optional attributes (see `https://www.tensorflow.org/versions/r2.0/api_docs/cc/struct/tensorflow/ops/prevent-gradient/attrs#structtensorflow_1_1ops_1_1_prevent_gradient_1_1_attrs`):

- message: Will be printed in the error when anyone tries to differentiate this operation.

<br />

Returns:

- `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output`: the same input tensor.

<br />

| ### Constructors and Destructors ||
|---|---|
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a0b9966e0dc996fe02edcdfc60584d033(const ::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input)` ||
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1ae19edcd4e91e9dc4bc39684dfd8cfa74(const ::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, ::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, const https://www.tensorflow.org/versions/r2.0/api_docs/cc/struct/tensorflow/ops/prevent-gradient/attrs#structtensorflow_1_1ops_1_1_prevent_gradient_1_1_attrs & attrs)` ||

| ### Public attributes ||
|---|---|
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a9b6a878872406f077395172368112563` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a4c8f001d1b1f87090e63ed718977d582` | `::https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output` |

| ### Public functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a039d4498a7fd50b84e4246f6adab399e() const ` | `::tensorflow::Node *` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a20ebe0054ff4d6f2d7bb35242547bb7b() const ` | ` `` ` |
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a2e068c7e108d2325da28edbfd997cd02() const ` | ` `` ` |

| ### Public static functions ||
|---|---|
| `https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient_1a5e4b110d0c0f8f247fd80301b88df40d(StringPiece x)` | `https://www.tensorflow.org/versions/r2.0/api_docs/cc/struct/tensorflow/ops/prevent-gradient/attrs#structtensorflow_1_1ops_1_1_prevent_gradient_1_1_attrs` |

| ### Structs ||
|---|---|
| [tensorflow::ops::PreventGradient::Attrs](https://www.tensorflow.org/versions/r2.0/api_docs/cc/struct/tensorflow/ops/prevent-gradient/attrs) | Optional attribute setters for [PreventGradient](https://www.tensorflow.org/versions/r2.0/api_docs/cc/class/tensorflow/ops/prevent-gradient#classtensorflow_1_1ops_1_1_prevent_gradient). |

## Public attributes

### operation

```
Operation operation
```

### output

```
::tensorflow::Output output
```

## Public functions

### PreventGradient

```
 PreventGradient(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input
)
```

### PreventGradient

```
 PreventGradient(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  const PreventGradient::Attrs & attrs
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```

## Public static functions

### Message

```
Attrs Message(
  StringPiece x
)
```