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

本站现有博文327篇,共被浏览833002

本站已经建立2538天!

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