The wider model
// The last conv layer cannot be widen since wider operator cannot be done over the two sides of flatten.
conv_layers = list(filter(lambda x: is_conv_layer(x), graph.layer_list))[:-1]
// The first layer cannot be widen since widen operator cannot be done over the two sides of flatten.
// The last layer is softmax, which also cannot be widen.
dense_layers = list(filter(lambda x: is_dense_layer(x), graph.layer_list))[1:-1]
After Change
Returns:
The wider model
weighted_layer_ids = graph.wide_layer_ids()
if len(weighted_layer_ids) <= 1:
target_id = weighted_layer_ids[0]
else:
target_id = weighted_layer_ids[randint(0, len(weighted_layer_ids) - 1)]
if is_conv_layer(graph.layer_list[target_id]):
n_add = randint(1, 4 * graph.layer_list[target_id].filters)
else:
n_add = randint(1, 4 * graph.layer_list[target_id].units)
graph.to_wider_model(target_id, n_add)
return graph