Exemplo n.º 1
0
    def test_partitionModel3(self):
        """Test partitioning of a NxModel.

        After completion of the algorithm, the partitioner reconstructs the
        kernelIdMap from the synapses and axons generated during partitioning.
        An exception is thrown if the reconstructed map does not equal the
        original map.
        """

        inputShape = (73, 81, 3)
        inputLayer = NxInputLayer(inputShape)
        hiddenLayer = NxConv2D(11,
                               3,
                               strides=(2, 2),
                               padding='same',
                               validatePartitions=True)(inputLayer.input)
        hiddenLayer = NxAveragePooling2D(4,
                                         validatePartitions=True)(hiddenLayer)
        hiddenLayer = NxFlatten()(hiddenLayer)
        outputLayer = NxDense(50, validatePartitions=True)(hiddenLayer)

        model = NxModel(inputLayer.input, outputLayer)

        model.partition()

        model.clearTemp()
Exemplo n.º 2
0
    def test_partition1(self):
        """Test partitioning a single NxConv1D layer."""

        inputShape = (5, 4)
        inputLayer = NxInputLayer(inputShape)
        outputLayer = NxConv1D(2, 3, validatePartitions=True)
        model = NxModel(inputLayer.input, outputLayer(inputLayer.input))

        model.partition()

        model.clearTemp()
Exemplo n.º 3
0
    def test_partitionPooling(self):
        """Test partitioning a single pooling layer."""

        inputShape = (5, 5, 4)
        inputLayer = NxInputLayer(inputShape)
        outputLayer = NxAveragePooling2D(2, validatePartitions=True)
        model = NxModel(inputLayer.input, outputLayer(inputLayer.input))

        model.partition()

        model.clearTemp()
Exemplo n.º 4
0
    def test_partition1(self):
        """Test partitioning a single fully-connected layer."""

        inputShape = (3, 3, 2)
        inputLayer = NxInputLayer(inputShape)
        flattenLayer = NxFlatten()(inputLayer.input)
        outputLayer = NxDense(10, validatePartitions=True)
        model = NxModel(inputLayer.input, outputLayer(flattenLayer))

        model.partition()

        model.clearTemp()
Exemplo n.º 5
0
    def test_partition2(self):
        """Test partitioning two fully-connected layers."""

        inputShape = (40, 32, 2)
        inputLayer = NxInputLayer(inputShape)
        flattenLayer = NxFlatten()(inputLayer.input)
        hiddenLayer = NxDense(100, validatePartitions=True)
        outputLayer = NxDense(10, validatePartitions=True)
        model = NxModel(inputLayer.input,
                        outputLayer(hiddenLayer(flattenLayer)))

        model.partition()

        model.clearTemp()
Exemplo n.º 6
0
    def test_partition2(self):
        """Test partitioning two NxConv1D layers."""

        inputShape = (500, 4)
        inputLayer = NxInputLayer(inputShape)
        hiddenLayer = NxConv1D(20,
                               3,
                               strides=2,
                               padding='same',
                               validatePartitions=True)
        outputLayer = NxConv1D(10, 2, padding='same', validatePartitions=True)
        model = NxModel(inputLayer.input,
                        outputLayer(hiddenLayer(inputLayer.input)))

        model.partition()

        model.clearTemp()
Exemplo n.º 7
0
    def test_partitionPooling2(self):
        """Test partitioning two pooling layers."""

        inputShape = (30, 40, 4)
        inputLayer = NxInputLayer(inputShape)
        hiddenLayer = NxAveragePooling2D(2,
                                         padding='same',
                                         validatePartitions=True)
        outputLayer = NxAveragePooling2D(3,
                                         strides=(1, 1),
                                         validatePartitions=True)
        model = NxModel(inputLayer.input,
                        outputLayer(hiddenLayer(inputLayer.input)))

        model.partition()

        model.clearTemp()
Exemplo n.º 8
0
    def test_partition2(self):
        """Test partitioning two DepthwiseConv2D layers."""

        inputShape = (50, 20, 4)
        inputLayer = NxInputLayer(inputShape)
        hiddenLayer = NxDepthwiseConv2D(3,
                                        strides=(2, 2),
                                        padding='same',
                                        validatePartitions=True)
        outputLayer = NxDepthwiseConv2D(2,
                                        padding='same',
                                        validatePartitions=True)
        model = NxModel(inputLayer.input,
                        outputLayer(hiddenLayer(inputLayer.input)))

        model.partition()

        model.clearTemp()
Exemplo n.º 9
0
    def test_partitionModel2(self):
        """Test partitioning of a NxModel.

        After completion of the algorithm, the partitioner reconstructs the
        kernelIdMap from the synapses and axons generated during partitioning.
        An exception is thrown if the reconstructed map does not equal the
        original map.
        """

        inputShape = (2, 2, 128)
        inputLayer = NxInputLayer(inputShape)
        hiddenLayer = NxConv2D(128, 2, padding='same', validatePartitions=True)
        hiddenLayer.exclusionCriteria.maxNumCompartments /= 4
        outputLayer = NxConv2D(256, 3, padding='same', validatePartitions=True)
        outputLayer.exclusionCriteria.maxNumCompartments /= 4

        model = NxModel(inputLayer.input,
                        outputLayer(hiddenLayer(inputLayer.input)))

        model.partition()

        model.clearTemp()
Exemplo n.º 10
0
    def test_partitionModel4(self):
        """Test partitioning of a NxModel.

        After completion of the algorithm, the partitioner reconstructs the
        kernelIdMap from the synapses and axons generated during partitioning.
        An exception is thrown if the reconstructed map does not equal the
        original map.
        """

        inputShape = (15, 15, 3)
        inputLayer = NxInputLayer(inputShape)
        outputLayer = NxConv2D(3,
                               3,
                               strides=(2, 2),
                               padding='same',
                               validatePartitions=True)(inputLayer.input)

        model = NxModel(inputLayer.input,
                        outputLayer,
                        numCandidatesToCompute=10)

        model.partition()

        model.clearTemp()