예제 #1
0
 @Override
 public Sample getSample(Sample s, int index) {
   if (s == null) {
     s = new Sample();
   }
   s.input = asTensor(data.charAt(index), s.input);
   s.target = asTensor(data.charAt(index + 1), s.target);
   return s;
 }
예제 #2
0
 @Override
 protected void adaptSample(Sample original, Sample adapted) {
   adapted.input = original.input.copyInto(adapted.input);
   if (adapted.target == null) {
     adapted.target = new Tensor(labels.length);
   }
   adapted.target.fill(0.0f);
   for (int i = 0; i < labelIndices.length; i++) {
     adapted.target.set(original.target.get(labelIndices[i]), i);
   }
   if (other) {
     if (TensorOps.sum(adapted.target) == 0) {
       adapted.target.set(1.0f, labels.length - 1);
     }
   }
 }