List of usage examples for java.util.stream IntStream generate
public static IntStream generate(IntSupplier s)
From source file:Main.java
public static void main(String[] args) { IntStream.generate(() -> 0).limit(5).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { IntStream i = IntStream.generate(() -> { return (int) (Math.random() * 100); });/*from w w w.j av a 2 s.co m*/ i.limit(10).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { IntStream.generate(new IntSupplier() { public int getAsInt() { return 2; }//from w ww .j ava 2 s. c o m }).limit(5).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { // stream of 1s with Stream.generate IntStream.generate(() -> 1).limit(5).forEach(System.out::println); }
From source file:Main.java
public static void main(String[] args) { SecureRandom secureRandom = new SecureRandom(new byte[] { 1, 3, 3, 7 }); int[] randoms = IntStream.generate(secureRandom::nextInt).filter(n -> n > 0).limit(10).toArray(); System.out.println(Arrays.toString(randoms)); int[] nums = IntStream.iterate(1, n -> n * 2).limit(11).toArray(); System.out.println(Arrays.toString(nums)); }
From source file:Main.java
public static void main(String[] args) { IntSupplier fib = new IntSupplier() { private int previous = 0; private int current = 1; public int getAsInt() { int nextValue = this.previous + this.current; this.previous = this.current; this.current = nextValue; return this.previous; }/*w w w .ja v a2 s . co m*/ }; IntStream.generate(fib).limit(10).forEach(System.out::println); }
From source file:com.eventsourcing.hlc.NTPServerTimeProviderTest.java
@DataProvider(name = "delays", parallel = true) public static Iterator<Object[]> delays() { return IntStream.generate(() -> new Random().nextInt(3000)) .limit(ForkJoinPool.getCommonPoolParallelism() * 10).boxed().map(i -> new Object[] { i }) .collect(Collectors.toList()).iterator(); }
From source file:kishida.cnn.layers.FullyConnect.java
@JsonCreator public FullyConnect(@JsonProperty("name") String name, @JsonProperty("outputSize") int outputSize, @JsonProperty("weight") float[] weight, @JsonProperty("bias") float[] bias, @JsonProperty("initBias") float initBias, @JsonProperty("weightDelta") float[] weightDelta, @JsonProperty("biasDelta") float[] biasDelta, @JsonProperty("dropoutRate") float dropoutRate, @JsonProperty("activation") String activationName, @JsonProperty("activationObj") ActivationFunction activation, @JsonProperty("useGpu") boolean useGpu) { super(name);// w w w . j a va 2s . c om this.name = name; if (activation != null) { this.activation = activation; } else { try { this.activation = (ActivationFunction) FullyConnect.class .forName(ActivationFunction.class.getPackage().getName() + "." + activationName) .newInstance(); } catch (ClassNotFoundException | InstantiationException | IllegalAccessException ex) { throw new RuntimeException(ex); } } this.outputSize = outputSize; this.weight = weight; this.weightDelta = weightDelta; this.bias = bias; this.initBias = initBias; this.biasDelta = biasDelta; this.result = new float[outputSize]; this.dropout = IntStream.generate(() -> 1).limit(outputSize).toArray(); this.dropoutRate = dropoutRate; this.useGpu = useGpu; this.diffed = new float[outputSize]; }