Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 ARM Limited. |
| 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" |
| 26 | #include "utils/GraphUtils.h" |
| 27 | #include "utils/Utils.h" |
| 28 | |
| 29 | #include <cstdlib> |
| 30 | #include <tuple> |
| 31 | |
| 32 | using namespace arm_compute::utils; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 33 | using namespace arm_compute::graph::frontend; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 34 | using namespace arm_compute::graph_utils; |
| 35 | |
| 36 | /** Example demonstrating how to implement InceptionV4's network using the Compute Library's graph API |
| 37 | * |
| 38 | * @param[in] argc Number of arguments |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 39 | * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] image, [optional] labels, [optional] Fast math for convolution layer (0 = DISABLED, 1 = ENABLED) ) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 40 | */ |
| 41 | class InceptionV4Example final : public Example |
| 42 | { |
| 43 | public: |
| 44 | void do_setup(int argc, char **argv) override |
| 45 | { |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 46 | // Disabled the test for now because the process gets killed on Linux Firefly 32 bit even when using ConvolutionMethodHint::DIRECT. |
| 47 | // Needs to review/rework to run the code below. |
| 48 | #if __aarch64__ |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 49 | std::string data_path; /* Path to the trainable data */ |
| 50 | std::string image; /* Image data */ |
| 51 | std::string label; /* Label data */ |
| 52 | |
| 53 | // Create a preprocessor object |
| 54 | std::unique_ptr<IPreprocessor> preprocessor = arm_compute::support::cpp14::make_unique<TFPreproccessor>(); |
| 55 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 56 | // Set target. 0 (NEON), 1 (OpenCL). By default it is NEON |
Gian Marco Iodice | a8aef29 | 2018-05-14 14:21:39 +0100 | [diff] [blame] | 57 | const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; |
| 58 | Target target_hint = set_target_hint(target); |
| 59 | FastMathHint fast_math_hint = FastMathHint::DISABLED; |
Georgios Pinitas | 2870516 | 2018-03-21 20:10:53 +0000 | [diff] [blame] | 60 | |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 61 | // Parse arguments |
| 62 | if(argc < 2) |
| 63 | { |
| 64 | // Print help |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 65 | std::cout << "Usage: " << argv[0] << " [target] [path_to_data] [image] [labels] [fast_math_hint]\n\n"; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 66 | std::cout << "No data folder provided: using random values\n\n"; |
| 67 | } |
| 68 | else if(argc == 2) |
| 69 | { |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 70 | std::cout << "Usage: " << argv[0] << " " << argv[1] << " [path_to_data] [image] [labels] [fast_math_hint]\n\n"; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 71 | std::cout << "No data folder provided: using random values\n\n"; |
| 72 | } |
| 73 | else if(argc == 3) |
| 74 | { |
| 75 | data_path = argv[2]; |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 76 | std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " [image] [labels] [fast_math_hint]\n\n"; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 77 | std::cout << "No image provided: using random values\n\n"; |
| 78 | } |
| 79 | else if(argc == 4) |
| 80 | { |
| 81 | data_path = argv[2]; |
| 82 | image = argv[3]; |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 83 | std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " [labels] [fast_math_hint]\n\n"; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 84 | std::cout << "No text file with labels provided: skipping output accessor\n\n"; |
| 85 | } |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 86 | else if(argc == 5) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 87 | { |
| 88 | data_path = argv[2]; |
| 89 | image = argv[3]; |
| 90 | label = argv[4]; |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 91 | std::cout << "Usage: " << argv[0] << " " << argv[1] << " " << argv[2] << " " << argv[3] << " " << argv[4] << " [fast_math_hint]\n\n"; |
| 92 | std::cout << "No fast math info provided: disabling fast math\n\n"; |
| 93 | } |
| 94 | else |
| 95 | { |
| 96 | data_path = argv[2]; |
| 97 | image = argv[3]; |
| 98 | label = argv[4]; |
| 99 | fast_math_hint = (std::strtol(argv[5], nullptr, 1) == 0) ? FastMathHint::DISABLED : FastMathHint::ENABLED; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 100 | } |
| 101 | |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 102 | graph << target_hint |
| 103 | << fast_math_hint |
| 104 | << InputLayer(TensorDescriptor(TensorShape(299U, 299U, 3U, 1U), DataType::F32), |
| 105 | get_input_accessor(image, std::move(preprocessor), false)) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 106 | // Conv2d_1a_3x3 |
| 107 | << ConvolutionLayer(3U, 3U, 32U, |
| 108 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_weights.npy"), |
| 109 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 110 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 111 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 112 | get_random_accessor(1.f, 1.f), |
| 113 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 114 | 0.001f) |
| 115 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 116 | // Conv2d_2a_3x3 |
| 117 | << ConvolutionLayer(3U, 3U, 32U, |
| 118 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_weights.npy"), |
| 119 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 120 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_mean.npy"), |
| 121 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_moving_variance.npy"), |
| 122 | get_random_accessor(1.f, 1.f), |
| 123 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2a_3x3_BatchNorm_beta.npy"), |
| 124 | 0.001f) |
| 125 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 126 | // Conv2d_2b_3x3 |
| 127 | << ConvolutionLayer(3U, 3U, 64U, |
| 128 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_weights.npy"), |
| 129 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
| 130 | << BatchNormalizationLayer(get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_mean.npy"), |
| 131 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_moving_variance.npy"), |
| 132 | get_random_accessor(1.f, 1.f), |
| 133 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Conv2d_2b_3x3_BatchNorm_beta.npy"), |
| 134 | 0.001f) |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 135 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 136 | |
Georgios Pinitas | 41c482d | 2018-04-17 13:23:26 +0100 | [diff] [blame] | 137 | graph << get_mixed_3a(data_path); |
| 138 | graph << get_mixed_4a(data_path); |
| 139 | graph << get_mixed_5a(data_path); |
| 140 | // 4 inception A blocks |
| 141 | graph << get_inceptionA_block(data_path, "Mixed_5b"); |
| 142 | graph << get_inceptionA_block(data_path, "Mixed_5c"); |
| 143 | graph << get_inceptionA_block(data_path, "Mixed_5d"); |
| 144 | graph << get_inceptionA_block(data_path, "Mixed_5e"); |
| 145 | // reduction A block |
| 146 | graph << get_reductionA_block(data_path); |
| 147 | // 7 inception B blocks |
| 148 | graph << get_inceptionB_block(data_path, "Mixed_6b"); |
| 149 | graph << get_inceptionB_block(data_path, "Mixed_6c"); |
| 150 | graph << get_inceptionB_block(data_path, "Mixed_6d"); |
| 151 | graph << get_inceptionB_block(data_path, "Mixed_6e"); |
| 152 | graph << get_inceptionB_block(data_path, "Mixed_6f"); |
| 153 | graph << get_inceptionB_block(data_path, "Mixed_6g"); |
| 154 | graph << get_inceptionB_block(data_path, "Mixed_6h"); |
| 155 | // reduction B block |
| 156 | graph << get_reductionB_block(data_path); |
| 157 | // 3 inception C blocks |
| 158 | graph << get_inceptionC_block(data_path, "Mixed_7b"); |
| 159 | graph << get_inceptionC_block(data_path, "Mixed_7c"); |
| 160 | graph << get_inceptionC_block(data_path, "Mixed_7d"); |
| 161 | graph << PoolingLayer(PoolingLayerInfo(PoolingType::AVG)) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 162 | << FlattenLayer() |
| 163 | << FullyConnectedLayer( |
| 164 | 1001U, |
| 165 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_weights.npy"), |
| 166 | get_weights_accessor(data_path, "/cnn_data/inceptionv4_model/Logits_Logits_biases.npy")) |
| 167 | << SoftmaxLayer() |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 168 | << OutputLayer(get_output_accessor(label, 5)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 169 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 170 | // Finalize graph |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 171 | GraphConfig config; |
Georgios Pinitas | 3d1489d | 2018-05-03 20:47:16 +0100 | [diff] [blame] | 172 | config.use_tuner = (target == 2); |
Georgios Pinitas | 9a8c672 | 2018-03-21 17:52:35 +0000 | [diff] [blame] | 173 | graph.finalize(target_hint, config); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 174 | #else /* __aarch64__ */ |
| 175 | using namespace arm_compute; |
| 176 | ARM_COMPUTE_UNUSED(argc); |
| 177 | ARM_COMPUTE_UNUSED(argv); |
| 178 | #endif /* __aarch64__ */ |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | void do_run() override |
| 182 | { |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 183 | #if __aarch64__ |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 184 | graph.run(); |
Pablo Tello | eb82fd2 | 2018-02-23 13:43:50 +0000 | [diff] [blame] | 185 | #endif /* __aarch64__ */ |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | private: |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 189 | Stream graph{ 0, "InceptionV4" }; |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 190 | |
| 191 | private: |
| 192 | BranchLayer get_mixed_3a(const std::string &data_path) |
| 193 | { |
| 194 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_3a_"; |
| 195 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 196 | SubStream i_a(graph); |
| 197 | i_a << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 198 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 199 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 200 | i_b << ConvolutionLayer(3U, 3U, 96U, |
| 201 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_weights.npy"), |
| 202 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 203 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_mean.npy"), |
| 204 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_moving_variance.npy"), |
| 205 | get_random_accessor(1.f, 1.f), |
| 206 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_3x3_BatchNorm_beta.npy"), |
| 207 | 0.001f) |
| 208 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 209 | |
| 210 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b)); |
| 211 | } |
| 212 | |
| 213 | BranchLayer get_mixed_4a(const std::string &data_path) |
| 214 | { |
| 215 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_4a_"; |
| 216 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 217 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 218 | i_a << ConvolutionLayer(1U, 1U, 64U, |
| 219 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"), |
| 220 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 221 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 222 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 223 | get_random_accessor(1.f, 1.f), |
| 224 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 225 | 0.001f) |
| 226 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 227 | << ConvolutionLayer(3U, 3U, 96U, |
| 228 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"), |
| 229 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 230 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 231 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 232 | get_random_accessor(1.f, 1.f), |
| 233 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 234 | 0.001f) |
| 235 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 236 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 237 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 238 | i_b << ConvolutionLayer(1U, 1U, 64U, |
| 239 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"), |
| 240 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 241 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 242 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 243 | get_random_accessor(1.f, 1.f), |
| 244 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 245 | 0.001f) |
| 246 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 247 | << ConvolutionLayer(7U, 1U, 64U, |
| 248 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"), |
| 249 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
| 250 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 251 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 252 | get_random_accessor(1.f, 1.f), |
| 253 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 254 | 0.001f) |
| 255 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 256 | << ConvolutionLayer(1U, 7U, 64U, |
| 257 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"), |
| 258 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
| 259 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 260 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 261 | get_random_accessor(1.f, 1.f), |
| 262 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 263 | 0.001f) |
| 264 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 265 | << ConvolutionLayer(3U, 3U, 96U, |
| 266 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy"), |
| 267 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 268 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 269 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 270 | get_random_accessor(1.f, 1.f), |
| 271 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 272 | 0.001f) |
| 273 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 274 | |
| 275 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b)); |
| 276 | } |
| 277 | |
| 278 | BranchLayer get_mixed_5a(const std::string &data_path) |
| 279 | { |
| 280 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_5a_"; |
| 281 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 282 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 283 | i_a << ConvolutionLayer(3U, 3U, 192U, |
| 284 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"), |
| 285 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 286 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 287 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 288 | get_random_accessor(1.f, 1.f), |
| 289 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 290 | 0.001f) |
| 291 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 292 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 293 | SubStream i_b(graph); |
| 294 | i_b << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 295 | |
| 296 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b)); |
| 297 | } |
| 298 | |
| 299 | BranchLayer get_inceptionA_block(const std::string &data_path, std::string &¶m_path) |
| 300 | { |
| 301 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 302 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 303 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 304 | i_a << ConvolutionLayer(1U, 1U, 96U, |
| 305 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"), |
| 306 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 307 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 308 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 309 | get_random_accessor(1.f, 1.f), |
| 310 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 311 | 0.001f) |
| 312 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 313 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 314 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 315 | i_b << ConvolutionLayer(1U, 1U, 64U, |
| 316 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"), |
| 317 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 318 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 319 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 320 | get_random_accessor(1.f, 1.f), |
| 321 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 322 | 0.001f) |
| 323 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 324 | << ConvolutionLayer(3U, 3U, 96U, |
| 325 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy"), |
| 326 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
| 327 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 328 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 329 | get_random_accessor(1.f, 1.f), |
| 330 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 331 | 0.001f) |
| 332 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 333 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 334 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 335 | i_c << ConvolutionLayer(1U, 1U, 64U, |
| 336 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"), |
| 337 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 338 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 339 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 340 | get_random_accessor(1.f, 1.f), |
| 341 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 342 | 0.001f) |
| 343 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 344 | << ConvolutionLayer(3U, 3U, 96U, |
| 345 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_weights.npy"), |
| 346 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
| 347 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 348 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 349 | get_random_accessor(1.f, 1.f), |
| 350 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 351 | 0.001f) |
| 352 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 353 | << ConvolutionLayer(3U, 3U, 96U, |
| 354 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_weights.npy"), |
| 355 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
| 356 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_mean.npy"), |
| 357 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_moving_variance.npy"), |
| 358 | get_random_accessor(1.f, 1.f), |
| 359 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_3x3_BatchNorm_beta.npy"), |
| 360 | 0.001f) |
| 361 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 362 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 363 | SubStream i_d(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 364 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)) |
| 365 | << ConvolutionLayer(1U, 1U, 96U, |
| 366 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"), |
| 367 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 368 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 369 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 370 | get_random_accessor(1.f, 1.f), |
| 371 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 372 | 0.001f) |
| 373 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 374 | |
| 375 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
| 376 | } |
| 377 | |
| 378 | BranchLayer get_reductionA_block(const std::string &data_path) |
| 379 | { |
| 380 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_6a_"; |
| 381 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 382 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 383 | i_a << ConvolutionLayer(3U, 3U, 384U, |
| 384 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"), |
| 385 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 386 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 387 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 388 | get_random_accessor(1.f, 1.f), |
| 389 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 390 | 0.001f) |
| 391 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 392 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 393 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 394 | i_b << ConvolutionLayer(1U, 1U, 192U, |
| 395 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"), |
| 396 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 397 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 398 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 399 | get_random_accessor(1.f, 1.f), |
| 400 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 401 | 0.001f) |
| 402 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 403 | << ConvolutionLayer(3U, 3U, 224U, |
| 404 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_weights.npy"), |
| 405 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 1, 1)) |
| 406 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_mean.npy"), |
| 407 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_moving_variance.npy"), |
| 408 | get_random_accessor(1.f, 1.f), |
| 409 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_3x3_BatchNorm_beta.npy"), |
| 410 | 0.001f) |
| 411 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 412 | << ConvolutionLayer(3U, 3U, 256U, |
| 413 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy"), |
| 414 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 415 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 416 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 417 | get_random_accessor(1.f, 1.f), |
| 418 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 419 | 0.001f) |
| 420 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 421 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 422 | SubStream i_c(graph); |
| 423 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)); |
| 424 | |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 425 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c)); |
| 426 | } |
| 427 | |
| 428 | BranchLayer get_inceptionB_block(const std::string &data_path, std::string &¶m_path) |
| 429 | { |
| 430 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 431 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 432 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 433 | i_a << ConvolutionLayer(1U, 1U, 384U, |
| 434 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"), |
| 435 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 436 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 437 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 438 | get_random_accessor(1.f, 1.f), |
| 439 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 440 | 0.001f) |
| 441 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 442 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 443 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 444 | i_b << ConvolutionLayer(1U, 1U, 192U, |
| 445 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"), |
| 446 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 447 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 448 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 449 | get_random_accessor(1.f, 1.f), |
| 450 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 451 | 0.001f) |
| 452 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 453 | << ConvolutionLayer(7U, 1U, 224U, |
| 454 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"), |
| 455 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
| 456 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 457 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 458 | get_random_accessor(1.f, 1.f), |
| 459 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 460 | 0.001f) |
| 461 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 462 | << ConvolutionLayer(1U, 7U, 256U, |
| 463 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"), |
| 464 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
| 465 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 466 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 467 | get_random_accessor(1.f, 1.f), |
| 468 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 469 | 0.001f) |
| 470 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 471 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 472 | SubStream i_c(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 473 | i_c << ConvolutionLayer(1U, 1U, 192U, |
| 474 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"), |
| 475 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 476 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 477 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 478 | get_random_accessor(1.f, 1.f), |
| 479 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 480 | 0.001f) |
| 481 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 482 | << ConvolutionLayer(1U, 7U, 192U, |
| 483 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_weights.npy"), |
| 484 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
| 485 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_mean.npy"), |
| 486 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_moving_variance.npy"), |
| 487 | get_random_accessor(1.f, 1.f), |
| 488 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_7x1_BatchNorm_beta.npy"), |
| 489 | 0.001f) |
| 490 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 491 | << ConvolutionLayer(7U, 1U, 224U, |
| 492 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_weights.npy"), |
| 493 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
| 494 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_mean.npy"), |
| 495 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_moving_variance.npy"), |
| 496 | get_random_accessor(1.f, 1.f), |
| 497 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x7_BatchNorm_beta.npy"), |
| 498 | 0.001f) |
| 499 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 500 | << ConvolutionLayer(1U, 7U, 224U, |
| 501 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_weights.npy"), |
| 502 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
| 503 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_mean.npy"), |
| 504 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_moving_variance.npy"), |
| 505 | get_random_accessor(1.f, 1.f), |
| 506 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_7x1_BatchNorm_beta.npy"), |
| 507 | 0.001f) |
| 508 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 509 | << ConvolutionLayer(7U, 1U, 256U, |
| 510 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_weights.npy"), |
| 511 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
| 512 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_mean.npy"), |
| 513 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_moving_variance.npy"), |
| 514 | get_random_accessor(1.f, 1.f), |
| 515 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_1x7_BatchNorm_beta.npy"), |
| 516 | 0.001f) |
| 517 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 518 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 519 | SubStream i_d(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 520 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)) |
| 521 | << ConvolutionLayer(1U, 1U, 128U, |
| 522 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"), |
| 523 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 524 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 525 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 526 | get_random_accessor(1.f, 1.f), |
| 527 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 528 | 0.001f) |
| 529 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 530 | |
| 531 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
| 532 | } |
| 533 | |
| 534 | BranchLayer get_reductionB_block(const std::string &data_path) |
| 535 | { |
| 536 | std::string total_path = "/cnn_data/inceptionv4_model/Mixed_7a_"; |
| 537 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 538 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 539 | i_a << ConvolutionLayer(1U, 1U, 192U, |
| 540 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"), |
| 541 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 542 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 543 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 544 | get_random_accessor(1.f, 1.f), |
| 545 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 546 | 0.001f) |
| 547 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 548 | << ConvolutionLayer(3U, 3U, 192U, |
| 549 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_weights.npy"), |
| 550 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 551 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 552 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 553 | get_random_accessor(1.f, 1.f), |
| 554 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 555 | 0.001f) |
| 556 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 557 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 558 | SubStream i_b(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 559 | i_b << ConvolutionLayer(1U, 1U, 256U, |
| 560 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"), |
| 561 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 562 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 563 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 564 | get_random_accessor(1.f, 1.f), |
| 565 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 566 | 0.001f) |
| 567 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 568 | << ConvolutionLayer(7U, 1U, 256U, |
| 569 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_weights.npy"), |
| 570 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 3, 0)) |
| 571 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_mean.npy"), |
| 572 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_moving_variance.npy"), |
| 573 | get_random_accessor(1.f, 1.f), |
| 574 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x7_BatchNorm_beta.npy"), |
| 575 | 0.001f) |
| 576 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 577 | << ConvolutionLayer(1U, 7U, 320U, |
| 578 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_weights.npy"), |
| 579 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 3)) |
| 580 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_mean.npy"), |
| 581 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_moving_variance.npy"), |
| 582 | get_random_accessor(1.f, 1.f), |
| 583 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_7x1_BatchNorm_beta.npy"), |
| 584 | 0.001f) |
| 585 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 586 | << ConvolutionLayer(3U, 3U, 320U, |
| 587 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_weights.npy"), |
| 588 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(2, 2, 0, 0)) |
| 589 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_mean.npy"), |
| 590 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_moving_variance.npy"), |
| 591 | get_random_accessor(1.f, 1.f), |
| 592 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_1a_3x3_BatchNorm_beta.npy"), |
| 593 | 0.001f) |
| 594 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 595 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 596 | SubStream i_c(graph); |
| 597 | i_c << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL), true)); |
| 598 | |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 599 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c)); |
| 600 | } |
| 601 | |
| 602 | BranchLayer get_inceptionC_block(const std::string &data_path, std::string &¶m_path) |
| 603 | { |
| 604 | std::string total_path = "/cnn_data/inceptionv4_model/" + param_path + "_"; |
| 605 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 606 | SubStream i_a(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 607 | i_a << ConvolutionLayer(1U, 1U, 256U, |
| 608 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_weights.npy"), |
| 609 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 610 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 611 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 612 | get_random_accessor(1.f, 1.f), |
| 613 | get_weights_accessor(data_path, total_path + "Branch_0_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 614 | 0.001f) |
| 615 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 616 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 617 | SubStream i_b(graph); |
| 618 | i_b << ConvolutionLayer( |
| 619 | 1U, 1U, 384U, |
| 620 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_weights.npy"), |
| 621 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 622 | PadStrideInfo(1, 1, 0, 0)) |
| 623 | << BatchNormalizationLayer( |
| 624 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 625 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 626 | get_random_accessor(1.f, 1.f), |
| 627 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 628 | 0.001f) |
| 629 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 630 | |
| 631 | SubStream i_b1(static_cast<IStream &>(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 632 | i_b1 << ConvolutionLayer( |
| 633 | 3U, 1U, 256U, |
| 634 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_weights.npy"), |
| 635 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 636 | PadStrideInfo(1, 1, 1, 0)) |
| 637 | << BatchNormalizationLayer( |
| 638 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_mean.npy"), |
| 639 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_moving_variance.npy"), |
| 640 | get_random_accessor(1.f, 1.f), |
| 641 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0b_1x3_BatchNorm_beta.npy"), |
| 642 | 0.001f) |
| 643 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 644 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 645 | SubStream i_b2(static_cast<IStream &>(i_b)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 646 | i_b2 << ConvolutionLayer( |
| 647 | 1U, 3U, 256U, |
| 648 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_weights.npy"), |
| 649 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 650 | PadStrideInfo(1, 1, 0, 1)) |
| 651 | << BatchNormalizationLayer( |
| 652 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_mean.npy"), |
| 653 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_moving_variance.npy"), |
| 654 | get_random_accessor(1.f, 1.f), |
| 655 | get_weights_accessor(data_path, total_path + "Branch_1_Conv2d_0c_3x1_BatchNorm_beta.npy"), |
| 656 | 0.001f) |
| 657 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 658 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 659 | // Merge b1 and b2 |
| 660 | i_b << BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_b1), std::move(i_b2)); |
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 | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 663 | i_c << ConvolutionLayer( |
| 664 | 1U, 1U, 384U, |
| 665 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_weights.npy"), |
| 666 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 667 | PadStrideInfo(1, 1, 0, 0)) |
| 668 | << BatchNormalizationLayer( |
| 669 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_mean.npy"), |
| 670 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_moving_variance.npy"), |
| 671 | get_random_accessor(1.f, 1.f), |
| 672 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0a_1x1_BatchNorm_beta.npy"), |
| 673 | 0.001f) |
| 674 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 675 | << ConvolutionLayer( |
| 676 | 1U, 3U, 448U, |
| 677 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_weights.npy"), |
| 678 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 679 | PadStrideInfo(1, 1, 0, 1)) |
| 680 | << BatchNormalizationLayer( |
| 681 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_mean.npy"), |
| 682 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_moving_variance.npy"), |
| 683 | get_random_accessor(1.f, 1.f), |
| 684 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0b_3x1_BatchNorm_beta.npy"), |
| 685 | 0.001f) |
| 686 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) |
| 687 | << ConvolutionLayer( |
| 688 | 3U, 1U, 512U, |
| 689 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_weights.npy"), |
| 690 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 691 | PadStrideInfo(1, 1, 1, 0)) |
| 692 | << BatchNormalizationLayer( |
| 693 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_mean.npy"), |
| 694 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_moving_variance.npy"), |
| 695 | get_random_accessor(1.f, 1.f), |
| 696 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0c_1x3_BatchNorm_beta.npy"), |
| 697 | 0.001f) |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 698 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 699 | |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 700 | SubStream i_c1(static_cast<IStream &>(i_c)); |
| 701 | i_c1 << ConvolutionLayer( |
| 702 | 3U, 1U, 256U, |
| 703 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_weights.npy"), |
| 704 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 705 | PadStrideInfo(1, 1, 1, 0)) |
| 706 | << BatchNormalizationLayer( |
| 707 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_mean.npy"), |
| 708 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_moving_variance.npy"), |
| 709 | get_random_accessor(1.f, 1.f), |
| 710 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0d_1x3_BatchNorm_beta.npy"), |
| 711 | 0.001f) |
| 712 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 713 | |
| 714 | SubStream i_c2(static_cast<IStream &>(i_c)); |
| 715 | i_c2 << ConvolutionLayer( |
| 716 | 1U, 3U, 256U, |
| 717 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_weights.npy"), |
| 718 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), |
| 719 | PadStrideInfo(1, 1, 0, 1)) |
| 720 | << BatchNormalizationLayer( |
| 721 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_mean.npy"), |
| 722 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_moving_variance.npy"), |
| 723 | get_random_accessor(1.f, 1.f), |
| 724 | get_weights_accessor(data_path, total_path + "Branch_2_Conv2d_0e_3x1_BatchNorm_beta.npy"), |
| 725 | 0.001f) |
| 726 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 727 | |
| 728 | // Merge i_c1 and i_c2 |
| 729 | i_c << BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_c1), std::move(i_c2)); |
| 730 | |
| 731 | SubStream i_d(graph); |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 732 | i_d << PoolingLayer(PoolingLayerInfo(PoolingType::AVG, 3, PadStrideInfo(1, 1, 1, 1, DimensionRoundingType::CEIL), true)) |
| 733 | << ConvolutionLayer(1U, 1U, 256U, |
| 734 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_weights.npy"), |
| 735 | std::unique_ptr<arm_compute::graph::ITensorAccessor>(nullptr), PadStrideInfo(1, 1, 0, 0)) |
| 736 | << BatchNormalizationLayer(get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_mean.npy"), |
| 737 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_moving_variance.npy"), |
| 738 | get_random_accessor(1.f, 1.f), |
| 739 | get_weights_accessor(data_path, total_path + "Branch_3_Conv2d_0b_1x1_BatchNorm_beta.npy"), |
| 740 | 0.001f) |
| 741 | << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)); |
| 742 | |
| 743 | return BranchLayer(BranchMergeMethod::DEPTH_CONCATENATE, std::move(i_a), std::move(i_b), std::move(i_c), std::move(i_d)); |
| 744 | } |
| 745 | }; |
| 746 | |
| 747 | /** Main program for Inception V4 |
| 748 | * |
| 749 | * @param[in] argc Number of arguments |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 750 | * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] image, [optional] labels, [optional] Fast math for convolution layer (0 = DISABLED, 1 = ENABLED) ) |
Georgios Pinitas | 240cfa6 | 2018-02-26 19:58:04 +0000 | [diff] [blame] | 751 | */ |
| 752 | int main(int argc, char **argv) |
| 753 | { |
| 754 | return arm_compute::utils::run_example<InceptionV4Example>(argc, argv); |
| 755 | } |