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

本站现有博文322篇,共被浏览783699

本站已经建立2477天!

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