I have troubles with my C++ code. I am using OpenNN to buid a Neural Network and I want to use my trained Neural Network (see variable neuralnetwork), to predict the output from a set of features (see variable featureVector). I am trying to call a function which needs a initialiser_list - object as argument. This is the code:
float featureVector[1][5] = {{1, 2, 3, 4, 5}};
Tensor<type, 2> inputs(1, featureLength);
inputs.setValues(featureVector);
neuralnetwork.calculate_outputs(inputs);
I get this error message: neuralnetwork.cpp:141:22: error: reference to type 'const typename internal::Initializer<Tensor<float, 2, 0, long long>, NumDimensions>::InitList' (aka 'const initializer_list<initializer_list>') could not bind to an lvalue of type 'float [1][5]' TensorBase.h:861:81: note: passing argument to parameter 'vals' here
When I change my code according to an example from OpenNN, it works, but this is not what I want because the feature vector needs to be a variable like above:
Tensor<type, 2> inputs(1, featureLength);
inputs.setValues({{1, 2, 3, 4, 5}});
neuralnetwork.calculate_outputs(inputs);
I also tried to change featureVector to a list (std::list) but this does not work, to. I know that featureVector needs to be an initialiser_list object, but I could not find any answers online on how to initialise an initialiser_list-object. It would be nice if featureVector is a array or std::list, which will be converted to a initialiser_list.
Edit:
Type of neuralnetwork:
OpenNN::NeuralNetwork neuralnetwork;
Function calculate_outputs:
Tensor<type, 2> NeuralNetwork::calculate_outputs(const Tensor<type, 2>& inputs)
With the solution in the comment I figured something out that works for me:
auto featureVector1 = {1.f, 2.f, 3.f, 4.f, 5.f};
auto featureVector = {featureVector1};
Tensor<type, 2> inputs(1, featureLength);
inputs.setValues(featureVector);
neuralnetwork.calculate_outputs(inputs);
It does not look nice and maybe it is not perfect, but it this is exactly how I wanted it. Thank you!