Advertisement
Trainlover08

X tensor chatGPT output

Mar 20th, 2024 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.10 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <xtensor/xarray.hpp>
  4. #include <xtensor/xio.hpp>
  5. #include <xtensor/xview.hpp>
  6. #include <xtensor.blas/xlinalg.hpp>
  7.  
  8. xt::array<double> dot_product_with_biases(const xt::array<double>& inputs,
  9.                                          const xt::array<double>& weights,
  10.                                          const xt::array<double>& biases){
  11.     xt::xarray<double> transposed_weights = xt::transpose(weights);
  12.     xt::xarray<double> dot_product_result = xt::linalg::dot(inputs, transposed_weights);
  13.     xt::xarray<double> output = dot_product_result + biases;
  14.    
  15.     return output;
  16. }
  17.  
  18. int main(){
  19.     xt::xarray<double> inputs = {
  20.                                 {1.,1.,3.,2.5},
  21.                                 {2.,5.,-1.,2.},
  22.                                 {-1.5,2.7,3.3,-0.8}
  23.                                 };
  24.     xt::xarray<double> weights = {
  25.                                  {.2,.8,-.5,1.}
  26.                                  {.5,-.91,.26,-.5}
  27.                                  {-.26,-.27,.17,.87}
  28.                                  };
  29.     xt::xarray<double> biases = {2.,3.,.5};
  30.    
  31.     xt::array<double> results = dot_product_with_biases(inputs, weights, biases);
  32.    
  33.     printf("product: %.2f\n", results);
  34.    
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement