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

本站现有博文323篇,共被浏览795298

本站已经建立2493天!

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