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

本站现有博文333篇,共被浏览915419

本站已经建立2619天!

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