lombok.NonNull类的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(8.9k)|赞(0)|评价(0)|浏览(188)

本文整理了Java中lombok.NonNull类的一些代码示例,展示了NonNull类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NonNull类的具体详情如下:
包路径:lombok.NonNull
类名称:NonNull

NonNull介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-data-elasticsearch

/**
 * An {@link ReactiveElasticsearchQueryExecution} that wraps the results of the given delegate with the given result
 * processing.
 */
@RequiredArgsConstructor
final class ResultProcessingExecution implements ReactiveElasticsearchQueryExecution {
  private final @NonNull ReactiveElasticsearchQueryExecution delegate;
  private final @NonNull Converter<Object, Object> converter;
  @Override
  public Object execute(Query query, Class<?> type, String indexName, String indexType,
      @Nullable Class<?> targetType) {
    return converter.convert(delegate.execute(query, type, indexName, indexType, targetType));
  }
}

代码示例来源:origin: spring-projects/spring-data-mongodb

@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
static class ExecutableRemoveSupport<T> implements ExecutableRemove<T>, RemoveWithCollection<T> {
  @NonNull MongoTemplate template;
  @NonNull Class<T> domainType;
  Query query;
  @Nullable String collection;

代码示例来源:origin: lets-blade/blade

@Override
public Response contentType(@NonNull String contentType) {
  this.headers.put("Content-Type", contentType);
  return this;
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * This method samples value from Source array to Target, with probabilites provided in Probs argument
 *
 * @param source
 * @param probs
 * @param target
 * @return
 */
public static INDArray choice(@NonNull INDArray source, @NonNull INDArray probs, @NonNull INDArray target,
               @NonNull org.nd4j.linalg.api.rng.Random rng) {
  if (source.length() != probs.length())
    throw new ND4JIllegalStateException("Nd4j.choice() requires lengths of Source and Probs to be equal");
  return Nd4j.getExecutioner().exec(new Choice(source, probs, target), rng);
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * This op fills Z with binomial distribution over given trials with single given probability for all trials
 * @param z
 * @param trials
 * @param probability
 */
public BinomialDistribution(@NonNull INDArray z, int trials, double probability) {
  init(z, z, z, z.lengthLong());
  this.trials = trials;
  this.probability = probability;
  this.extraArgs = new Object[] {(double) this.trials, this.probability};
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * This op fills Z with binomial distribution over given trials with probability for each trial given as probabilities INDArray
 *
 * @param z
 * @param probabilities
 */
public BinomialDistributionEx(@NonNull INDArray z, @NonNull INDArray probabilities) {
  // FIXME: int cast
  this(z, (int) probabilities.length(), probabilities);
}

代码示例来源:origin: deeplearning4j/nd4j

public static INDArray tailor4d2d(@NonNull INDArray data) {
  long instances = data.size(0);
  long channels = data.size(1);
  long height = data.size(2);
  long width = data.size(3);
  INDArray in2d = Nd4j.create(channels, height * width * instances);
  long tads = data.tensorssAlongDimension(3, 2, 0);
  for (int i = 0; i < tads; i++) {
    INDArray thisTAD = data.tensorAlongDimension(i, 3, 2, 0);
    in2d.putRow(i, Nd4j.toFlattened(thisTAD));
  }
  return in2d.transposei();
}

代码示例来源:origin: deeplearning4j/nd4j

public static INDArray tailor3d2d(@NonNull INDArray data, INDArray mask) {
    if (data.size(0) != mask.size(0) || data.size(2) != mask.size(1)) {
      throw new IllegalArgumentException(
              "Invalid mask array/data combination: got data with shape [minibatch, vectorSize, timeSeriesLength] = "
  INDArray subset = Nd4j.pullRows(as2d, 1, rowsToPull); //Tensor along dimension 1 == rows
  return subset;

代码示例来源:origin: deeplearning4j/nd4j

/**
 * Atan2 operation, new INDArray instance will be returned
 * Note the order of x and y parameters is opposite to that of java.lang.Math.atan2
 *
 * @param x the abscissa coordinate
 * @param y the ordinate coordinate
 * @return the theta from point (r, theta) when converting (x,y) from to cartesian to polar coordinates
 */
public static INDArray atan2(@NonNull INDArray x, @NonNull INDArray y) {
  return Nd4j.getExecutioner()
          .execAndReturn(new OldAtan2Op(x, y, Nd4j.createUninitialized(x.shape(), x.ordering())));
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * This method does element-wise comparison for 2 equal-sized matrices, for each element that matches Condition
 *
 * @param to
 * @param from
 * @param condition
 */
public static void replaceWhere(@NonNull INDArray to, @NonNull INDArray from, @NonNull Condition condition) {
  if (!(condition instanceof BaseCondition))
    throw new UnsupportedOperationException("Only static Conditions are supported");
  if (to.lengthLong() != from.lengthLong())
    throw new IllegalStateException("Mis matched length for to and from");
  Nd4j.getExecutioner().exec(new CompareAndReplace(to, from, condition));
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * Choose from the inputs based on the given condition.
 * This returns a row vector of all elements fulfilling the
 * condition listed within the array for input.
 * The double and integer arguments are only relevant
 * for scalar operations (like when you have a scalar
 * you are trying to compare each element in your input against)
 *
 * @param input the input to filter
 * @param tArgs the double args
 * @param iArgs the integer args
 * @param condition the condition to filter based on
 * @return a row vector of the input elements that are true
 * ffor the given conditions
 */
public static INDArray chooseFrom(@NonNull  INDArray[] input, @NonNull  List<Double> tArgs, @NonNull List<Integer> iArgs, @NonNull Condition condition) {
  Choose choose = new Choose(input,iArgs,tArgs,condition);
  Nd4j.getExecutioner().exec(choose);
  int secondOutput = choose.getOutputArgument(1).getInt(0);
  if(secondOutput < 1) {
    return null;
  }
  INDArray ret =  choose.getOutputArgument(0).get(NDArrayIndex.interval(0,secondOutput));
  ret = ret.reshape(ret.length());
  return ret;
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * @param mean row vector of means
 * @param std  row vector of standard deviations
 */
public DistributionStats(@NonNull INDArray mean, @NonNull INDArray std) {
  Transforms.max(std, Nd4j.EPS_THRESHOLD, false);
  if (std.min(1) == Nd4j.scalar(Nd4j.EPS_THRESHOLD)) {
    logger.info("API_INFO: Std deviation found to be zero. Transform will round up to epsilon to avoid nans.");
  }
  this.mean = mean;
  this.std = std;
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 *
 * @param d1
 * @param d2
 * @return
 */
public static double euclideanDistance(@NonNull INDArray d1, @NonNull INDArray d2) {
  return d1.distance2(d2);
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 *
 * @param d1
 * @param d2
 * @return
 */
public static double manhattanDistance(@NonNull INDArray d1, @NonNull INDArray d2) {
  return d1.distance1(d2);
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * Meshgrid op. Returns a pair of arrays where values are broadcast on a 2d grid.<br>
 * For example, if x = [1,2,3,4] and y = [5,6,7], then:<br>
 * out[0] =<br>
 * [1,2,3,4]<br>
 * [1,2,3,4]<br>
 * [1,2,3,4]<br>
 * <br>
 * out[1] =<br>
 * [5,5,5,5]<br>
 * [6,6,6,6]<br>
 * [7,7,7,7]<br>
 * <br>
 *
 * @param x X array input
 * @param y Y array input
 * @return INDArray[] of length 2, shape [y.length, x.length]
 */
public static INDArray[] meshgrid(@NonNull INDArray x, @NonNull INDArray y){
  Preconditions.checkArgument(x.isVectorOrScalar(), "X must be a vector");
  Preconditions.checkArgument(y.isVectorOrScalar(), "Y must be a vector");
  INDArray xOut = Nd4j.createUninitialized(y.length(), x.length());
  INDArray yOut = Nd4j.createUninitialized(y.length(), x.length());
  CustomOp op = DynamicCustomOp.builder("meshgrid")
      .addInputs(x, y)
      .addOutputs(xOut, yOut)
      .build();
  Nd4j.getExecutioner().exec(op);
  return new INDArray[]{xOut, yOut};
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * Choose from the inputs based on the given condition.
 * This returns a row vector of all elements fulfilling the
 * condition listed within the array for input
 * @param input the input to filter
 * @param condition the condition to filter based on
 * @return a row vector of the input elements that are true
 * ffor the given conditions
 */
public static INDArray chooseFrom(@NonNull  INDArray[] input,@NonNull  Condition condition) {
  Choose choose = new Choose(input,condition);
  Nd4j.getExecutioner().exec(choose);
  int secondOutput = choose.getOutputArgument(1).getInt(0);
  if(secondOutput < 1) {
    return null;
  }
  return choose.getOutputArgument(0);
}

代码示例来源:origin: deeplearning4j/nd4j

public ByteBuffer asFlatBuffers(@NonNull ExecutorConfiguration configuration) {
  Nd4j.getExecutioner().commit();
  FlatBufferBuilder bufferBuilder = new FlatBufferBuilder(1024);
  val idCounter = new AtomicInteger(0);
    int array = arr.toFlatArray(bufferBuilder);
    int id = IntPair.createIntPair(bufferBuilder, idCounter.get(), 0);
      int array = arr.toFlatArray(bufferBuilder);
      int id = IntPair.createIntPair(bufferBuilder, ++idx, 0);

代码示例来源:origin: spring-projects/spring-data-mongodb

@RequiredArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE, makeFinal = true)
static class ExecutableAggregationSupport<T>
    implements AggregationWithAggregation<T>, ExecutableAggregation<T>, TerminatingAggregation<T> {
  @NonNull MongoTemplate template;
  @NonNull Class<T> domainType;
  @Nullable Aggregation aggregation;
  @Nullable String collection;

代码示例来源:origin: lets-blade/blade

/**
 * Add blade loader
 *
 * @param loader
 * @return
 */
public Blade addLoader(@NonNull BladeLoader loader) {
  this.loaders.add(loader);
  return this;
}

代码示例来源:origin: deeplearning4j/nd4j

/**
 * Cosine similarity
 *
 * @param d1 the first vector
 * @param d2 the second vector
 * @return the cosine similarities between the 2 arrays
 *
 */
public static double cosineSim(@NonNull INDArray d1, @NonNull INDArray d2) {
  return Nd4j.getExecutioner().execAndReturn(new CosineSimilarity(d1, d2, d1.length())).getFinalResult()
          .doubleValue();
}

相关文章

NonNull类方法