use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class MinMaxScalerExample method createCache.
/**
*/
private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
cacheConfiguration.setName("PERSONS");
cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
persons.put(1, new DenseVector(new Serializable[] { "Mike", 42, 10000 }));
persons.put(2, new DenseVector(new Serializable[] { "John", 32, 64000 }));
persons.put(3, new DenseVector(new Serializable[] { "George", 53, 120000 }));
persons.put(4, new DenseVector(new Serializable[] { "Karl", 24, 70000 }));
return persons;
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class BinarizationExample method createCache.
/**
*/
private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
cacheConfiguration.setName("PERSONS");
cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
persons.put(1, new DenseVector(new Serializable[] { "Mike", 42, 10000 }));
persons.put(2, new DenseVector(new Serializable[] { "John", 32, 64000 }));
persons.put(3, new DenseVector(new Serializable[] { "George", 53, 120000 }));
persons.put(4, new DenseVector(new Serializable[] { "Karl", 24, 70000 }));
return persons;
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class MaxAbsScalerExample method createCache.
/**
*/
private static IgniteCache<Integer, Vector> createCache(Ignite ignite) {
CacheConfiguration<Integer, Vector> cacheConfiguration = new CacheConfiguration<>();
cacheConfiguration.setName("PERSONS");
cacheConfiguration.setAffinity(new RendezvousAffinityFunction(false, 2));
IgniteCache<Integer, Vector> persons = ignite.createCache(cacheConfiguration);
persons.put(1, new DenseVector(new Serializable[] { "Mike", 42, 10000 }));
persons.put(2, new DenseVector(new Serializable[] { "John", 32, 64000 }));
persons.put(3, new DenseVector(new Serializable[] { "George", 53, 120000 }));
persons.put(4, new DenseVector(new Serializable[] { "Karl", 24, 70000 }));
return persons;
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class MultilayerPerceptron method initLayers.
/**
* Init layers parameters with initializer.
*
* @param initializer Parameters initializer.
*/
private void initLayers(MLPInitializer initializer) {
int prevSize = architecture.inputSize();
for (int i = 1; i < architecture.layersCount(); i++) {
TransformationLayerArchitecture layerCfg = architecture.transformationLayerArchitecture(i);
int neuronsCnt = layerCfg.neuronsCount();
DenseMatrix weights = new DenseMatrix(neuronsCnt, prevSize);
initializer.initWeights(weights);
DenseVector biases = null;
if (layerCfg.hasBias()) {
biases = new DenseVector(neuronsCnt);
initializer.initBiases(biases);
}
layers.add(new MLPLayer(weights, biases));
prevSize = layerCfg.neuronsCount();
}
}
use of org.apache.ignite.ml.math.primitives.vector.impl.DenseVector in project ignite by apache.
the class MultilayerPerceptron method paramsAsVector.
/**
* Flatten this MLP parameters as vector.
*
* @param layersParams List of layers parameters.
* @return This MLP parameters as vector.
*/
private Vector paramsAsVector(List<MLPLayer> layersParams) {
int off = 0;
Vector res = new DenseVector(architecture().parametersCount());
for (MLPLayer layerParams : layersParams) {
off = writeToVector(res, layerParams.weights, off);
if (layerParams.biases != null)
off = writeToVector(res, layerParams.biases, off);
}
return res;
}
Aggregations