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

本站现有博文337篇,共被浏览958999次

本站已经建立2670天!

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