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

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

本站已经建立2534天!

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