コード例 #1
0
    def clone_cntk_layer(self, feature):
        """Returns a clone of the CNTK layer for per-layer forward prop validation"""
        weightsParameter = utilities.find_parameter_by_name(
            self.layer.parameters, 'W', 0)
        biasParameter = utilities.find_parameter_by_name(
            self.layer.parameters, 'b', 1)

        internalNodes = utilities.get_model_layers(self.layer.block_root)
        activationType = utilities.get_cntk_activation_op(internalNodes)

        includeBias = biasParameter is not None
        layer = Dense(self.layer.shape, activation=activationType, bias=includeBias)(feature)

        layer.parameters[0].value = weightsParameter.value
        if includeBias:
            layer.parameters[1].value = biasParameter.value
        return layer
コード例 #2
0
    def clone_cntk_layer(self, feature):
        """Returns a clone of the CNTK layer for per-layer forward prop validation"""

        nodes = utilities.get_model_layers(self.layer.block_root)
        activation = utilities.get_cntk_activation_op(nodes)

        weightsShape = self.weights_parameter.shape
        pad = self.attributes['autoPadding'][0] or (
            self.attributes['autoPadding'][1] and self.attributes['autoPadding'][2])
        bias = (self.bias_parameter is not None)

        layer = Convolution((weightsShape[2], weightsShape[3]), weightsShape[0],
                            pad=pad, activation=activation, bias=bias)(feature)

        layer.parameters[0].value = self.weights_parameter.value
        if bias:
            layer.parameters[1].value = self.bias_parameter.value
        return layer