def set_output_characteristics(self, nextLayer): """Sets the output characteristics based on the next layer""" if nextLayer: self.layer.ell_outputPaddingParameters = nextLayer.layer.ell_inputPaddingParameters self.layer.ell_outputShape = utilities.get_adjusted_shape( self.layer.output.shape, self.layer.ell_outputPaddingParameters) self.layer.ell_outputShapeMinusPadding = utilities.get_shape( self.layer.output.shape) else: # last layer self.layer.ell_outputPaddingParameters = ell.NoPadding() self.layer.ell_outputShape = utilities.get_adjusted_shape( self.layer.output.shape, ell.NoPadding()) self.layer.ell_outputShapeMinusPadding = self.layer.ell_outputShape
def get_predictor(self, layer): ell_layers = [] # remove output_padding from because CNTK doesn't have output padding. layer.layer.ell_outputPaddingParameters = ell.neural.PaddingParameters( ell.neural.PaddingScheme.zeros, 0) layer.layer.ell_outputShape = cntk_utilities.get_adjusted_shape( layer.layer.output.shape, layer.layer.ell_outputPaddingParameters) layer.process(ell_layers) # Create an ELL neural network predictor from the relevant CNTK layers return ell.neural.NeuralNetworkPredictor(ell_layers)
def __init__(self, layer): self.layer = layer self.layer.ell_inputPaddingParameters = self.get_input_padding_parameters() self.additional_layer_text = None if not hasattr(self, 'input_shape'): if (len(self.layer.arguments) > 0 and len(self.layer.arguments[0].shape) > 0): self.input_shape = self.layer.arguments[0].shape # else, assume derived classes have already initialized the input shape if hasattr(self, 'input_shape'): self.layer.ell_inputShape = utilities.get_adjusted_shape( self.input_shape, self.layer.ell_inputPaddingParameters) else: raise RuntimeError( "Could not initialize input_shape") # coding error