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

本站现有博文321篇,共被浏览764641

本站已经建立2442天!

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