def aux_logits(): return mo.siso_sequential([ relu(), avg_pool2d(D([5]), D([3]), D(['VALID'])), conv2d(D([128]), D([1])), batch_normalization(), relu(), global_convolution(D([768])), batch_normalization(), relu(), flatten(), fc_layer(D([10])) ])
def intermediate_node_fn(num_inputs, filters): return mo.siso_sequential([ add(num_inputs), conv2d(D([filters]), D([3])), batch_normalization(), relu() ])
def generate(filters): return cell( lambda channels: mo.siso_sequential( [conv2d(D([channels]), D([1])), batch_normalization(), relu()]), lambda num_inputs, node_id, channels: intermediate_node_fn( num_inputs, node_id, channels, cell_ops), concat, h_connections, 5, filters)
def conv_op(filters, filter_size, stride, dilation_rate, spatial_separable): if spatial_separable: return mo.siso_sequential([ conv2d(D([filters]), D([[1, filter_size]]), D([[1, stride]])), batch_normalization(), relu(), conv2d(D([filters]), D([[filter_size, 1]]), D([[stride, 1]])), ]) else: return conv2d(D([filters]), D([filter_size]), D([stride]), D([dilation_rate]))
def intermediate_node_fn(num_inputs, node_id, filters, cell_ops): return mo.siso_sequential([ add(num_inputs), mo.siso_or( { 'conv1': lambda: conv2d(D([filters]), D([1])), 'conv3': lambda: conv2d(D([filters]), D([3])), 'max3': lambda: max_pool2d(D([3])) }, cell_ops[node_id]), batch_normalization(), relu() ])
def generate_stage(stage_num, num_nodes, filters, filter_size): h_connections = [ Bool(name='%d_in_%d_%d' % (stage_num, in_id, out_id)) for (in_id, out_id) in itertools.combinations(range(1, num_nodes + 1), 2) ] return genetic_stage( lambda: mo.siso_sequential([ conv2d(D([filters]), D([filter_size])), batch_normalization(), relu() ]), lambda num_inputs: intermediate_node_fn(num_inputs, filters), lambda num_inputs: intermediate_node_fn(num_inputs, filters), h_connections, num_nodes)
def wrap_relu_batch_norm(op): return mo.siso_sequential([relu(), op, batch_normalization()])
def stem(filters): return mo.siso_sequential( [conv2d(D([filters]), D([3])), batch_normalization()])
def stem(): return mo.siso_sequential([ conv2d(D([128]), D([3])), batch_normalization(), relu(), ])