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

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

本站已经建立2597天!

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