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

本站现有博文340篇,共被浏览1017985次

本站已经建立2718天!

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