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

本站现有博文327篇,共被浏览832597

本站已经建立2537天!

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