Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 1 | /* |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 2 | * Copyright (c) 2018-2019 ARM Limited. |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 24 | #include "arm_compute/graph.h" |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 25 | #include "support/ToolchainSupport.h" |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 26 | #include "utils/CommonGraphOptions.h" |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 27 | #include "utils/GraphUtils.h" |
| 28 | #include "utils/Utils.h" |
| 29 | |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 30 | using namespace arm_compute::utils; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 31 | using namespace arm_compute::graph::frontend; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 32 | using namespace arm_compute::graph_utils; |
| 33 | |
Georgios Pinitas | 108ab0b | 2018-09-14 18:35:11 +0100 | [diff] [blame] | 34 | /** Example demonstrating how to implement InceptionV4's network using the Compute Library's graph API */ |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 35 | class InceptionV4Example final : public Example |
| 36 | { |
| 37 | public: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 38 | InceptionV4Example() |
| 39 | : cmd_parser(), common_opts(cmd_parser), common_params(), graph(0, "InceptionV4") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 40 | { |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 41 | } |
| 42 | bool do_setup(int argc, char **argv) override |
| 43 | { |
| 44 | // Parse arguments |
| 45 | cmd_parser.parse(argc, argv); |
Georgios Pinitas | cd60a5f | 2019-08-21 17:06:54 +0100 | [diff] [blame] | 46 | cmd_parser.validate(); |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 47 | |
| 48 | // Consume common parameters |
| 49 | common_params = consume_common_graph_parameters(common_opts); |
| 50 | |
| 51 | // Return when help menu is requested |
| 52 | if(common_params.help) |
| 53 | { |
| 54 | cmd_parser.print_help(argv[0]); |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | // Checks |
Anthony Barbier | cdd68c0 | 2018-08-23 15:03:41 +0100 | [diff] [blame] | 59 | ARM_COMPUTE_EXIT_ON_MSG(arm_compute::is_data_type_quantized_asymmetric(common_params.data_type), "QASYMM8 not supported for this graph"); |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 60 | |
| 61 | // Print parameter values |
| 62 | std::cout << common_params << std::endl; |
| 63 | |
| 64 | // Get trainable parameters data path |
| 65 | std::string data_path = common_params.data_path; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 66 | |
| 67 | // Create a preprocessor object |
| 68 | std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>(); |
| 69 | |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 70 | // Create input descriptor |
| 71 | const TensorShape tensor_shape = permute_shape(TensorShape(299U, 299U, 3U, 1U), DataLayout::NCHW, common_params.data_layout); |
| 72 | TensorDescriptor input_descriptor = TensorDescriptor(tensor_shape, common_params.data_type).set_layout(common_params.data_layout); |
| 73 | |
| 74 | // Set weights trained layout |
| 75 | const DataLayout weights_layout = DataLayout::NCHW; |
| 76 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 77 | graph << common_params.target |
| 78 | << common_params.fast_math_hint |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 79 | << InputLayer(input_descriptor, get_input_accessor(common_params, std::move(preprocessor), false)) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 80 | // Conv2d_1a_3x3 |
| 81 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 82 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 83 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 84 | .set_name("Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 85 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 86 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 87 | get_random_accessor(1.f, 1.f), |
| 88 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 89 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 90 | .set_name("Conv2d_1a_3x3/BatchNorm") |
| 91 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_1a_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 92 | // Conv2d_2a_3x3 |
| 93 | << ConvolutionLayer(3U, 3U, 32U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 94 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 95 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 96 | .set_name("Conv2d_2a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 97 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"), |
| 98 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"), |
| 99 | get_random_accessor(1.f, 1.f), |
| 100 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"), |
| 101 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 102 | .set_name("Conv2d_2a_3x3/BatchNorm") |
| 103 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2a_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 104 | // Conv2d_2b_3x3 |
| 105 | << ConvolutionLayer(3U, 3U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 106 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 107 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 108 | .set_name("Conv2d_2b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 109 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"), |
| 110 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"), |
| 111 | get_random_accessor(1.f, 1.f), |
| 112 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"), |
| 113 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 114 | .set_name("Conv2d_2b_3x3/BatchNorm") |
| 115 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Conv2d_2b_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 116 | |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 117 | graph << get_mixed_3a(data_path, weights_layout).set_name("Mixed_3a/concat"); |
| 118 | graph << get_mixed_4a(data_path, weights_layout).set_name("Mixed_4a/concat"); |
| 119 | graph << get_mixed_5a(data_path, weights_layout).set_name("Mixed_5a/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 120 | // 4 inception A blocks |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 121 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5b").set_name("Mixed_5b/concat"); |
| 122 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5c").set_name("Mixed_5c/concat"); |
| 123 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5d").set_name("Mixed_5d/concat"); |
| 124 | graph << get_inceptionA_block(data_path, weights_layout, "Mixed_5e").set_name("Mixed_5e/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 125 | // reduction A block |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 126 | graph << get_reductionA_block(data_path, weights_layout).set_name("Mixed_6a/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 127 | // 7 inception B blocks |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 128 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6b").set_name("Mixed_6b/concat"); |
| 129 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6c").set_name("Mixed_6c/concat"); |
| 130 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6d").set_name("Mixed_6d/concat"); |
| 131 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6e").set_name("Mixed_6e/concat"); |
| 132 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6f").set_name("Mixed_6f/concat"); |
| 133 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6g").set_name("Mixed_6g/concat"); |
| 134 | graph << get_inceptionB_block(data_path, weights_layout, "Mixed_6h").set_name("Mixed_6h/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 135 | // reduction B block |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 136 | graph << get_reductionB_block(data_path, weights_layout).set_name("Mixed_7a/concat"); |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 137 | // 3 inception C blocks |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 138 | graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7b").set_name("Mixed_7b/concat"); |
| 139 | graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7c").set_name("Mixed_7c/concat"); |
| 140 | graph << get_inceptionC_block(data_path, weights_layout, "Mixed_7d").set_name("Mixed_7d/concat"); |
| 141 | graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)).set_name("Logits/AvgPool_1a/AvgPool") |
| 142 | << FlattenLayer().set_name("Logits/Flatten") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 143 | << FullyConnectedLayer( |
| 144 | 1001U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 145 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 146 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy")) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 147 | .set_name("Logits/MatMul") |
| 148 | << SoftmaxLayer().set_name("Logits/Predictions") |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 149 | << OutputLayer(get_output_accessor(common_params, 5)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 150 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 151 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 152 | GraphConfig config; |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 153 | config.num_threads = common_params.threads; |
| 154 | config.use_tuner = common_params.enable_tuner; |
Vidhya Sudhan Loganathan | 050471e | 2019-04-25 09:27:24 +0100 | [diff] [blame] | 155 | config.tuner_mode = common_params.tuner_mode; |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 156 | config.tuner_file = common_params.tuner_file; |
| 157 | |
Pablo Tello | db9116f | 2019-07-11 16:50:37 +0100 | [diff] [blame] | 158 | // Load the precompiled kernels from a file into the kernel library, in this way the next time they are needed |
| 159 | // compilation won't be required. |
| 160 | if(common_params.enable_cl_cache) |
| 161 | { |
| 162 | restore_program_cache_from_file(); |
| 163 | } |
| 164 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 165 | graph.finalize(common_params.target, config); |
| 166 | |
Pablo Tello | db9116f | 2019-07-11 16:50:37 +0100 | [diff] [blame] | 167 | // Save the opencl kernels to a file |
| 168 | if(common_opts.enable_cl_cache) |
| 169 | { |
| 170 | save_program_cache_to_file(); |
| 171 | } |
| 172 | |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 173 | return true; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | void do_run() override |
| 177 | { |
| 178 | graph.run(); |
| 179 | } |
| 180 | |
| 181 | private: |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 182 | CommandLineParser cmd_parser; |
| 183 | CommonGraphOptions common_opts; |
| 184 | CommonGraphParams common_params; |
| 185 | Stream graph; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 186 | |
| 187 | private: |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 188 | ConcatLayer get_mixed_3a(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 189 | { |
| 190 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_"; |
| 191 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 192 | SubStream i_a(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 193 | i_a << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_3a/Branch_0/MaxPool_0a_3x3/MaxPool"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 194 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 195 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 196 | i_b << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 197 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 198 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 199 | .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 200 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"), |
| 201 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"), |
| 202 | get_random_accessor(1.f, 1.f), |
| 203 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"), |
| 204 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 205 | .set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/BatchNorm") |
| 206 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_3a/Branch_1/Conv2d_0a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 207 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 208 | return ConcatLayer(std::move(i_a), std::move(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 209 | } |
| 210 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 211 | ConcatLayer get_mixed_4a(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 212 | { |
| 213 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_"; |
| 214 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 215 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 216 | i_a << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 217 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 218 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 219 | .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 220 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 221 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 222 | get_random_accessor(1.f, 1.f), |
| 223 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 224 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 225 | .set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 226 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 227 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 228 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 229 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 230 | .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 231 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 232 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 233 | get_random_accessor(1.f, 1.f), |
| 234 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 235 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 236 | .set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 237 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 238 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 239 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 240 | i_b << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 241 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 242 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 243 | .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 244 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 245 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 246 | get_random_accessor(1.f, 1.f), |
| 247 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 248 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 249 | .set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 250 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 251 | << ConvolutionLayer(7U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 252 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 253 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 254 | .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 255 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 256 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 257 | get_random_accessor(1.f, 1.f), |
| 258 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 259 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 260 | .set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/BatchNorm") |
| 261 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 262 | << ConvolutionLayer(1U, 7U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 263 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 264 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 265 | .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 266 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 267 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 268 | get_random_accessor(1.f, 1.f), |
| 269 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 270 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 271 | .set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/BatchNorm") |
| 272 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_0c_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 273 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 274 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 275 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 276 | .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 277 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 278 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 279 | get_random_accessor(1.f, 1.f), |
| 280 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 281 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 282 | .set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/BatchNorm") |
| 283 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_4a/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 284 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 285 | return ConcatLayer(std::move(i_a), std::move(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 286 | } |
| 287 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 288 | ConcatLayer get_mixed_5a(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 289 | { |
| 290 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_"; |
| 291 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 292 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 293 | i_a << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 294 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 295 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 296 | .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 297 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 298 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 299 | get_random_accessor(1.f, 1.f), |
| 300 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 301 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 302 | .set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 303 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_5a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 304 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 305 | SubStream i_b(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 306 | i_b << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_5a/Branch_1/MaxPool_1a_3x3/MaxPool"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 307 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 308 | return ConcatLayer(std::move(i_a), std::move(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 309 | } |
| 310 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 311 | ConcatLayer get_inceptionA_block(const std::string &data_path, DataLayout weights_layout, std::string &¶m_path) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 312 | { |
| 313 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 314 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 315 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 316 | i_a << ConvolutionLayer(1U, 1U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 317 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 318 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 319 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 320 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 321 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 322 | get_random_accessor(1.f, 1.f), |
| 323 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 324 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 325 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 326 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 327 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 328 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 329 | i_b << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 330 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 331 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 332 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 333 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 334 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 335 | get_random_accessor(1.f, 1.f), |
| 336 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 337 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 338 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 339 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 340 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 341 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 342 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 343 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 344 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 345 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 346 | get_random_accessor(1.f, 1.f), |
| 347 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 348 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 349 | .set_name(param_path + "/Branch_1/Conv2d_0b_3x3/BatchNorm") |
| 350 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 351 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 352 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 353 | i_c << ConvolutionLayer(1U, 1U, 64U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 354 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 355 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 356 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 357 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 358 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 359 | get_random_accessor(1.f, 1.f), |
| 360 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 361 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 362 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm") |
| 363 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 364 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 365 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 366 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 367 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 368 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 369 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 370 | get_random_accessor(1.f, 1.f), |
| 371 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 372 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 373 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x3/BatchNorm") |
| 374 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 375 | << ConvolutionLayer(3U, 3U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 376 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 377 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 378 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 379 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"), |
| 380 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"), |
| 381 | get_random_accessor(1.f, 1.f), |
| 382 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"), |
| 383 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 384 | .set_name(param_path + "/Branch_2/Conv2d_0c_3x3/BatchNorm") |
| 385 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 386 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 387 | SubStream i_d(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 388 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 389 | << ConvolutionLayer(1U, 1U, 96U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 390 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 391 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 392 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 393 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 394 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 395 | get_random_accessor(1.f, 1.f), |
| 396 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 397 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 398 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm") |
| 399 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 400 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 401 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 402 | } |
| 403 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 404 | ConcatLayer get_reductionA_block(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 405 | { |
| 406 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_"; |
| 407 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 408 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 409 | i_a << ConvolutionLayer(3U, 3U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 410 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 411 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 412 | .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 413 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 414 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 415 | get_random_accessor(1.f, 1.f), |
| 416 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 417 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 418 | .set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 419 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 420 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 421 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 422 | i_b << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 423 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 424 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 425 | .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 426 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 427 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 428 | get_random_accessor(1.f, 1.f), |
| 429 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 430 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 431 | .set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 432 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 433 | << ConvolutionLayer(3U, 3U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 434 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 435 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 436 | .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 437 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 438 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 439 | get_random_accessor(1.f, 1.f), |
| 440 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 441 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 442 | .set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/BatchNorm") |
| 443 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_0b_3x3/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 444 | << ConvolutionLayer(3U, 3U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 445 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 446 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 447 | .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 448 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 449 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 450 | get_random_accessor(1.f, 1.f), |
| 451 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 452 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 453 | .set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/BatchNorm") |
| 454 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_6a/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 455 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 456 | SubStream i_c(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 457 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_6a/Branch_2/MaxPool_1a_3x3/MaxPool"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 458 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 459 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 460 | } |
| 461 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 462 | ConcatLayer get_inceptionB_block(const std::string &data_path, DataLayout weights_layout, std::string &¶m_path) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 463 | { |
| 464 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 465 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 466 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 467 | i_a << ConvolutionLayer(1U, 1U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 468 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 469 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 470 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 471 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 472 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 473 | get_random_accessor(1.f, 1.f), |
| 474 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 475 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 476 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 477 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 478 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 479 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 480 | i_b << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 481 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 482 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 483 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 484 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 485 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 486 | get_random_accessor(1.f, 1.f), |
| 487 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 488 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 489 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 490 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 491 | << ConvolutionLayer(7U, 1U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 492 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 493 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 494 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 495 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 496 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 497 | get_random_accessor(1.f, 1.f), |
| 498 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 499 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 500 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x7/BatchNorm") |
| 501 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 502 | << ConvolutionLayer(1U, 7U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 503 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 504 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 505 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 506 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 507 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 508 | get_random_accessor(1.f, 1.f), |
| 509 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 510 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 511 | .set_name(param_path + "/Branch_1/Conv2d_0c_7x1/BatchNorm") |
| 512 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_7x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 513 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 514 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 515 | i_c << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 516 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 517 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 518 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 519 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 520 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 521 | get_random_accessor(1.f, 1.f), |
| 522 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 523 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 524 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm") |
| 525 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 526 | << ConvolutionLayer(1U, 7U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 527 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 528 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 529 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 530 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"), |
| 531 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"), |
| 532 | get_random_accessor(1.f, 1.f), |
| 533 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"), |
| 534 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 535 | .set_name(param_path + "/Branch_2/Conv2d_0b_7x1/BatchNorm") |
| 536 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 537 | << ConvolutionLayer(7U, 1U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 538 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 539 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 540 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 541 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"), |
| 542 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"), |
| 543 | get_random_accessor(1.f, 1.f), |
| 544 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"), |
| 545 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 546 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x7/BatchNorm") |
| 547 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 548 | << ConvolutionLayer(1U, 7U, 224U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 549 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 550 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 551 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 552 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"), |
| 553 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"), |
| 554 | get_random_accessor(1.f, 1.f), |
| 555 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"), |
| 556 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 557 | .set_name(param_path + "/Branch_2/Conv2d_0d_7x1/BatchNorm") |
| 558 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 559 | << ConvolutionLayer(7U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 560 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 561 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 562 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 563 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"), |
| 564 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"), |
| 565 | get_random_accessor(1.f, 1.f), |
| 566 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"), |
| 567 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 568 | .set_name(param_path + "/Branch_2/Conv2d_0e_1x7/BatchNorm") |
| 569 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_1x7/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 570 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 571 | SubStream i_d(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 572 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 573 | << ConvolutionLayer(1U, 1U, 128U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 574 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 575 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 576 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 577 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 578 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 579 | get_random_accessor(1.f, 1.f), |
| 580 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 581 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 582 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm") |
| 583 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 584 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 585 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 586 | } |
| 587 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 588 | ConcatLayer get_reductionB_block(const std::string &data_path, DataLayout weights_layout) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 589 | { |
| 590 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_"; |
| 591 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 592 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 593 | i_a << ConvolutionLayer(1U, 1U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 594 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 595 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 596 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 597 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 598 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 599 | get_random_accessor(1.f, 1.f), |
| 600 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 601 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 602 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 603 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 604 | << ConvolutionLayer(3U, 3U, 192U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 605 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 606 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 607 | .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 608 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 609 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 610 | get_random_accessor(1.f, 1.f), |
| 611 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 612 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 613 | .set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/BatchNorm") |
| 614 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_0/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 615 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 616 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 617 | i_b << ConvolutionLayer(1U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 618 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 619 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 620 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 621 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 622 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 623 | get_random_accessor(1.f, 1.f), |
| 624 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 625 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 626 | .set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 627 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 628 | << ConvolutionLayer(7U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 629 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 630 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 631 | .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 632 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 633 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 634 | get_random_accessor(1.f, 1.f), |
| 635 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 636 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 637 | .set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/BatchNorm") |
| 638 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0b_1x7/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 639 | << ConvolutionLayer(1U, 7U, 320U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 640 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 641 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 642 | .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 643 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 644 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 645 | get_random_accessor(1.f, 1.f), |
| 646 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 647 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 648 | .set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/BatchNorm") |
| 649 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_0c_7x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 650 | << ConvolutionLayer(3U, 3U, 320U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 651 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 652 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 653 | .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 654 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 655 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 656 | get_random_accessor(1.f, 1.f), |
| 657 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 658 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 659 | .set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/BatchNorm") |
| 660 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name("Mixed_7a/Branch_1/Conv2d_1a_3x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 661 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 662 | SubStream i_c(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 663 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)).set_name("Mixed_7a/Branch_2/MaxPool_1a_3x3/MaxPool"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 664 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 665 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 666 | } |
| 667 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 668 | ConcatLayer get_inceptionC_block(const std::string &data_path, DataLayout weights_layout, std::string &¶m_path) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 669 | { |
| 670 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 671 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 672 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 673 | i_a << ConvolutionLayer(1U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 674 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 675 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 676 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 677 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 678 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 679 | get_random_accessor(1.f, 1.f), |
| 680 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 681 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 682 | .set_name(param_path + "/Branch_0/Conv2d_0a_1x1/BatchNorm") |
| 683 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_0/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 684 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 685 | SubStream i_b(graph); |
| 686 | i_b << ConvolutionLayer( |
| 687 | 1U, 1U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 688 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 689 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 690 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 691 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 692 | << BatchNormalizationLayer( |
| 693 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 694 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 695 | get_random_accessor(1.f, 1.f), |
| 696 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 697 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 698 | .set_name(param_path + "/Branch_1/Conv2d_0a_1x1/BatchNorm") |
| 699 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0a_1x1/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 700 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 701 | SubStream i_b1(i_b); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 702 | i_b1 << ConvolutionLayer( |
| 703 | 3U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 704 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 705 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 706 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 707 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 708 | << BatchNormalizationLayer( |
| 709 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"), |
| 710 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"), |
| 711 | get_random_accessor(1.f, 1.f), |
| 712 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"), |
| 713 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 714 | .set_name(param_path + "/Branch_1/Conv2d_0b_1x3/BatchNorm") |
| 715 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0b_1x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 716 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 717 | SubStream i_b2(i_b); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 718 | i_b2 << ConvolutionLayer( |
| 719 | 1U, 3U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 720 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 721 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 722 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 723 | .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 724 | << BatchNormalizationLayer( |
| 725 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"), |
| 726 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"), |
| 727 | get_random_accessor(1.f, 1.f), |
| 728 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"), |
| 729 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 730 | .set_name(param_path + "/Branch_1/Conv2d_0c_3x1/BatchNorm") |
| 731 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_1/Conv2d_0c_3x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 732 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 733 | // Merge b1 and b2 |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 734 | i_b << ConcatLayer(std::move(i_b1), std::move(i_b2)).set_name(param_path + "/Branch_1/concat"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 735 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 736 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 737 | i_c << ConvolutionLayer( |
| 738 | 1U, 1U, 384U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 739 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 740 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 741 | PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 742 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 743 | << BatchNormalizationLayer( |
| 744 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 745 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 746 | get_random_accessor(1.f, 1.f), |
| 747 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 748 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 749 | .set_name(param_path + "/Branch_2/Conv2d_0a_1x1/BatchNorm") |
| 750 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0a_1x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 751 | << ConvolutionLayer( |
| 752 | 1U, 3U, 448U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 753 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 754 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 755 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 756 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 757 | << BatchNormalizationLayer( |
| 758 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"), |
| 759 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"), |
| 760 | get_random_accessor(1.f, 1.f), |
| 761 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"), |
| 762 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 763 | .set_name(param_path + "/Branch_2/Conv2d_0b_3x1/BatchNorm") |
| 764 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0b_3x1/Relu") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 765 | << ConvolutionLayer( |
| 766 | 3U, 1U, 512U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 767 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 768 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 769 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 770 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 771 | << BatchNormalizationLayer( |
| 772 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"), |
| 773 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"), |
| 774 | get_random_accessor(1.f, 1.f), |
| 775 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"), |
| 776 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 777 | .set_name(param_path + "/Branch_2/Conv2d_0c_1x3/BatchNorm") |
| 778 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0c_1x3/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 779 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 780 | SubStream i_c1(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 781 | i_c1 << ConvolutionLayer( |
| 782 | 3U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 783 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 784 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 785 | PadStrideInfo(1, 1, 1, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 786 | .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Conv2D") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 787 | << BatchNormalizationLayer( |
| 788 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"), |
| 789 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"), |
| 790 | get_random_accessor(1.f, 1.f), |
| 791 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"), |
| 792 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 793 | .set_name(param_path + "/Branch_2/Conv2d_0d_1x3/BatchNorm") |
| 794 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0d_1x3/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 795 | |
Georgios Pinitas | 772e17f | 2018-07-13 12:25:33 +0100 | [diff] [blame] | 796 | SubStream i_c2(i_c); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 797 | i_c2 << ConvolutionLayer( |
| 798 | 1U, 3U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 799 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy", weights_layout), |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 800 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 801 | PadStrideInfo(1, 1, 0, 1)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 802 | .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Conv2D") |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 803 | << BatchNormalizationLayer( |
| 804 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"), |
| 805 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"), |
| 806 | get_random_accessor(1.f, 1.f), |
| 807 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"), |
| 808 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 809 | .set_name(param_path + "/Branch_2/Conv2d_0e_3x1/BatchNorm") |
| 810 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_2/Conv2d_0e_3x1/Relu"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 811 | |
| 812 | // Merge i_c1 and i_c2 |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 813 | i_c << ConcatLayer(std::move(i_c1), std::move(i_c2)).set_name(param_path + "/Branch_2/concat"); |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 814 | |
| 815 | SubStream i_d(graph); |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 816 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)).set_name(param_path + "/Branch_3/AvgPool_0a_3x3/AvgPool") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 817 | << ConvolutionLayer(1U, 1U, 256U, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 818 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy", weights_layout), |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 819 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 820 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Conv2D") |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 821 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 822 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 823 | get_random_accessor(1.f, 1.f), |
| 824 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 825 | 0.001f) |
Georgios Pinitas | 62c3639 | 2019-01-31 12:53:10 +0000 | [diff] [blame] | 826 | .set_name(param_path + "/Branch_3/Conv2d_0b_1x1/BatchNorm") |
| 827 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)).set_name(param_path + "/Branch_3/Conv2d_0b_1x1/Relu"); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 828 | |
Georgios Pinitas | 427bbbf | 2018-08-28 13:32:02 +0100 | [diff] [blame] | 829 | return ConcatLayer(std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 830 | } |
| 831 | }; |
| 832 | |
| 833 | /** Main program for Inception V4 |
| 834 | * |
Georgios Pinitas | bdbbbe8 | 2018-11-07 16:06:47 +0000 | [diff] [blame] | 835 | * Model is based on: |
| 836 | * https://arxiv.org/abs/1602.07261 |
| 837 | * "Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning" |
| 838 | * Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi |
| 839 | * |
Georgios Pinitas | 588ebc5 | 2018-12-21 13:39:07 +0000 | [diff] [blame] | 840 | * Provenance: download.tensorflow.org/models/inception_v4_2016_09_09.tar.gz |
| 841 | * |
Georgios Pinitas | 9f28b39 | 2018-07-18 20:01:53 +0100 | [diff] [blame] | 842 | * @note To list all the possible arguments execute the binary appended with the --help option |
| 843 | * |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 844 | * @param[in] argc Number of arguments |
Georgios Pinitas | 12be7ab | 2018-07-03 12:06:23 +0100 | [diff] [blame] | 845 | * @param[in] argv Arguments |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 846 | */ |
| 847 | int main(int argc, char **argv) |
| 848 | { |
| 849 | return arm_compute::utils::run_example<InceptionV4Example>(argc, argv); |
| 850 | } |