| 134 | } |
| 135 | |
| 136 | int testSimple1DConv() { |
| 137 | |
| 138 | Specification::Model m1; |
| 139 | |
| 140 | auto *topIn = m1.mutable_description()->add_input(); |
| 141 | topIn->set_name("input"); |
| 142 | auto *shape = topIn->mutable_type()->mutable_multiarraytype(); |
| 143 | shape->add_shape(4); |
| 144 | |
| 145 | auto *out = m1.mutable_description()->add_output(); |
| 146 | out->set_name("output"); |
| 147 | auto *outshape = out->mutable_type()->mutable_multiarraytype(); |
| 148 | outshape->add_shape(3); |
| 149 | |
| 150 | auto *nn = m1.mutable_neuralnetwork(); |
| 151 | |
| 152 | // The parameters of the layer don't match the network inputs & outputs |
| 153 | Specification::NeuralNetworkLayer *permLayer = nn->add_layers(); |
| 154 | permLayer->add_input("input"); |
| 155 | permLayer->add_output("perm1_out"); |
| 156 | Specification::PermuteLayerParams *permParams = permLayer->mutable_permute(); |
| 157 | permParams->add_axis(3); |
| 158 | permParams->add_axis(1); |
| 159 | permParams->add_axis(2); |
| 160 | permParams->add_axis(0); |
| 161 | |
| 162 | Specification::NeuralNetworkLayer *convLayer = nn->add_layers(); |
| 163 | convLayer->add_input("perm1_out"); |
| 164 | convLayer->add_output("conv_out"); |
| 165 | Specification::ConvolutionLayerParams *convParams = convLayer->mutable_convolution(); |
| 166 | convParams->set_outputchannels(5); |
| 167 | convParams->set_kernelchannels(4); |
| 168 | convParams->add_kernelsize(1); |
| 169 | convParams->add_kernelsize(10); |
| 170 | convParams->mutable_valid(); |
| 171 | convParams->set_hasbias(false); |
| 172 | for (int i = 0; i < 200; i++) { |
| 173 | convParams->mutable_weights()->add_floatvalue(1.0); |
| 174 | } |
| 175 | |
| 176 | Specification::NeuralNetworkLayer *permLayer2 = nn->add_layers(); |
| 177 | permLayer2->add_input("conv_out"); |
| 178 | permLayer2->add_output("perm2_out"); |
| 179 | Specification::PermuteLayerParams *permParams2 = permLayer2->mutable_permute(); |
| 180 | permParams2->add_axis(3); |
| 181 | permParams2->add_axis(1); |
| 182 | permParams2->add_axis(2); |
| 183 | permParams2->add_axis(0); |
| 184 | |
| 185 | Specification::NeuralNetworkLayer *innerProductLayer = nn->add_layers(); |
| 186 | innerProductLayer->add_input("perm2_out"); |
| 187 | innerProductLayer->add_output("output"); |
| 188 | Specification::InnerProductLayerParams *innerProductParams = innerProductLayer->mutable_innerproduct(); |
| 189 | innerProductParams->set_inputchannels(5); |
| 190 | innerProductParams->set_outputchannels(3); |
| 191 | for (int i = 0; i < 15; i++) { |
| 192 | innerProductParams->mutable_weights()->add_floatvalue(1.0); |
| 193 | } |