cntk.contrib.crosstalkcaffe.unimodel.cntkinstance module

class ApiSetup[source]

Bases: object

Setup CNTK ops with given parameters

static batch_norm(cntk_layer, inputs)[source]
Setup batch normalization op with given parameters
Parameters:
  • cntk_layer (CntkLayersDefinition) – the layer definition of batch normalization op
  • inputs (list) – a list contains all Function or input
Returns:

instaced cntk batch normalization op

Return type:

Function()

static convolution(cntk_layer, inputs)[source]
Setup convolution op with given parameters
Parameters:
Returns:

instaced cntk convolution op

Return type:

Function()

static dense(cntk_layer, inputs)[source]
Setup dense op with given parameters
Parameters:
Returns:

instaced cntk dense op

Return type:

Function()

static dropout(cntk_layer, inputs)[source]
Setup dropout op with given parameters
Parameters:
Returns:

instaced cntk dropout op

Return type:

Function()

static lrn(cntk_layer, inputs)[source]
Setup lrn op with given parameters
Parameters:
Returns:

instaced cntk lrn op

Return type:

Function()

static plus(cntk_layer, inputs)[source]
Setup plus op with given parameters
Parameters:
Returns:

instaced cntk dense op

Return type:

Function()

static pooling(cntk_layer, inputs)[source]
Setup pooling op with given parameters
Parameters:
Returns:

instaced cntk pooling op

Return type:

Function()

static relu(cntk_layer, inputs)[source]
Setup ReLU op with given parameters
Parameters:
Returns:

instaced cntk ReLU op

Return type:

Function()

static softmax(cntk_layer, inputs)[source]
Setup softmax op with given parameters
Parameters:
Returns:

instaced cntk softmax op

Return type:

Function()

static splice(cntk_layer, inputs)[source]
Setup splice op with given parameters
Parameters:
Returns:

instaced cntk splice op

Return type:

Function()

class BlockApiSetup[source]

Bases: object

Implement some special requirement ops

static convolution(output, kernel, stride, pad, kernel_init, bias_init, group, dilation, name)[source]
Implement convolution ops
Parameters:
  • output (int) – the output channel size
  • kernel (list) – the kernel size of filter, with format [width, height]
  • stride (list) – the stride of convolution, with format [w_stride, h_stride]
  • pad (bool) – auto padding or not
  • kernel_init (np.array) – the tensor saving initialize values of filter
  • bias_init (np.array) – the tensor saving initialize values of bias
  • group (int) – the group size in the convolution
  • dilation (list) – the dilation of convolution, with format [w_dilation, h_dilation]
  • name (str) – the name of ops
Returns:

the function contains convolution ops

Return type:

as_block()

static linear(output_shape, input_shape, scale_init, bias_init, name)[source]
Implement linear ops, also known as full connection in Caffe
Parameters:
  • output_shape (tuple) – the output channel size
  • input_shape (tuple) – the input channel size
  • scale_init (np.array) – the tensor saving initialize values of scale
  • bias_init (np.array) – the tensor saving initialize values of bias
  • name (str) – the name of ops
Returns:

the function contains linear ops

Return type:

as_block()

static lrn(k, n, alpha, beta, name)[source]
Implement LRN ops
Parameters:
  • k (int) – the factor k in LRN
  • n (int) – the normalization radius
  • alpha (float) – alpha factor in LRN
  • beta (float) – beta factor in LRN
  • name (str) – the name of ops
Returns:

the function contains lrn ops

Return type:

as_block()

class CntkApiInstance(cntk_uni_model, global_conf)[source]

Bases: object

Instace CNTK ops and network

export_model()[source]
Save instanced CNTK model
Parameters:None
Returns:None
get_functions()[source]
Return the functions of CNTK network
Parameters:None
Returns:the instaced functions of CNTK
Return type:list
get_model()[source]
Get instaced CNTK model
Parameters:None
Returns:the output node of CNTK
Return type:Function()
instance_functions(cntk_sorted_layers, cntk_layers)[source]
Instace all nodes into CNTK ops
Parameters:
  • cntk_sorted_layers (list) – the list contains the name of instaced layers with traversal order
  • cntk_layers (dict) – the dict contains all layers definition
Returns:

None

instance_input(data_providers)[source]
Instace the inputs into CNTK variable
Parameters:data_providers (list) – the list contains the definition of inputs
Returns:None