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

本站现有博文338篇,共被浏览974698次

本站已经建立2687天!

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