Ejemplo n.º 1
0
 def create_layers(self):
     self.layer_conv1, self.weights_conv1 = new_conv_layer(
         prev_layer=self.X_img,
         in_channels=self.num_channels,
         out_channels=self.num_filters1,
         filter_size=self.conv_filter_size1,
         name='conv-1')
     self.layer_conv2, self.weights_conv2 = new_conv_layer(
         prev_layer=self.layer_conv1,
         in_channels=self.num_filters1,
         out_channels=self.num_filters2,
         filter_size=self.conv_filter_size2,
         name='conv-2')
     self.flattened, self.num_features = new_flatten_layer(
         prev_layer=self.layer_conv2)
     self.fc_layer1 = new_fc_layer(prev_layer=self.flattened,
                                   num_inputs=self.num_features,
                                   num_outputs=self.fc_size,
                                   name='fc-1',
                                   relu=True)
     self.fc_layer2 = new_fc_layer(prev_layer=self.fc_layer1,
                                   num_inputs=self.fc_size,
                                   num_outputs=self.num_classes,
                                   name='fc-2')
     self.prediction = tf.nn.softmax(self.fc_layer2)
     self.y_pred_cls = tf.argmax(self.prediction, axis=1)
def configure_network1(dataset, input_dim):
    global x, y_true, num_classes

    num_features = int(input_dim)
    fc_size1 = int(1024)
    print("num_classes {} num_features {}".format(num_classes, num_features))
    layer_fc1 = new_fc_layer(input=dataset,
                             num_inputs=num_features,
                             num_outputs=fc_size1,
                             use_relu=False)

    layer_fc2 = new_fc_layer(input=layer_fc1,
                             num_inputs=fc_size1,
                             num_outputs=num_classes,
                             use_relu=False)

    y_pred = tf.nn.softmax(layer_fc2)

    print(y_pred)

    cross_entropy = tf.nn.softmax_cross_entropy_with_logits(logits=layer_fc2,
                                                            labels=y_true)

    cost = tf.reduce_mean(cross_entropy)

    return y_pred, cost
Ejemplo n.º 3
0
 def create_layers(self):
     self.layer_conv1, self.weights_conv1 = new_conv_layer(
         prev_layer=self.X_img,
         in_channels=self.num_channels,
         out_channels=self.num_filters1,
         filter_size=self.conv_filter_size1,
         name=self.name + 'conv-1')
     self.layer_conv2, self.weights_conv2 = new_conv_layer(
         prev_layer=self.layer_conv1,
         in_channels=self.num_filters1,
         out_channels=self.num_filters2,
         filter_size=self.conv_filter_size2,
         name=self.name + 'conv-2')
     self.flattened, self.num_features = new_flatten_layer(
         prev_layer=self.layer_conv2)
     self.fc_layer1 = new_fc_layer(prev_layer=self.flattened,
                                   num_inputs=self.num_features,
                                   num_outputs=self.fc_size,
                                   name=self.name + 'fc-1',
                                   relu=True)