public List <string> Predict(TensorOld X) { X = Normalize(X); LastRawResult = Model.Predict(X); LastCodecResult = Utilities.ProbabilityToCode(LastRawResult); if (LabelCodec != null) { return(LabelCodec.Decode(LastCodecResult)); } return(LastRawResult.GetRawValues().Select(a => a.ToString()).ToList()); }
private void SetTrainingData(TensorOld trainX, TensorOld trainY, TensorOld testX, TensorOld testY) { if (Normalizer != null) { TrainX = Normalizer.Normalize(trainX); if (testX != null) { TestX = Normalizer.Normalize(testX); } } else { TrainX = trainX; TestX = testX; } if (LabelCodec != null) { TrainY = LabelCodec.Encode(trainY.GetRawValues()); if (testY != null) { TestY = LabelCodec.Encode(testY.GetRawValues()); } } else { TrainY = trainY; TestY = testY; } var shape = TrainX.Shape; shape[0] = BatchSize; xBuff = new TensorOld(shape); yBuff = new TensorOld(BatchSize, TrainY.shape[1]); sampleCount = TrainX.shape[0]; xWidth = TrainX.ElementCount / TrainX.shape[0]; yWidth = TrainY.ElementCount / TrainY.shape[0]; batchPerEpoch = trainX.shape[0] / BatchSize; if (trainX.shape[0] % BatchSize != 0) { batchPerEpoch++; } }