本文整理汇总了Java中org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood类的典型用法代码示例。如果您正苦于以下问题:Java SquareNeighbourhood类的具体用法?Java SquareNeighbourhood怎么用?Java SquareNeighbourhood使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SquareNeighbourhood类属于org.apache.commons.math3.ml.neuralnet包,在下文中一共展示了SquareNeighbourhood类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: test2x2Network2
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test
public void test2x2Network2() {
final FeatureInitializer[] initArray = { init };
final Network net = new NeuronSquareMesh2D(2, false,
2, false,
SquareNeighbourhood.MOORE,
initArray).getNetwork();
Collection<Neuron> neighbours;
// All neurons
for (long id : new long[] { 0, 1, 2, 3 }) {
neighbours = net.getNeighbours(net.getNeuron(id));
for (long nId : new long[] { 0, 1, 2, 3 }) {
if (id != nId) {
Assert.assertTrue(neighbours.contains(net.getNeuron(nId)));
}
}
}
}
示例2: test3x2CylinderNetwork2
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test
public void test3x2CylinderNetwork2() {
final FeatureInitializer[] initArray = { init };
final Network net = new NeuronSquareMesh2D(2, false,
3, true,
SquareNeighbourhood.MOORE,
initArray).getNetwork();
Collection<Neuron> neighbours;
// All neurons.
for (long id : new long[] { 0, 1, 2, 3, 4, 5 }) {
neighbours = net.getNeighbours(net.getNeuron(id));
for (long nId : new long[] { 0, 1, 2, 3, 4, 5 }) {
if (id != nId) {
Assert.assertTrue("id=" + id + " nId=" + nId,
neighbours.contains(net.getNeuron(nId)));
}
}
}
}
示例3: test3x3TorusNetwork2
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test
public void test3x3TorusNetwork2() {
final FeatureInitializer[] initArray = { init };
final Network net = new NeuronSquareMesh2D(3, true,
3, true,
SquareNeighbourhood.MOORE,
initArray).getNetwork();
Collection<Neuron> neighbours;
// All neurons.
for (long id : new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) {
neighbours = net.getNeighbours(net.getNeuron(id));
for (long nId : new long[] { 0, 1, 2, 3, 4, 5, 6, 7, 8 }) {
if (id != nId) {
Assert.assertTrue("id=" + id + " nId=" + nId,
neighbours.contains(net.getNeuron(nId)));
}
}
}
}
示例4: NeuronSquareMesh2D
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
/**
* Constructor with restricted access, solely used for deserialization.
*
* @param wrapRowDim Whether to wrap the first dimension (i.e the first
* and last neurons will be linked together).
* @param wrapColDim Whether to wrap the second dimension (i.e the first
* and last neurons will be linked together).
* @param neighbourhoodType Neighbourhood type.
* @param featuresList Arrays that will initialize the features sets of
* the network's neurons.
* @throws NumberIsTooSmallException if {@code numRows < 2} or
* {@code numCols < 2}.
*/
NeuronSquareMesh2D(boolean wrapRowDim,
boolean wrapColDim,
SquareNeighbourhood neighbourhoodType,
double[][][] featuresList) {
numberOfRows = featuresList.length;
numberOfColumns = featuresList[0].length;
if (numberOfRows < 2) {
throw new NumberIsTooSmallException(numberOfRows, 2, true);
}
if (numberOfColumns < 2) {
throw new NumberIsTooSmallException(numberOfColumns, 2, true);
}
wrapRows = wrapRowDim;
wrapColumns = wrapColDim;
neighbourhood = neighbourhoodType;
final int fLen = featuresList[0][0].length;
network = new Network(0, fLen);
identifiers = new long[numberOfRows][numberOfColumns];
// Add neurons.
for (int i = 0; i < numberOfRows; i++) {
for (int j = 0; j < numberOfColumns; j++) {
identifiers[i][j] = network.createNeuron(featuresList[i][j]);
}
}
// Add links.
createLinks();
}
示例5: SerializationProxy
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
/**
* @param wrapRows Whether the row dimension is wrapped.
* @param wrapColumns Whether the column dimension is wrapped.
* @param neighbourhood Neighbourhood type.
* @param featuresList List of neurons features.
* {@code neuronList}.
*/
SerializationProxy(boolean wrapRows,
boolean wrapColumns,
SquareNeighbourhood neighbourhood,
double[][][] featuresList) {
this.wrapRows = wrapRows;
this.wrapColumns = wrapColumns;
this.neighbourhood = neighbourhood;
this.featuresList = featuresList;
}
示例6: ChineseRingsClassifier
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
/**
* @param rings Training data.
* @param dim1 Number of rows of the SOFM.
* @param dim2 Number of columns of the SOFM.
*/
public ChineseRingsClassifier(ChineseRings rings,
int dim1,
int dim2) {
this.rings = rings;
sofm = new NeuronSquareMesh2D(dim1, false,
dim2, false,
SquareNeighbourhood.MOORE,
makeInitializers());
}
示例7: testMinimalNetworkSize1
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test(expected=NumberIsTooSmallException.class)
public void testMinimalNetworkSize1() {
final FeatureInitializer[] initArray = { init };
new NeuronSquareMesh2D(1, false,
2, false,
SquareNeighbourhood.VON_NEUMANN,
initArray);
}
示例8: testMinimalNetworkSize2
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test(expected=NumberIsTooSmallException.class)
public void testMinimalNetworkSize2() {
final FeatureInitializer[] initArray = { init };
new NeuronSquareMesh2D(2, false,
0, false,
SquareNeighbourhood.VON_NEUMANN,
initArray);
}
示例9: testGetFeaturesSize
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test
public void testGetFeaturesSize() {
final FeatureInitializer[] initArray = { init, init, init };
final Network net = new NeuronSquareMesh2D(2, false,
2, false,
SquareNeighbourhood.VON_NEUMANN,
initArray).getNetwork();
Assert.assertEquals(3, net.getFeaturesSize());
}
示例10: testSerialize
import org.apache.commons.math3.ml.neuralnet.SquareNeighbourhood; //导入依赖的package包/类
@Test
public void testSerialize()
throws IOException,
ClassNotFoundException {
final FeatureInitializer[] initArray = { init };
final NeuronSquareMesh2D out = new NeuronSquareMesh2D(4, false,
3, true,
SquareNeighbourhood.VON_NEUMANN,
initArray);
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(bos);
oos.writeObject(out);
final ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
final ObjectInputStream ois = new ObjectInputStream(bis);
final NeuronSquareMesh2D in = (NeuronSquareMesh2D) ois.readObject();
for (Neuron nOut : out.getNetwork()) {
final Neuron nIn = in.getNetwork().getNeuron(nOut.getIdentifier());
// Same values.
final double[] outF = nOut.getFeatures();
final double[] inF = nIn.getFeatures();
Assert.assertEquals(outF.length, inF.length);
for (int i = 0; i < outF.length; i++) {
Assert.assertEquals(outF[i], inF[i], 0d);
}
// Same neighbours.
final Collection<Neuron> outNeighbours = out.getNetwork().getNeighbours(nOut);
final Collection<Neuron> inNeighbours = in.getNetwork().getNeighbours(nIn);
Assert.assertEquals(outNeighbours.size(), inNeighbours.size());
for (Neuron oN : outNeighbours) {
Assert.assertTrue(inNeighbours.contains(in.getNetwork().getNeuron(oN.getIdentifier())));
}
}
}