code: public SDVariable getGradient() {
          Preconditions.checkState(dataType().isFPType(), "Cannot get gradient of %s variable \"%s\": only floating" +
                  " point variables have gradients", getVarName(), dataType());
          return sameDiff.getGradForVariable(getVarName());
      }
docs: The gradient variable is the variable that represents the derivative of the loss function with respect
  to the output of this variable. I.e., if this variable is X and loss function is L, then gradient() returns the
  variable representing dL/dX<br>
  Note that only floating point variables can have gradients.<br>
  Note also that a gradient may not yet be defined, and/or if no loss function variables have been set.<br>
  You can set the loss function variables using {@link SameDiff#setLossVariables(String...)} and then create the
  gradient functions using {@link SameDiff#createGradFunction()}. Alternatively, the gradient function will be
  created automatically when training is performed.