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

本站现有博文335篇,共被浏览937401

本站已经建立2648天!

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