def create_model(self): in_tensor = x for i in range(assignments['num_conv']): in_tensor = create_inception_block(in_tensor=in_tensor) in_tensor = tf.layers.batch_normalization(in_tensor, training=training_mode) return create_conv( in_tensor=in_tensor, kernel=assignments.get('output_kernel', 5), out_features=1, activation=assignments.get('output_act', 'sigmoid'), )
def create_model(self): relu = activation_functions['relu'] sigmoid = activation_functions['sigmoid'] in_tensor = x for i in range(assignments.get('num_conv', 1)): block_features = assignments.get('block_features', 1) shortcut = bn(conv2d(in_tensor, 1, block_features)) in_tensor = relu(bn(conv2d( in_tensor=in_tensor, kernel=assignments.get('conv1_kernel', 1), output=assignments.get('conv1_features', 1), ))) in_tensor = bn(conv2d( in_tensor=in_tensor, kernel=assignments.get('conv2_kernel', 1), output=block_features, )) in_tensor = in_tensor + shortcut output_1 = relu(bn(conv2d( in_tensor=in_tensor, kernel=assignments.get('output1_kernel', 1), output=assignments.get('output1_features', 1), ))) activation = sigmoid(bn(conv2d( in_tensor=output_1, kernel=assignments.get('activation_kernel', 1), output=1, ))) return activation
def create_model(self): conv1_kernel = assignments.get('conv1_kernel', 5) conv1_output = assignments.get('conv1_output', 64) w_c1, b_c1 = create_weights(conv1_kernel, 4, conv1_output) conv1 = tf.nn.conv2d(x, w_c1, strides=[1, 1, 1, 1], padding='SAME') conv1 = tf.add(conv1, b_c1) conv1 = activation_functions[assignments.get('conv1_act', 'relu')](conv1) conv2_kernel = assignments.get('conv2_kernel', 5) w_c2, b_c2 = create_weights(conv2_kernel, conv1_output, 1) conv2 = tf.nn.conv2d(conv1, w_c2, strides=[1, 1, 1, 1], padding='SAME') conv2 = tf.add(conv2, b_c2) conv2 = activation_functions[assignments.get('conv2_act', 'sigmoid')](conv2) return conv2
def create_inception_block(in_tensor): in_features = in_tensor.get_shape()[3].value # 'conv_a' is a single 1x1 convolution conv_a1 = create_conv(in_tensor, 1, assignments.get('conv_a1_features', 16)) conv_a = conv_a1 # 'conv_b' is a 1x1 convolution followed by 3x3 convolution conv_b1 = create_conv(in_tensor, 1, assignments.get('conv_b1_features', 16)) conv_b2 = create_conv(conv_b1, 3, assignments.get('conv_b2_features', 16)) conv_b = conv_b2 # 'conv_c' is a 1x1 convolution followed by 5x5 convolution conv_c1 = create_conv(in_tensor, 1, assignments.get('conv_c1_features', 16)) conv_c2 = create_conv(conv_c1, 5, assignments.get('conv_c2_features', 16)) conv_c = conv_c2 # 'conv_d' is a 3x3 max pool followed by 1x1 convolution conv_d1 = tf.nn.max_pool( in_tensor, ksize=[1, 3, 3, 1], strides=[1, 1, 1, 1], padding='SAME', ) conv_d2 = create_conv(conv_c1, 1, assignments.get('conv_d2_features', 16)) conv_d = conv_d2 return activation_functions[assignments.get('block_act', 'relu')]( tf.concat([conv_a, conv_b, conv_c, conv_d], 3))
def create_model(self): in_tensor = x intermediate_layers = [x] for i in range(assignments.get('num_conv', 2)): in_tensor = create_inception_block(in_tensor=in_tensor) in_tensor = tf.layers.batch_normalization(in_tensor, training=training_mode) intermediate_layers.append(in_tensor) block_result = tf.concat(intermediate_layers, 3) final_conv_1 = create_conv(block_result, assignments.get('out_conv1_kernel', 11), assignments.get('out_conv1_features', 100)) final_conv_2 = create_conv(final_conv_1, assignments.get('out_conv2_kernel', 1), assignments.get('out_conv2_features', 100)) out_final = create_conv( in_tensor=final_conv_2, kernel=assignments.get('activation_kernel', 1), out_features=1, activation='sigmoid', ) return out_final