Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <xtensor/xarray.hpp>
- #include <xtensor/xio.hpp>
- #include <xtensor/xview.hpp>
- #include <xtensor.blas/xlinalg.hpp>
- xt::array<double> dot_product_with_biases(const xt::array<double>& inputs,
- const xt::array<double>& weights,
- const xt::array<double>& biases){
- xt::xarray<double> transposed_weights = xt::transpose(weights);
- xt::xarray<double> dot_product_result = xt::linalg::dot(inputs, transposed_weights);
- xt::xarray<double> output = dot_product_result + biases;
- return output;
- }
- int main(){
- xt::xarray<double> inputs = {
- {1.,1.,3.,2.5},
- {2.,5.,-1.,2.},
- {-1.5,2.7,3.3,-0.8}
- };
- xt::xarray<double> weights = {
- {.2,.8,-.5,1.}
- {.5,-.91,.26,-.5}
- {-.26,-.27,.17,.87}
- };
- xt::xarray<double> biases = {2.,3.,.5};
- xt::array<double> results = dot_product_with_biases(inputs, weights, biases);
- printf("product: %.2f\n", results);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement