def create_cell_generator(num_nodes, reduction): prefix = 'reduction' if reduction else 'normal' cell_ops = [ SP1_ops('%s_op_%d_%d' % (prefix, i // 2, i % 2), reduction) for i in range(2 * num_nodes) ] connection_hparams = [ D(list(range(i // 2 + 2)), name='%s_in_%d_%d' % (prefix, i // 2, i % 2)) for i in range(2 * num_nodes) ] def generate(filters, cell_ratio): return cell( lambda: cell_input_fn(filters), lambda in_id, node_id, op_num: intermediate_node_fn( reduction, in_id, node_id, op_num, filters, cell_ratio, cell_ops), lambda: add(2), combine_unused, num_nodes, connection_hparams) return generate
def generate_search_space(nodes_per_stage, filters_per_stage, filter_size_per_stage): search_space = [] for i in range(len(nodes_per_stage)): search_space.append( generate_stage(i, nodes_per_stage[i], filters_per_stage[i], filter_size_per_stage[i])) search_space.append(max_pool2d(D([3]), D([2]), D(['SAME']))) search_space += [ flatten(), fc_layer(D([1024])), dropout(D([.5])), fc_layer(D([10])) ] return mo.siso_sequential(search_space)
def create_cell_generator(num_nodes): h_connections = [ Bool(name='in_%d_%d' % (in_id, out_id)) for (in_id, out_id) in itertools.combinations(range(num_nodes + 2), 2) ] cell_ops = [ D(['conv1', 'conv3', 'max3'], name='node_%d' % i) for i in range(num_nodes) ] 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) return generate
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(), ])
def relu(): return activation(D(['relu']))