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

at Ex1BasicSameDiffLayerExample.java, console says:

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:

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

appreciate for your help.

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)? Given that you reference an old example in Could not find class for TF Ops: ResourceGather, your problem might stem from something that we’ve fixed already.

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