예제 #1
0
        public void TestNoInsertion2()
        {
            SplitLayerTest test     = new SplitLayerTest();
            string         strInput =
                "name: 'TestNetwork' " +
                "layer { " +
                "  name: 'data' " +
                "  type: 'Data' " +
                "  top: 'data' " +
                "  top: 'label' " +
                "} " +
                "layer { " +
                "  name: 'data_split' " +
                "  type: 'Split' " +
                "  bottom: 'data' " +
                "  top: 'data_split_0' " +
                "  top: 'data_split_1' " +
                "} " +
                "layer { " +
                "  name: 'innerprod1' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data_split_0' " +
                "  top: 'innerprod1' " +
                "} " +
                "layer { " +
                "  name: 'innerprod2' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data_split_1' " +
                "  top: 'innerprod2' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'EuclideanLoss' " +
                "  bottom: 'innerprod1' " +
                "  bottom: 'innerprod2' " +
                "} ";

            try
            {
                foreach (ISplitLayerTest t in test.Tests)
                {
                    t.RunInsertionTest(strInput, strInput);
                }
            }
            finally
            {
                test.Dispose();
            }
        }
예제 #2
0
        public void TestGradient()
        {
            SplitLayerTest test = new SplitLayerTest();

            try
            {
                foreach (ISplitLayerTest t in test.Tests)
                {
                    t.TestGradient();
                }
            }
            finally
            {
                test.Dispose();
            }
        }
예제 #3
0
        public void TestNoInsertionWithInPlace()
        {
            SplitLayerTest test     = new SplitLayerTest();
            string         strInput =
                "name: 'TestNetwork' " +
                "layer { " +
                "  name: 'data' " +
                "  type: 'Data' " +
                "  top: 'data' " +
                "  top: 'label' " +
                "} " +
                "layer { " +
                "  name: 'innerprod' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data' " +
                "  top: 'innerprod' " +
                "} " +
                "layer { " +
                "  name: 'relu' " +
                "  type: 'ReLU' " +
                "  bottom: 'innerprod' " +
                "  top: 'innerprod' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'SoftmaxWithLoss' " +
                "  bottom: 'innerprod' " +
                "  bottom: 'label' " +
                "} ";

            try
            {
                foreach (ISplitLayerTest t in test.Tests)
                {
                    t.RunInsertionTest(strInput, strInput);
                }
            }
            finally
            {
                test.Dispose();
            }
        }
예제 #4
0
        public void TestInputInsertion()
        {
            SplitLayerTest test     = new SplitLayerTest();
            string         strInput =
                "name: 'TestNetwork' " +
                "input: 'data' " +
                "input_dim: 10 " +
                "input_dim: 3 " +
                "input_dim: 227 " +
                "input_dim: 227 " +
                "layer { " +
                "  name: 'innerprod1' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data' " +
                "  top: 'innerprod1' " +
                "} " +
                "layer { " +
                "  name: 'innerprod2' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data' " +
                "  top: 'innerprod2' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'EuclideanLoss' " +
                "  bottom: 'innerprod1' " +
                "  bottom: 'innerprod2' " +
                "} ";
            string strExpectedOutput =
                "name: 'TestNetwork' " +
                "input: 'data' " +
                "input_dim: 10 " +
                "input_dim: 3 " +
                "input_dim: 227 " +
                "input_dim: 227 " +
                "layer { " +
                "  name: 'data_input_0_split' " +
                "  type: 'Split' " +
                "  bottom: 'data' " +
                "  top: 'data_input_0_split_0' " +
                "  top: 'data_input_0_split_1' " +
                "} " +
                "layer { " +
                "  name: 'innerprod1' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data_input_0_split_0' " +
                "  top: 'innerprod1' " +
                "} " +
                "layer { " +
                "  name: 'innerprod2' " +
                "  type: 'InnerProduct' " +
                "  bottom: 'data_input_0_split_1' " +
                "  top: 'innerprod2' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'EuclideanLoss' " +
                "  bottom: 'innerprod1' " +
                "  bottom: 'innerprod2' " +
                "} ";

            try
            {
                foreach (ISplitLayerTest t in test.Tests)
                {
                    t.RunInsertionTest(strInput, strExpectedOutput);
                }
            }
            finally
            {
                test.Dispose();
            }
        }
예제 #5
0
        public void TestLossInsertion()
        {
            SplitLayerTest test     = new SplitLayerTest();
            string         strInput =
                "name: 'UnsharedWeightsNetwork' " +
                "force_backward: true " +
                "layer { " +
                "  name: 'data' " +
                "  type: 'DummyData' " +
                "  dummy_data_param { " +
                "    num: 5 " +
                "    channels: 2 " +
                "    height: 3 " +
                "    width: 4 " +
                "    data_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "  } " +
                "  top: 'data' " +
                "} " +
                "layer { " +
                "  name: 'innerproduct1' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 10 " +
                "    bias_term: false " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 10 " +
                "    } " +
                "  } " +
                "  param { name: 'unsharedweights1' } " +
                "  bottom: 'data' " +
                "  top: 'innerproduct1' " +
                "  loss_weight: 2.5 " +
                "} " +
                "layer { " +
                "  name: 'innerproduct2' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 10 " +
                "    bias_term: false " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 10 " +
                "    } " +
                "  } " +
                "  param { name: 'unsharedweights2' } " +
                "  bottom: 'data' " +
                "  top: 'innerproduct2' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'EuclideanLoss' " +
                "  bottom: 'innerproduct1' " +
                "  bottom: 'innerproduct2' " +
                "} ";
            string strExpectedOutput =
                "name: 'UnsharedWeightsNetwork' " +
                "force_backward: true " +
                "layer { " +
                "  name: 'data' " +
                "  type: 'DummyData' " +
                "  dummy_data_param { " +
                "    num: 5 " +
                "    channels: 2 " +
                "    height: 3 " +
                "    width: 4 " +
                "    data_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "  } " +
                "  top: 'data' " +
                "} " +
                "layer { " +
                "  name: 'data_data_0_split' " +
                "  type: 'Split' " +
                "  bottom: 'data' " +
                "  top: 'data_data_0_split_0' " +
                "  top: 'data_data_0_split_1' " +
                "} " +
                "layer { " +
                "  name: 'innerproduct1' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 10 " +
                "    bias_term: false " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 10 " +
                "    } " +
                "  } " +
                "  param { name: 'unsharedweights1' } " +
                "  bottom: 'data_data_0_split_0' " +
                "  top: 'innerproduct1' " +
                "} " +
                "layer { " +
                "  name: 'innerproduct1_innerproduct1_0_split' " +
                "  type: 'Split' " +
                "  bottom: 'innerproduct1' " +
                "  top: 'innerproduct1_innerproduct1_0_split_0' " +
                "  top: 'innerproduct1_innerproduct1_0_split_1' " +
                "  loss_weight: 2.5 " +
                "  loss_weight: 0 " +
                "} " +
                "layer { " +
                "  name: 'innerproduct2' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 10 " +
                "    bias_term: false " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 10 " +
                "    } " +
                "  } " +
                "  param { name: 'unsharedweights2' } " +
                "  bottom: 'data_data_0_split_1' " +
                "  top: 'innerproduct2' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'EuclideanLoss' " +
                "  bottom: 'innerproduct1_innerproduct1_0_split_1' " +
                "  bottom: 'innerproduct2' " +
                "} ";

            try
            {
                foreach (ISplitLayerTest t in test.Tests)
                {
                    t.RunInsertionTest(strInput, strExpectedOutput);
                }
            }
            finally
            {
                test.Dispose();
            }
        }
예제 #6
0
        public void TestNoInsertionImageNet()
        {
            SplitLayerTest test     = new SplitLayerTest();
            string         strInput =
                "name: 'CaffeNet' " +
                "layer { " +
                "  name: 'data' " +
                "  type: 'Data' " +
                "  data_param { " +
                "    source: '/home/jiayq/Data/ILSVRC12/train-leveldb' " +
                "    batch_size: 256 " +
                "  } " +
                "  transform_param { " +
                "    crop_size: 227 " +
                "    mirror: true " +
                "    mean_file: '/home/jiayq/Data/ILSVRC12/image_mean.binaryproto' " +
                "  } " +
                "  top: 'data' " +
                "  top: 'label' " +
                "} " +
                "layer { " +
                "  name: 'conv1' " +
                "  type: 'Convolution' " +
                "  convolution_param { " +
                "    num_output: 96 " +
                "    kernel_size: 11 " +
                "    stride: 4 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 0. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'data' " +
                "  top: 'conv1' " +
                "} " +
                "layer { " +
                "  name: 'relu1' " +
                "  type: 'ReLU' " +
                "  bottom: 'conv1' " +
                "  top: 'conv1' " +
                "} " +
                "layer { " +
                "  name: 'pool1' " +
                "  type: 'Pooling' " +
                "  pooling_param { " +
                "    pool: MAX " +
                "    kernel_size: 3 " +
                "    stride: 2 " +
                "  } " +
                "  bottom: 'conv1' " +
                "  top: 'pool1' " +
                "} " +
                "layer { " +
                "  name: 'norm1' " +
                "  type: 'LRN' " +
                "  lrn_param { " +
                "    local_size: 5 " +
                "    alpha: 0.0001 " +
                "    beta: 0.75 " +
                "  } " +
                "  bottom: 'pool1' " +
                "  top: 'norm1' " +
                "} " +
                "layer { " +
                "  name: 'conv2' " +
                "  type: 'Convolution' " +
                "  convolution_param { " +
                "    num_output: 256 " +
                "    group: 2 " +
                "    kernel_size: 5 " +
                "    pad: 2 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 1. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'norm1' " +
                "  top: 'conv2' " +
                "} " +
                "layer { " +
                "  name: 'relu2' " +
                "  type: 'ReLU' " +
                "  bottom: 'conv2' " +
                "  top: 'conv2' " +
                "} " +
                "layer { " +
                "  name: 'pool2' " +
                "  type: 'Pooling' " +
                "  pooling_param { " +
                "    pool: MAX " +
                "    kernel_size: 3 " +
                "    stride: 2 " +
                "  } " +
                "  bottom: 'conv2' " +
                "  top: 'pool2' " +
                "} " +
                "layer { " +
                "  name: 'norm2' " +
                "  type: 'LRN' " +
                "  lrn_param { " +
                "    local_size: 5 " +
                "    alpha: 0.0001 " +
                "    beta: 0.75 " +
                "  } " +
                "  bottom: 'pool2' " +
                "  top: 'norm2' " +
                "} " +
                "layer { " +
                "  name: 'conv3' " +
                "  type: 'Convolution' " +
                "  convolution_param { " +
                "    num_output: 384 " +
                "    kernel_size: 3 " +
                "    pad: 1 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 0. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'norm2' " +
                "  top: 'conv3' " +
                "} " +
                "layer { " +
                "  name: 'relu3' " +
                "  type: 'ReLU' " +
                "  bottom: 'conv3' " +
                "  top: 'conv3' " +
                "} " +
                "layer { " +
                "  name: 'conv4' " +
                "  type: 'Convolution' " +
                "  convolution_param { " +
                "    num_output: 384 " +
                "    group: 2 " +
                "    kernel_size: 3 " +
                "    pad: 1 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 1. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'conv3' " +
                "  top: 'conv4' " +
                "} " +
                "layer { " +
                "  name: 'relu4' " +
                "  type: 'ReLU' " +
                "  bottom: 'conv4' " +
                "  top: 'conv4' " +
                "} " +
                "layer { " +
                "  name: 'conv5' " +
                "  type: 'Convolution' " +
                "  convolution_param { " +
                "    num_output: 256 " +
                "    group: 2 " +
                "    kernel_size: 3 " +
                "    pad: 1 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 1. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'conv4' " +
                "  top: 'conv5' " +
                "} " +
                "layer { " +
                "  name: 'relu5' " +
                "  type: 'ReLU' " +
                "  bottom: 'conv5' " +
                "  top: 'conv5' " +
                "} " +
                "layer { " +
                "  name: 'pool5' " +
                "  type: 'Pooling' " +
                "  pooling_param { " +
                "    kernel_size: 3 " +
                "    pool: MAX " +
                "    stride: 2 " +
                "  } " +
                "  bottom: 'conv5' " +
                "  top: 'pool5' " +
                "} " +
                "layer { " +
                "  name: 'fc6' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 4096 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.005 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 1. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'pool5' " +
                "  top: 'fc6' " +
                "} " +
                "layer { " +
                "  name: 'relu6' " +
                "  type: 'ReLU' " +
                "  bottom: 'fc6' " +
                "  top: 'fc6' " +
                "} " +
                "layer { " +
                "  name: 'drop6' " +
                "  type: 'Dropout' " +
                "  dropout_param { " +
                "    dropout_ratio: 0.5 " +
                "  } " +
                "  bottom: 'fc6' " +
                "  top: 'fc6' " +
                "} " +
                "layer { " +
                "  name: 'fc7' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 4096 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.005 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 1. " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'fc6' " +
                "  top: 'fc7' " +
                "} " +
                "layer { " +
                "  name: 'relu7' " +
                "  type: 'ReLU' " +
                "  bottom: 'fc7' " +
                "  top: 'fc7' " +
                "} " +
                "layer { " +
                "  name: 'drop7' " +
                "  type: 'Dropout' " +
                "  dropout_param { " +
                "    dropout_ratio: 0.5 " +
                "  } " +
                "  bottom: 'fc7' " +
                "  top: 'fc7' " +
                "} " +
                "layer { " +
                "  name: 'fc8' " +
                "  type: 'InnerProduct' " +
                "  inner_product_param { " +
                "    num_output: 1000 " +
                "    weight_filler { " +
                "      type: 'gaussian' " +
                "      std: 0.01 " +
                "    } " +
                "    bias_filler { " +
                "      type: 'constant' " +
                "      value: 0 " +
                "    } " +
                "  } " +
                "  param { " +
                "    lr_mult: 1 " +
                "    decay_mult: 1 " +
                "  } " +
                "  param { " +
                "    lr_mult: 2 " +
                "    decay_mult: 0 " +
                "  } " +
                "  bottom: 'fc7' " +
                "  top: 'fc8' " +
                "} " +
                "layer { " +
                "  name: 'loss' " +
                "  type: 'SoftmaxWithLoss' " +
                "  bottom: 'fc8' " +
                "  bottom: 'label' " +
                "} ";

            try
            {
                foreach (ISplitLayerTest t in test.Tests)
                {
                    t.RunInsertionTest(strInput, strInput);
                }
            }
            finally
            {
                test.Dispose();
            }
        }