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

本站现有博文332篇,共被浏览870130

本站已经建立2578天!

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