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

本站现有博文324篇,共被浏览809639

本站已经建立2512天!

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