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

本站现有博文328篇,共被浏览851018

本站已经建立2557天!

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