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

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

本站已经建立2583天!

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