# Cannot perform gradient check: Datatype is not set to double precision

**URL:** <https://community.konduit.ai/t/cannot-perform-gradient-check-datatype-is-not-set-to-double-precision/639>\
**Category:** DL4J\
**Created:** [June 21, 2020, 11:32am UTC](https://community.konduit.ai/t/cannot-perform-gradient-check-datatype-is-not-set-to-double-precision/639 "2020-06-21T11:32:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maple](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/maple/32/410_2.png) [@Maple](https://community.konduit.ai/u/Maple)\
**Post date:** [June 21, 2020, 11:32am UTC](https://community.konduit.ai/t/cannot-perform-gradient-check-datatype-is-not-set-to-double-precision/639/1 "2020-06-21T11:32:20Z")

</div>

at Ex1BasicSameDiffLayerExample.java, console says:

```auto
Exception in thread "main" java.lang.IllegalStateException: 
Cannot perform gradient check: 
Datatype is not set to double precision (is: FLOAT). 
Double precision must be used for gradient checks. Set DataTypeUtil.setDTypeForContext(DataType.DOUBLE); 
before using GradientCheckUtil

```

but in validateLayer(); it had set the DataTypes to double like this:

```auto
Nd4j.setDefaultDataTypes(DataType.DOUBLE, DataType.DOUBLE);

```

appreciate for your help.

---

<div class="post-metadata">

**Author:** ![treo](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/treo/32/47_2.png) [@treo](https://community.konduit.ai/u/treo)\
**Post date:** [June 26, 2020, 6:32am UTC](https://community.konduit.ai/t/cannot-perform-gradient-check-datatype-is-not-set-to-double-precision/639/2 "2020-06-26T06:32:38Z")

</div>

Can you tell me more about the environment you are running this in? The example runs just fine on my system.

Are you using the new examples already (see [Rework of Deeplearning4J Examples](https://community.konduit.ai/t/rework-of-deeplearning4j-examples/619))? Given that you reference an old example in [Could not find class for TF Ops: ResourceGather](https://community.konduit.ai/t/could-not-find-class-for-tf-ops-resourcegather/641), your problem might stem from something that we’ve fixed already.

---

<div class="post-metadata">

**Author:** ![Maple](https://yyz1.discourse-cdn.com/flex035/user_avatar/community.konduit.ai/maple/32/410_2.png) [@Maple](https://community.konduit.ai/u/Maple)\
**Post date:** [July 1, 2020, 12:26am UTC](https://community.konduit.ai/t/cannot-perform-gradient-check-datatype-is-not-set-to-double-precision/639/3 "2020-07-01T00:26:28Z")

</div>

I tested this example, it works. maybe i didn’t update to the newest version before.
