curl上传和下载C语言实现

C/C++ CGI处理文件上传 前端页面如下:(index.html) <!DOCTYPE> <html> <head> <title>Upload File Test</title> </head> <body> <form enctype='multipart/form 阅读详情

上传

/***************************************************************************
 *                                  _   _ ____  _
 *  Project                     ___| | | |  _ \| |
 *                             / __| | | | |_) | |
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * are also available at https://curl.se/docs/copyright.html.
 *
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
 * copies of the Software, and permit persons to whom the Software is
 * furnished to do so, under the terms of the COPYING file.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ***************************************************************************/
/* <DESC>
 * Upload to a file:// URL
 * </DESC>
 */
#include <stdio.h>
#include <curl/curl.h>
#include <sys/stat.h>
#include <fcntl.h>
 
int main(void)
{
  CURL *curl;
  CURLcode res;
  struct stat file_info;
  curl_off_t speed_upload, total_time;
  FILE *fd;
 
  fd = fopen("debugit", "rb"); /* open file to upload */
  if(!fd)
    return 1; /* cannot continue */
 
  /* to get the file size */
  if(fstat(fileno(fd), &file_info) != 0)
    return 1; /* cannot continue */
 
  curl = curl_easy_init();
  if(curl) {
    /* upload to this place */
    curl_easy_setopt(curl, CURLOPT_URL,
                     "file:///home/dast/src/curl/debug/new");
 
    /* tell it to "upload" to the URL */
    curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
 
    /* set where to read from (on Windows you need to use READFUNCTION too) */
    curl_easy_setopt(curl, CURLOPT_READDATA, fd);
 
    /* and give the size of the upload (optional) */
    curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE,
                     (curl_off_t)file_info.st_size);
 
    /* enable verbose for easier tracing */
    curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
 
    res = curl_easy_perform(curl);
    /* Check for errors */
    if(res != CURLE_OK) {
      fprintf(stderr, "curl_easy_perform() failed: %s\n",
              curl_easy_strerror(res));
    }
    else {
      /* now extract transfer info */
      curl_easy_getinfo(curl, CURLINFO_SPEED_UPLOAD_T, &speed_upload);
      curl_easy_getinfo(curl, CURLINFO_TOTAL_TIME_T, &total_time);
 
      fprintf(stderr, "Speed: %lu bytes/sec during %lu.%06lu seconds\n",
              (unsigned long)speed_upload,
              (unsigned long)(total_time / 1000000),
              (unsigned long)(total_time % 1000000));
    }
    /* always cleanup */
    curl_easy_cleanup(curl);
  }
  fclose(fd);
  return 0;
}

下载

/***************************************************************************
 *                                  _   _ ____  _
 *  Project                     ___| | | |  _ \| |
 *                             / __| | | | |_) | |
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
 * are also available at https://curl.se/docs/copyright.html.
 *
 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
 * copies of the Software, and permit persons to whom the Software is
 * furnished to do so, under the terms of the COPYING file.
 *
 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 * KIND, either express or implied.
 *
 ***************************************************************************/
/* <DESC>
 * Download a given URL into a local file named page.out.
 * </DESC>
 */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
 
#include <curl/curl.h>
 
static size_t write_data(void *ptr, size_t size, size_t nmemb, void *stream)
{
  size_t written = fwrite(ptr, size, nmemb, (FILE *)stream);
  return written;
}
 
int main(int argc, char *argv[])
{
  CURL *curl_handle;
  static const char *pagefilename = "page.out";
  FILE *pagefile;
 
  if(argc < 2) {
    printf("Usage: %s <URL>\n", argv[0]);
    return 1;
  }
 
  curl_global_init(CURL_GLOBAL_ALL);
 
  /* init the curl session */
  curl_handle = curl_easy_init();
 
  /* set URL to get here */
  curl_easy_setopt(curl_handle, CURLOPT_URL, argv[1]);
 
  /* Switch on full protocol/debug output while testing */
  curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1L);
 
  /* disable progress meter, set to 0L to enable it */
  curl_easy_setopt(curl_handle, CURLOPT_NOPROGRESS, 1L);
 
  /* send all data to this function  */
  curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, write_data);
 
  /* open the file */
  pagefile = fopen(pagefilename, "wb");
  if(pagefile) {
 
    /* write the page body to this file handle */
    curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, pagefile);
 
    /* get it! */
    curl_easy_perform(curl_handle);
 
    /* close the header file */
    fclose(pagefile);
  }
 
  /* cleanup curl stuff */
  curl_easy_cleanup(curl_handle);
 
  curl_global_cleanup();
 
  return 0;
}


https://curl.se/libcurl/c/fileupload.html
https://curl.se/libcurl/c/url2file.html

curl第十课 multipart/formdata表单上传 基础multipart/form-data其实就是浏览器用表单上传文件的方式。最常见的情境是:在写邮件时,向邮件后添加附件,附件通常使用表单添加,也就是用multipart/form-data格式上传到服务器。场景Http服务器定义了上传数据的格式,接口地址 http://10.10.10.10:80/restful/personInfo,参... 阅读详情

相关推荐

2024年C C++最新C语言curl实现FTP上传、下载、获取文件信息(1),一个APP从启动到主页面显示经历了哪些过程

网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。需要这份系统化的资料的朋友,可以添加戳这里获取一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!***************************************************************************/ #in

2401_84978588的博客 1265

Curl 模拟get、 post、put 请求以及上传文件

1,Curl 模拟GET请求 //初始化 $ch = curl_init(); //设置请求地址L curl_setopt($ch, CURLOPT_URL, "http://www.nettuts.com"); //设置响应不直接输出到页面,1为不直接输出 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //设置是否输出请求头信息,0为不...

进无止境 5819

curl 实现 https、ftp下载文件 代码

cURL 是一个网络数据传输项目,通常说 cURL 是指 curl 命令行工具,它支持 DICT、FILE、FTP、FTPS、Gopher、HTTP、HTTPS、IMAP、IMAPS、LDAP、LDAPS、POP3、POP3S、RTMP、RTSP、SCP、SFTP、SMB、SMBS、SMTP、SMTPS、Telnet 与 TFTP 等协议,而 curl 的底层使用的是 libcurl 库,libcurl 与 curl 组成了 cURL 项目。命令没问题的话我们源码编译安装成功,下面就可以写代码实现了。

qq_34934140的博客 3295

PHP中CURL方法及curl_setopt()与curl_getinfo()函数参数说明

使用PHP的cURL库可以简单和有效地抓取网页内容,本文主要记录CURL方法及curl_setopt()函数的一些参数。 简单示例 CURL库方法 名称 说明 curl_close 关闭一个curl会话 curl_copy_handle 拷贝一个curl连接资源的所有内容和参数 curl_errno 返回一个包含当前会话错误信

大爱无疆的博客 3244

Linux系统下SFTP上传下载实现

1.功能介绍 1.1 sftp(安全文件传送协议),从字面意思看,就是我们常用的文件上传下载协议,实现文件的上传下载功能。 2.如实使用sftp 2.1 网上也有很多封装好的库,也很好用,可以跨平台;今天我分享的是基于Linux系统编程的sftp,不需要下载任何库,拿去直接可用,也写了相应的测试程序可参考。 3.SFTP代码 #include <stdio.h> #include &l...

weixin_40314888的博客 1570

LIBCURL实现FTP上传下载功能

<br /> /*****************************************************************************<br /><br />  FTP上传下载功能<br /><br />  */<br /><br />  #include <stdlib.h><br /><br />  #include <stdio.h><br /><br />  #include <curl/curl.h><br /><br />  #include <sys/sta

vipfengxiao的专栏 9465

FTP文件上传、下载(基于curl库 )

在Linux中curl是一个利用URL规则在命令行下工作的文件传输工具,如下为通过curl命令上传、下载ftp文件的用法: # curl -T upload_test.txt -u fangye:fangye ftp://192.168.10.105/ //下载ftp文件 -u 账号:密码 更多curl命令用法参考博客: https://blog.youkuaiyun.com/gubenpeiyua...

fangye945a的博客 3028

获取ftp服务器目录树

在FTP协议中,要获取FTP服务器的目录树,可以使用一系列命令交互来逐级列出目录内容,直到构建出整个目录结构。请注意,FTP是一种不安全的协议,因为数据(包括密码)在传输过程中是未加密的,建议使用更安全的替代方案,如SFTP(SSH File Transfer Protocol)或FTPS(FTP Secure),它们提供了加密的数据传输。在FTP协议中,要获取目录树通常会涉及多个命令,主要有`PWD`(打印当前工作目录)、`CWD`(改变工作目录)、`LIST`或`NLST`(列出目录内容)等。

数字人生 2241

使用curl 命令上传下载FTP

CURL命令行 常见操作 1、列出ftp服务器上的目录列表: curl ftp://www.xxx.com/ --user name:passwd curl ftp://www.xxx.com/ –u name:passwd #简洁写法1 curl ftp://name:passwd@www.xxx.com #简洁写法2 2、只列出目录,不显示进度条 curl ftp://www.xxx.com –u name:passwd -s 3、下载一个文件: curl ftp://www.xxx.com/s.

$好记性还是要多记录$ 1万+

Linux下使用libcurl实现FTP单个文件上传下载功能

1.前言 1.1声明 文章中的文字可能存在语法错语以及标点错误,请谅解; 如果在文章中发现代码错误或其它问题请告知,感谢! 2.关于libcurl 2.1简介 libcurl是一个提供数据传输功能的函数库,主要功能就是通过其使用不同的协议连接不同类型的服务器。当前libcurl支持的协议主要有http, https, ftp, gopher, telnet, dict, file, 和ldap等协议和各种SSL安全认证。 在基于libcurl的程序里,使用libcurl提供的库函数完成特定任务。开发者在启动

技术联盟 744

Python 音频: sounddevice 使用 左声道/右声道/立体声 --- 播放,录音

# coding: utf8 """ Python 音频: 使用 sounddevice 操作声卡的 左声道, 右声道, 立体声 仅限 MME, Windows DirectSound, Windows WASAPI, Windows WDM-KS 等支持双声道的驱动类型 """ import os import sounddevice as sd import soundfile mapping_left_ch = 1 # 左声道为 1 mapping_right_ch

weixin_42019925的博客 4926

libcurl 库的ftp上传和下载代码

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34247299的博客 463

STM32F103 实例应用(10)——I2C读写24C32

一、应用简介 本文介绍24C32的读写,基于野火的软件I2C程序。 board_i2c.h /**=========================================================================== @file board_i2c.h @brief 本文件是用于I2C驱动 @author 青梅煮久 @version r0.1 @date 2021/01/13 -------------------------.

qq_34118600的博客 3447

利用curl进行ftp的下载和上传

由于项目的需要,利用libcurl编写程序与ftp服务器通信,进行文件上传或下载,愈发地感到curl功能的强悍。其实在命令行下直接使用curl命令就可以完成这些功能,但是需要获取上传下载行为的状态以便更好地控制。直接上代码://ftp-manager.h #ifndef _FTP_MANAGER_H_ #define _FTP_MANAGER_H_ /*FTP OPERATION CODE*/...

u010871058的专栏 6936

攻防实战之Confluence后利用

这边管理员密码是密文加密在数据库中,解不开,因此解决的思路是将管理员用户密码修改为已知明文密码的密文(这边不能直接在数据库中添加字段,关系型数据库在单表中添加一条字段可能会出现问题),登录上后台以后,添加用户并加入管理员组,最后将管理员密码还原。Confluence的后利用主要问题在于在Linux中搭建时,默认是Confluence用户权限,如下图所示,而confluence在linux中是没有写权限的,这也就是为什么有些人发现可以执行命令但是shell写不进去。至此admin的密码被改为了123123。

weixin_39251927的博客 2716

spark 适配达梦数据库

spark 适配达梦数据库 版本 spark3.0.0 scala2.12.10 DM Database Server 64 V8 步骤一: 引驱动包: SBT方式: "com.dameng" % "Dm8JdbcDriver18" % "8.1.0.157", maven方式: <dependency> <groupId>com.dameng</groupId> <artifactId>Dm8JdbcDriver18</artifac

_@Eva@_的博客 2088

C语言curl实现FTP上传、下载、获取文件信息

目录 Get a single file from an FTP server. Checks a single file's size and mtime from an FTP server. Get a single file from an FTP server.but also stores the received response-lines Get a single fil...

RToax 3559

vnpy_ctp源码下载后转变为python可用的处理过程

vnpy_ctp源码下载后在window中编译使用

m0_37967652的博客 3327

如何使用curl编程来下载文件

本文介绍了libcurl库的基础使用,重点讲解如何通过C语言实现文件下载功能。文章首先概述了libcurl作为一个跨平台网络传输库的特性,详细解析其核心数据结构:CURL句柄(具有独立性、可复用性和状态存储特性)和CURLcode返回值(包含80多种错误代码枚举)。通过具体代码示例,展示了如何利用libcurl进行文件下载操作,包括初始化、配置选项和错误处理等关键步骤。内容涵盖了从基础概念到实际应用的完整流程,为开发者提供了一份清晰的libcurl入门指南。

码农爱学习的博客 1415

【VTKExamples::Meshes】第十二期 QuadricDecimation

本文分享VTK样例QuadricDecimation,并解析接口vtkQuadricDecimation,希望对各位小伙伴有所帮助!

qq_40041064的博客 342

12、激光制造中人工智能与机器学习的应用及挑战

本文探讨了人工智能与机器学习在激光制造中的应用,重点分析了图像分类技术在质量检测中的多种方法及其性能对比,包括基于贝叶斯分类、卷积神经网络(CNN)和多尺度CNN的技术。同时,文章指出了AI在激光制造中面临的五大挑战:鲁棒性、安全性、可解释性、责任归属和可预测性,并提出了相应的解决思路。此外,还介绍了激光制造的主要应用技术如切割、焊接和增材制造的流程、优势与局限性,并通过对比表格直观展示不同技术的特点。最后展望了未来激光制造向智能化、自动化和可持续化发展的趋势。

rgv234567的博客 136

2024年C C++最全C语言curl实现FTP上传、下载、获取文件信息(2),2024年最新手慢无

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上C C++开发知识点,真正体系化!由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、讲解视频,并且后续会持续更新如果你需要这些资料,可以戳这里获取} /*************************************************************************** Project

2401_84976212的博客 1199

YOLOv5改进 | 多尺度特征提取 | 结合多样分支块及融合的高级设计(CVPR2021)

YOLOv5改进 | 多尺度特征提取 | 结合多样分支块及融合的高级设计(CVPR2021)

qq_44224801的博客 2067

curl 简单实例 (c代码通过 curl-url 实现信息获取)

在项目中使用到了libcurl,gui图形界面通过url向主进程获取、传递参数,通过查看代码,发现通过curl可以做到如此强大的功能,很强大。 在网上查资料。php使用curl是最多的,通过curl获取http url请求/web站点各阶段相应时间,因为我们的环境限制,只能采用c语言,所以我也只能通过c语言来验证。 首先还是对curl做一个简单的介绍吧,cURL是一个利用URL语法在命令行下工作的...

weixin_43608153的博客 5269

C# WinForm 基于DirectShow.dll编写的程序,可边预览边保存视频,音频和图片

基于微软的DirectShow.dll的二次开发1.自动识别连接的摄像头跟麦克风且可以对其进行选择(默认选中第一个)2.可录制wmv和avi两种格式的视频并且都带有音频,avi可以录制的分辨率和帧数进行选择,wmv默认进行了淸晰度优化如不喜欢可去除代码中有相关提示3.可在预览点开之后进行拍照,也可边录制视频边拍照4.添加了视频和音频的压缩功能(酌情使用)这次二次开发发现C#对DirectShow的相关信息太少,这次做完也不敢藏私共享出来,还望大家指正

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

windows下C语言使用curl库访问HTTP下载文件

cURL是一个利用URL语法在命令行下工作的文件传输工具,1997年首次发行。它支持文件上传和下载,所以是综合传输工具,但按传统,习惯称cURL为下载工具。cURL还包含了用于程序开发的libcurl。

2681

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

基于Linux的嵌入式设备通过CURL实现HTTP POST方式向服务器传递JSON数据(C语言)(原理+实现过程+代码)

近期应项目要求,需要在嵌入式设备上实现将数据上传至服务器,查找了许多资料,现在将整个过程所需要的知识整理下来,以备后续查找。 硬件环境 下位机:基于Linux的嵌入式开发硬件 上位机:web服务器(PC端) HTTP协议简介 HTTP即Hyper Text Transfer Protocol (超文本传输协议),是一种基于TCP/IP通信协议来传递数据 (HTML 文件,图片文件,查询结果等)。 HTTP协议的几种请求方法 在HTTP1.1中,总共有8种请求方法(也叫动作),用来表明对Request-URL

weixin_45994747的博客 4631

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

上一篇: VS的符合模式选项
下一篇: Hook截取键盘信息
我是谁??
博客等级 码龄11年 242粉丝 183原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值