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

本站现有博文333篇,共被浏览921925

本站已经建立2628天!

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