public ConvNet(ConvNetArgs args)
                : base(args)
            {
                var layers = keras.layers;

                // Convolution Layer with 32 filters and a kernel size of 5.
                conv1 = layers.Conv2D(32, kernel_size: 5, activation: keras.activations.Relu);

                // Max Pooling (down-sampling) with kernel size of 2 and strides of 2.
                maxpool1 = layers.MaxPooling2D(2, strides: 2);

                // Convolution Layer with 64 filters and a kernel size of 3.
                conv2 = layers.Conv2D(64, kernel_size: 3, activation: keras.activations.Relu);
                // Max Pooling (down-sampling) with kernel size of 2 and strides of 2.
                maxpool2 = layers.MaxPooling2D(2, strides: 2);

                // Flatten the data to a 1-D vector for the fully connected layer.
                flatten = layers.Flatten();

                // Fully connected layer.
                fc1 = layers.Dense(1024);
                // Apply Dropout (if is_training is False, dropout is not applied).
                dropout = layers.Dropout(rate: 0.5f);

                // Output layer, class prediction.
                output = layers.Dense(args.NumClasses);

                StackLayers(conv1, maxpool1, conv2, maxpool2, flatten, fc1, dropout, output);
            }
Пример #2
0
            public ConvNet(ConvNetArgs args)
                : base(args)
            {
                // Convolution Layer with 32 filters and a kernel size of 5.
                conv1 = Conv2D(32, kernel_size: 5, activation: tf.nn.relu);
                // Max Pooling (down-sampling) with kernel size of 2 and strides of 2.
                maxpool1 = MaxPooling2D(2, strides: 2);

                // Convolution Layer with 64 filters and a kernel size of 3.
                conv2 = Conv2D(64, kernel_size: 3, activation: tf.nn.relu);
                // Max Pooling (down-sampling) with kernel size of 2 and strides of 2.
                maxpool2 = MaxPooling2D(2, strides: 2);

                // Flatten the data to a 1-D vector for the fully connected layer.
                flatten = Flatten();

                // Fully connected layer.
                fc1 = Dense(1024);
                // Apply Dropout (if is_training is False, dropout is not applied).
                dropout = Dropout(rate: 0.5f);

                // Output layer, class prediction.
                output = Dense(args.NumClasses);
            }