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

本站现有博文320篇,共被浏览757227

本站已经建立2422天!

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