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