return null;
}
private FastByIDMap<float[]> constructInitialY(FastByIDMap<float[]> previousY) {
RandomGenerator random = RandomManager.getRandom();
FastByIDMap<float[]> randomY;
if (previousY == null || previousY.isEmpty()) {
// Common case: have to start from scratch
log.info("Starting from new, random Y matrix");
randomY = new FastByIDMap<float[]>(RbyColumn.size());
} else {
int oldFeatureCount = previousY.entrySet().iterator().next().getValue().length;
if (oldFeatureCount > features) {
// Fewer features, use some dimensions from prior larger number of features as-is
log.info("Feature count has decreased to {}, projecting down previous generation's Y matrix", features);
randomY = new FastByIDMap<float[]>(previousY.size());
for (FastByIDMap.MapEntry<float[]> entry : previousY.entrySet()) {
float[] oldLargerVector = entry.getValue();
float[] newSmallerVector = new float[features];
System.arraycopy(oldLargerVector, 0, newSmallerVector, 0, newSmallerVector.length);
SimpleVectorMath.normalize(newSmallerVector);
randomY.put(entry.getKey(), newSmallerVector);
}
} else if (oldFeatureCount < features) {
log.info("Feature count has increased to {}, using previous generation's Y matrix as subspace", features);
randomY = new FastByIDMap<float[]>(previousY.size());
for (FastByIDMap.MapEntry<float[]> entry : previousY.entrySet()) {
float[] oldSmallerVector = entry.getValue();
float[] newLargerVector = new float[features];
System.arraycopy(oldSmallerVector, 0, newLargerVector, 0, oldSmallerVector.length);
// Fill in new dimensions with random values
for (int i = oldSmallerVector.length; i < newLargerVector.length; i++) {
newLargerVector[i] = (float) random.nextGaussian();
}
SimpleVectorMath.normalize(newLargerVector);
randomY.put(entry.getKey(), newLargerVector);
}