EADST

Python Numpy Array to C++ Vector

Python Numpy Array to C++ Vector

# Save the Numpy in a txt.
import numpy as np

s = ''
data = np.load("data.npy")
c, h, w = data.shape
data = data.reshape(c*h*w)
for v in data:
    s += str(v) + '\t'
path = "data.txt"
f = open(path, "w+")
f.write(s)
// load the txt file and save in a float vector
#include < iostream>
#include < fstream>
#include < string>
#include < vector>

using namespace std;


std::string txtPath = "data.txt";
ifstream InFile;
InFile.open (txtPath);
std::vector data_vector;
if (InFile)
{
    string line;
    float number;
    for (int i = 0; i < 1; ++i)
    {
        getline (InFile, line);
        istringstream iss(line);
        while (iss >> number)
        {
            data_vector.push_back (number);
        }

     }
     InFile.close ();
     InFile.clear ();
 }
 else
     throw runtime_error ("document error");
相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
Plate torchinfo Domain WAN 阿里云 Base64 Search UI COCO Django CLAP HuggingFace Heatmap 财报 Breakpoint Pandas printf Land GoogLeNet NLP ms-swift Python Pickle OCR AI CC Excel VGG-16 git JSON Mixtral Jev Distillation SQL Nginx UNIX scipy InvalidArgumentError MD5 Qwen Rebuttal Tensor ResNet-50 Disk Animate Knowledge 图形思考法 Gemma 飞书 多进程 Statistics Linux GIT 净利润 logger Tiktoken PIP Conda Safetensors RL Anaconda TSV IndexTTS2 FP64 FlashAttention Agent TensorFlow EXCEL Food Pytorch Streamlit Transformers BeautifulSoup 顶会 Freesound GPT4 CEIR CTC Shortcut Hotel Crawler Random DeepStream FP8 Cloudreve Tracking News Template 搞笑 Baidu Paper Video XGBoost Bert Web WebCrawler Hilton TensorRT uwsgi Clash 继承 llama.cpp Bitcoin Translation Review CAM 域名 Math mmap SAM Vmess PyTorch Jupyter Interview FP16 SVR Augmentation Image2Text LoRA 关于博主 hf ChatGPT transformers DeepSeek OpenCV Bin QWEN NameSilo CV LaTeX icon Data Llama BTC C++ PyCharm Dataset Vim LLAMA 算法题 Harness v0.dev tqdm TTS Input 版权 Website Ptyhon Firewall Color Claude API Github LLM OpenAI Hungarian BF16 证件照 Diagram Qwen2.5 SQLite CUDA Sklearn tar API网关 Miniforge CSV Google Logo 云服务器 ModelScope PDB Ubuntu Paddle 报税 LeetCode 图标 Card Attention 第一性原理 GGML SPIE Zip 多线程 RGB YOLO RAR Quantize Windows ONNX 签证 腾讯云 Datetime XML Jetson HaggingFace Plotly Numpy Magnet PDF Password v2ray VPN FastAPI Qwen2 Pillow FP32 论文 git-lfs Michelin uWSGI Quantization 论文速读 音频 Proxy NLTK Algorithm 公式 Git Markdown diffusers Permission 强化学习 Bipartite 递归学习法 Docker VSCode GPTQ Use
站点统计

本站现有博文337篇,共被浏览961385次

本站已经建立2673天!

热门文章
文章归档
回到顶部