【caffe速成】caffe图像分类从模型自定义到测试

音频DSP开发中的‘隐藏关卡’:那些SigmaStudio未公开的模块计算秘籍 本文深入探讨音频DSP开发中SigmaStudio未公开的模块计算秘籍,重点解析动态范围控制、均衡器参数映射和混响算法优化等核心模块计算公式。通过实际案例揭示如何利用这些非官方技巧提升音频质量与系统性能,为ADI DSP开发者提供宝贵的实战经验。 阅读详情

文章首发于微信公众号《与有三学AI》

【caffe速成】caffe图像分类从模型自定义到测试

这是给大家准备的caffe速成例子

这一次我们讲讲 Caffe 这个主流的开源框架从训练到测试出结果的全流程。到此,我必须假设大家已经有了深度学习的基础知识并了解卷积网络的工作原理。

相关的代码、数据都在我们 Git 上,希望大家 Follow 一下这个 Git 项目,后面会持续更新不同框架下的任务。

https://github.com/longpeng2008/LongPeng_ML_Course

这一篇我们说一个分类任务,给大家准备了 500 张微笑的图片、500 张非微笑的图片,放置在 data 目录下,图片预览如下,已经缩放到 60*60 的大小:

这是非微笑的图片:

 

这是微笑的图片:

 

 

01 Caffe 是什么

Caffe 是以 C++/CUDA 代码为主,最早的深度学习框架之一,比 TensorFlow、Mxnet、Pytorch 等都更早,支持命令行、Python 和 Matlab 接口,单机多卡、多机多卡等都可以很方便的使用,CPU 和 GPU 之间无缝切换。

对于入门级别的任务,如图像分类,Caffe 上手的成本最低,几乎不需要写一行代码就可以开始训练,所以我推荐 Caffe 作为入门学习的框架。

Caffe 相对于 TensorFlow 等使用 pip 一键安装的方式来说,编译安装稍微麻烦一些,但其实依旧很简单,我们以 Ubuntu 16.04 为例子,官网的安装脚本足够用了,它有一些依赖库。

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-devsudo apt-get install libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

装完之后,到 Git 上 clone 代码,修改 Makefile.config 就可以进行编译安装,如果其中有任何问题,多 Google,还有什么问题,留言吧。当然,对于有 GPU 的读者,还需要安装 cuda 以及 Nvidia 驱动。

 

02 Caffe 训练

Caffe 完成一个训练,必要准备以下资料:一个是 train.prototxt 作为网络配置文件,另一个是 solver.prototxt 作为优化参数配置文件,再一个是训练文件 list。

另外,在大多数情况下,需要一个预训练模型作为权重的初始化。

(1)准备网络配置文件

我们准备了一个 3*3 的卷积神经网络,它的 train.prototxt 文件是这样的:

name: "mouth"
layer {
 name: "data"
 type: "ImageData"
 top: "data"
 top: "clc-label"
 image_data_param {
   source: "all_shuffle_train.txt"
   batch_size: 96
   shuffle: true
 }
 transform_param {
   mean_value: 104.008
   mean_value: 116.669
   mean_value: 122.675
   crop_size: 48
   mirror: true
 }
 include: { phase: TRAIN}
}
layer {
 name: "data"
 type: "ImageData"
 top: "data"
 top: "clc-label"
 image_data_param {
   source: "all_shuffle_val.txt"
   batch_size: 30
   shuffle: false
 }
 transform_param {
   mean_value: 104.008
   mean_value: 116.669
   mean_value: 122.675
   crop_size: 48
   mirror: false
 }
 include: { phase: TEST}
}
layer {
 name: "conv1"
 type: "Convolution"
 bottom: "data"
 top: "conv1"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 convolution_param {
   num_output: 12
   pad: 1
   kernel_size: 3
   stride: 2
   weight_filler {
     type: "xavier"
     std: 0.01
   }
   bias_filler {
     type: "constant"
     value: 0.2
   }
 }
}
layer {
 name: "relu1"
 type: "ReLU"
 bottom: "conv1"
 top: "conv1"
}
layer {
 name: "conv2"
 type: "Convolution"
 bottom: "conv1"
 top: "conv2"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 convolution_param {
   num_output: 20
   kernel_size: 3
   stride: 2
   pad: 1
   weight_filler {
     type: "xavier"
     std: 0.1
   }
   bias_filler {
     type: "constant"
     value: 0.2
   }
 }
}
layer {
 name: "relu2"
 type: "ReLU"
 bottom: "conv2"
 top: "conv2"
}
layer {
 name: "conv3"
 type: "Convolution"
 bottom: "conv2"
 top: "conv3"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 convolution_param {
   num_output: 40
   kernel_size: 3
   stride: 2
   pad: 1
   weight_filler {
     type: "xavier"
     std: 0.1
   }
   bias_filler {
     type: "constant"
     value: 0.2
   }
 }
}
layer {
 name: "relu3"
 type: "ReLU"
 bottom: "conv3"
 top: "conv3"
}
layer {
 name: "ip1-mouth"
 type: "InnerProduct"
 bottom: "conv3"
 top: "pool-mouth"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 inner_product_param {
   num_output: 128
   weight_filler {
     type: "xavier"
   }
   bias_filler {
     type: "constant"
     value: 0
   }
 }
}

layer {
   bottom: "pool-mouth"
   top: "fc-mouth"
   name: "fc-mouth"
   type: "InnerProduct"
   param {
       lr_mult: 1
       decay_mult: 1
   }
   param {
       lr_mult: 2
       decay_mult: 1
   }
   inner_product_param {
       num_output: 2
       weight_filler {
           type: "xavier"
       }
       bias_filler {
           type: "constant"
           value: 0
       }
   }
}
layer {
   bottom: "fc-mouth"
   bottom: "clc-label"
   name: "loss"
   type: "SoftmaxWithLoss"
   top: "loss"
}
layer {
   bottom: "fc-mouth"
   bottom: "clc-label"
   top: "acc"
   name: "acc"
   type: "Accuracy"
   include {
       phase: TRAIN
   }
   include {
       phase: TEST
   }
}

可以看出,Caffe 的这个网络配置文件,每一个卷积层,都是以 layer{} 的形式定义,layer 的bottom、top 就是它的输入输出,type 就是它的类型,有的是数据层、有的是卷积层、有的是 loss 层。

我们采用 netscope 来可视化一下这个模型。

从上面看很直观的看到,网络的输入层是 data 层,后面接了3个卷积层,其中每一个卷积层都后接了一个 relu 层,最后 ip1-mouth、fc-mouth 是全连接层。Loss 和 acc 分别是计算 loss 和 acc 的层。

各层的配置有一些参数,比如 conv1 有卷积核的学习率、卷积核的大小、输出通道数、初始化方法等,这些可以后续详细了解。

(2)准备训练 list

我们看上面的 data layer,可以到 

image_data_param 里面有

source: "all_shuffle_train.txt"

它是什么呢,就是输入用于训练的 list,它的内容是这样的:

../../../../datas/mouth/1/182smile.jpg 1

../../../../datas/mouth/1/435smile.jpg 1

../../../../datas/mouth/0/40neutral.jpg 0

../../../../datas/mouth/1/206smile.jpg 1

../../../../datas/mouth/0/458neutral.jpg 0

../../../../datas/mouth/0/158neutral.jpg 0

../../../../datas/mouth/1/322smile.jpg 1

../../../../datas/mouth/1/83smile.jpg 1

../../../../datas/mouth/0/403neutral.jpg 0

../../../../datas/mouth/1/425smile.jpg 1

../../../../datas/mouth/1/180smile.jpg 1

../../../../datas/mouth/1/233smile.jpg 1

../../../../datas/mouth/1/213smile.jpg 1

../../../../datas/mouth/1/144smile.jpg 1

../../../../datas/mouth/0/327neutral.jpg 0

格式就是,图片的名字 + 空格 + label,这就是 Caffe 用于图片分类默认的输入格式。

(3)准备优化配置文件:

net: "./train.prototxt"

test_iter: 100

test_interval: 10

base_lr: 0.00001

momentum: 0.9

type: "Adam"

lr_policy: "fixed"

display: 100

max_iter: 10000

snapshot: 2000

snapshot_prefix: "./snaps/conv3_finetune"

solver_mode: GPU

介绍一下上面的参数。

net 是网络的配置路径。test_interval是指训练迭代多少次之后,进行一次测试。test_iter是测试多少个batch,如果它等于 1,就说明只取一个 batchsize 的数据来做测试,如果 batchsize 太小,那么对于分类任务来说统计出来的指标也不可信,所以最好一次测试,用到所有测试数据。因为,常令test_iter*test_batchsize=测试集合的大小。

base_lr、momentum、type、lr_policy是和学习率有关的参数,base_lr和lr_policy决定了学习率大小如何变化。type 是优化的方法,以后再谈。max_iter是最大的迭代次数,snapshot 是每迭代多少次之后存储迭代结果,snapshot_prefix为存储结果的目录,caffe 存储的模型后缀是 .caffemodel。solver_mode可以指定用 GPU 或者 CPU 进行训练。

(4)训练与结果可视化

我们利用 C++ 的接口进行训练,命令如下:

SOLVER=./solver.prototxt

WEIGHTS=./init.caffemodel

../../../../libs/Caffe_Long/build/tools/caffe train -solver $SOLVER -weights $WEIGHTS -gpu 0 2>&1 | tee log.txt

其中,caffe train 就是指定训练。我们可以利用脚本可视化一下训练结果,具体参考git项目:

 

03 Caffe 测试

上面我们得到了训练结果,下面开始采用自己的图片进行测试。

train.prototxt 与 test.prototxt 的区别

训练时的网络配置与测试时的网络配置是不同的,测试没有 acc 层,也没有 loss 层,取输出的 softmax 就是分类的结果。同时,输入层的格式也有出入,不需要再输入 label,也不需要指定图片 list,但是要指定输入尺度,我们看一下 test.prototxt 和可视化结果。

name: "mouth"
layer {
 name: "data"
 type: "Input"
 top: "data"
 input_param { shape: { dim: 1 dim: 3 dim: 48 dim: 48 } }
}

layer {
 name: "conv1"
 type: "Convolution"
 bottom: "data"
 top: "conv1"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 convolution_param {
   num_output: 12
   pad: 1
   kernel_size: 3
   stride: 2
   weight_filler {
     type: "xavier"
     std: 0.01
   }
   bias_filler {
     type: "constant"
     value: 0.2
   }
 }
}
layer {
 name: "relu1"
 type: "ReLU"
 bottom: "conv1"
 top: "conv1"
}
layer {
 name: "conv2"
 type: "Convolution"
 bottom: "conv1"
 top: "conv2"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 convolution_param {
   num_output: 20
   kernel_size: 3
   stride: 2
   pad: 1
   weight_filler {
     type: "xavier"
     std: 0.1
   }
   bias_filler {
     type: "constant"
     value: 0.2
   }
 }
}
layer {
 name: "relu2"
 type: "ReLU"
 bottom: "conv2"
 top: "conv2"
}
layer {
 name: "conv3"
 type: "Convolution"
 bottom: "conv2"
 top: "conv3"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 convolution_param {
   num_output: 40
   kernel_size: 3
   stride: 2
   pad: 1
   weight_filler {
     type: "xavier"
     std: 0.1
   }
   bias_filler {
     type: "constant"
     value: 0.2
   }
 }
}
layer {
 name: "relu3"
 type: "ReLU"
 bottom: "conv3"
 top: "conv3"
}
layer {
 name: "ip1-mouth"
 type: "InnerProduct"
 bottom: "conv3"
 top: "pool-mouth"
 param {
   lr_mult: 1
   decay_mult: 1
 }
 param {
   lr_mult: 2
   decay_mult: 0
 }
 inner_product_param {
   num_output: 128
   weight_filler {
     type: "xavier"
   }
   bias_filler {
     type: "constant"
     value: 0
   }
 }
}
layer {
   bottom: "pool-mouth"
   top: "fc-mouth"
   name: "fc-mouth"
   type: "InnerProduct"
   param {
       lr_mult: 1
       decay_mult: 1
   }
   param {
       lr_mult: 2
       decay_mult: 1
   }
   inner_product_param {
       num_output: 2
       weight_filler {
           type: "xavier"
       }
       bias_filler {
           type: "constant"
           value: 0
       }
   }
}
layer {
   bottom: "fc-mouth"
   name: "loss"
   type: "Softmax"
   top: "prob"
}

使用 Python 进行测试

由于 Python 目前广泛使用,下面使用 Python 来进行测试,它要做的就是导入模型、导入图片、输出结果。

下面是所有的代码,我们详细解释下:

---代码段1,这一段,我导入一些基本库,同时导入caffe的路径---

#_*_ coding:utf8

import sys

sys.path.insert(0, '../../../../../libs/Caffe_Long/python/')

import caffe

import os,shutil

import numpy as np

from PIL import Image as PILImage

from PIL import ImageMath

import matplotlib.pyplot as plt

import time

import cv2

---代码段2,这一段,我们添加一个参数解释器,方便参数管理---

debug=True

import argparse

def parse_args():

   parser = argparse.ArgumentParser(description='test resnet model for portrait segmentation')

   parser.add_argument('--model', dest='model_proto', help='the model', default='test.prototxt', type=str)

   parser.add_argument('--weights', dest='model_weight', help='the weights', default='./test.caffemodel', type=str)

   parser.add_argument('--testsize', dest='testsize', help='inference size', default=60,type=int)

   parser.add_argument('--src', dest='img_folder', help='the src image folder', type=str, default='./')

   parser.add_argument('--gt', dest='gt', help='the gt', type=int, default=0)

   args = parser.parse_args()

   return args

def start_test(model_proto,model_weight,img_folder,testsize):

---代码段3,这一段,我们就完成了网络的初始化---

   caffe.set_device(0)

   #caffe.set_mode_cpu()

   net = caffe.Net(model_proto, model_weight, caffe.TEST)

   imgs = os.listdir(img_folder)

   pos = 0

   neg = 0

   for imgname in imgs:

---代码段4,这一段,是读取图片并进行预处理,还记得我们之前的训练,是采用 BGR 的输入格式,减去了图像均值吧,同时,输入网络的图像,也需要 resize 到相应尺度。预处理是通过 caffe 的类,transformer 来完成,set_mean 完成均值,set_transpose 完成维度的替换,因为 caffe blob 的格式是 batch、channel、height、width,而 numpy 图像的维度是 height、width、channel 的顺序---

      imgtype = imgname.split('.')[-1]

      imgid = imgname.split('.')[0]

      if imgtype != 'png' and imgtype != 'jpg' and imgtype != 'JPG' and imgtype != 'jpeg' and imgtype != 'tif' and imgtype != 'bmp':

          print imgtype,"error"

          continue

      imgpath = os.path.join(img_folder,imgname)

      img = cv2.imread(imgpath)

      if img is None:

          print "---------img is empty---------",imgpath

          continue

      img = cv2.resize(img,(testsize,testsize))

      transformer = caffe.io.Transformer({'data': net.blobs['data'].data.shape})

      transformer.set_mean('data', np.array([104.008,116.669,122.675]))

      transformer.set_transpose('data', (2,0,1))

---代码段5,这一段,就得到了输出结果了,并做一些可视化显示---

      out = net.forward_all(data=np.asarray([transformer.preprocess('data', img)]))

      result = out['prob'][0]

      print "---------result prob---------",result,"-------result size--------",result.shape

      probneutral = result[0]

      print "prob neutral",probneutral 

      probsmile = result[1]

      print "prob smile",probsmile

      problabel = -1

      probstr = 'none'

      if probneutral > probsmile:

          probstr = "neutral:"+str(probneutral)

          pos = pos + 1

      else:

          probstr = "smile:"+str(probsmile)

          neg = neg + 1

      if debug:

         showimg = cv2.resize(img,(256,256))

         cv2.putText(showimg,probstr,(30,50),cv2.FONT_HERSHEY_SIMPLEX,1,(0,0,255),1)

         cv2.imshow("test",showimg)

         k = cv2.waitKey(0)

         if k == ord('q'):

             break

   print "pos=",pos 

   print "neg=",neg 

if __name__ == '__main__':

    args = parse_args()

    start_test(args.model_proto,args.model_weight,args.img_folder,args.testsize)

经过前面的介绍,我们已经学会了 Caffe 的基本使用,但是我们不能停留于此。Caffe 是一个非常优秀的开源框架,有必要去细读它的源代码。

至于怎么读 Caffe 的代码,建议阅读我写的Caffe代码阅读系列内容。

 

04 总结

虽然现在很多人没有从 Caffe 开始学,但是希望提升自己 C++ 水平和更深刻理解深度学习中的一些源码的,建议从 Caffe 开始学起。

 

同时,在我的知乎专栏也会开始同步更新这个模块,欢迎来交流

https://zhuanlan.zhihu.com/c_151876233

注:部分图片来自网络

—END—

本系列完整文章:

第一篇:【caffe速成】caffe图像分类从模型自定义到测试

第二篇:【tensorflow速成】Tensorflow图像分类从模型自定义到测试

第三篇:【pytorch速成】Pytorch图像分类从模型自定义到测试

第四篇:【paddlepaddle速成】paddlepaddle图像分类从模型自定义到测试

第五篇:【Keras速成】Keras图像分类从模型自定义到测试

第六篇:【mxnet速成】mxnet图像分类从模型自定义到测试

第七篇:【cntk速成】cntk图像分类从模型自定义到测试

第八篇:【chainer速成】chainer图像分类从模型自定义到测试

第九篇:【DL4J速成】Deeplearning4j图像分类从模型自定义到测试

第十篇:【MatConvnet速成】MatConvnet图像分类从模型自定义到测试

第十一篇:【Lasagne速成】Lasagne/Theano图像分类从模型自定义到测试

第十二篇:【darknet速成】Darknet图像分类从模型自定义到测试

感谢各位看官的耐心阅读,不足之处希望多多指教。后续内容将会不定期奉上,欢迎大家关注有三公众号 有三AI!

 

从玩具到工业:手把手教你用Webots仿真Scara抓取(逆解实战篇) 本文详细介绍了如何在Webots仿真环境中实现Scara机械臂的逆解计算与抓取操作,涵盖从环境配置、逆运动学算法到轨迹规划与实时控制的完整流程。通过实战案例演示,帮助读者掌握机械臂逆解的核心技术,并应用于工业自动化场景,提升Scara机械臂的编程与控制能力。 阅读详情

相关推荐

银河麒麟系统V10 sp1,安装wine 9.0

银河麒麟系统V10 sp1 x86_64,安装wine 9.0

daqinzl的专栏 1万+

Caffe傻瓜系列(9):训练和测试自己的图片

在深度学习的实际应用中,我们经常用到的原始数据是图片文件,如jpg,jpeg,png,tif等格式的,而且有可能图片的大小还不一致。而在caffe中经常使用的数据类型是lmdb或leveldb,因此就产生了这样的一个问题:如何从原始图片文件转换成caffe中能够运行的db(leveldb/lmdb)文件? 在caffe中,作者为我们提供了这样一个文件:convert_imageset.c

深藏功与名 1万+

Ubuntu22.04通过DKMS包安装Intel WiFi系列适配器(网卡驱动)

Ubuntu安装Intel WiFi系列适配器(网卡驱动)

lu_linux的博客 2603

!!使用Caffe对图片进行训练并分类的简单流程

step 1.      首先,确保caffe已经正确安装,并且make runtest基本通过。   step 2.      准备训练集:         在训练之前,要准备训练需要的训练集,为了验证训练的效果,最好也准备一定数量的测试集。由于caffe的数据集的输入是leveldb格式,因此在训练前需要将输入转为相应格式。         在caffe_root/example 文件

1805

macOS 12.7.6部署Ollama+Dify避坑指南

本文介绍了在macOS 12.7.6系统下部署Ollama和Dify的详细步骤及避坑指南。主要内容包括:1)关闭系统完整性保护(SIP)以允许修改系统目录;2)安装特定版本的Docker(2.1.0.5)和docker-compose(v2.38.2)以避免兼容性问题;3)配置Ollama服务并下载nomic-embed-text和deepseek-r1:7b模型;4)针对macOS调整Dify的docker配置文件,包括延长超时时间、修改存储路径、增加资源限制等关键设置。文中提供了完整的命令操作步骤和配置

Hi20240217的博客 3108

OpenClaw与Ollama本地AI部署指南

AI模型本地化部署是当前企业数字化转型的关键技术,通过开源框架Ollama可以在消费级硬件上运行大语言模型。本文以OpenClaw多智能体系统为例,详解从环境配置到模型优化的全流程实践,特别针对国内开发者遇到的网络问题提供了镜像加速等解决方案。这种私有化部署方案尤其适合金融数据分析、企业知识管理等对数据安全要求高的场景,通过模块化设计实现多智能体协作,同时保持对NVIDIA显卡和普通CPU的兼容性。

weixin_34302561的博客 400

caffe图像分类教程_实践详细篇-Windows下使用Caffe训练自己的Caffemodel数据集并进行图像分类...

三:使用Caffe训练Caffemodel并进行图像分类上一篇记录的是如何使用别人训练好的MNIST数据做训练测试。上手操作一边后大致了解了配置文件属性。这一篇记录如何使用自己准备的图片素材做图像分类。第一篇《实践详细篇-Windows下使用VS2015编译安装Caffe环境(CPU ONLY)》有讲过使用Caffe的背景.所以这篇记录使用的素材就是12306的验证码来进行图像识别分类。1、准备...

weixin_39683144的博客 409

在VM虚拟机的MobaXterm下安装JDK17

本文介绍了在Linux系统下安装配置JDK17的完整步骤:1)从Oracle或OpenJDK官网下载Linux版JDK17压缩包;2)上传至/usr/local目录;3)解压安装包;4)通过编辑/etc/profile文件配置环境变量,添加JAVA_HOME和PATH路径;5)使用source命令使配置生效;6)通过javac -version验证安装是否成功。整个过程涵盖了从下载到环境配置的完整流程,确保Java开发环境正确设置。

qq_2937655951的博客 442

python+caffe训练自己的图片数据流程

1. 准备自己的图片数据 选用部分的Caltech数据库作为训练和测试样本。Caltech是加州理工学院的图像数据库,包含Caltech101和Caltech256两个数据集。该数据集是由Fei-FeiLi, Marco Andreetto, Marc 'Aurelio Ranzato在2003年9月收集而成的。Caltech101包含101种类别的物体,每...

weixin_30321449的博客 488

龙头复盘神器/复盘于导出工具最新版5.6

龙头复盘神器,复盘于导出工具

初入python踩过的坑 8254

手把手教你学Simulink--基于车联网与智能交通系统的场景实例:基于车联网(V2X)的实时路况信息共享与处理

《基于Simulink的车联网(V2X)实时路况共享系统仿真》摘要:本文详细介绍使用Simulink构建V2X智能交通系统的完整方法。系统包含交通路网建模、V2X通信实现(支持DSRC/C-V2X标准)、多源路况信息融合、动态路径规划等核心模块。通过对比实验,验证V2X可使平均车速提升52%,行程时间缩短34%,显著提升交通效率。文章还探讨了AI预测调度、车辆编队等高级应用,为智慧交通系统开发提供实用参考。所需工具包括Simulink、SimEvents及无线通信工具箱等。

MHD0815的博客 739

caffe训练(10)自己训练的caffemodel批量预测新图片--无其他参数(如准确率等)

#coding=utf-8 import sys caffe_root='D:/caffe-master/' #修改成你的Caffe项目路径 sys.path.append(caffe_root+'python') import caffe caffe.set_mode_gpu() #设置为GPU运行 import numpy as np # from pylab import * # 修改成...

weixin_42535423的博客 362

2025年下半年网络规划设计师综合知识真题及答案解析

1983年,ARPANet完成技术转型,对此后的 Internet发展全关重要,这一转型是指( ) A.电路交换转向分组交换 B.商业化转型 C.民用化转型 D.从 NCP 协议转向 TCP/IP 答案:D 解析:ARPANet 最初使用 NCP (Network Control Protocol)协议进行主机问通信。1983年1月1日,ARPANet 正式切换到TCP/IP 协议族,为后续Internet的发展奠定了统一协议基础。

鹿鸣天涯 945

「caffe速成」caffe图像分类从模型自定义到测试

https://www.toutiao.com/a6697741728985645581/ 这一次我们讲讲 Caffe 这个主流的开源框架从训练到测试出结果的全流程。到此,我必须假设大家已经有了深度学习的基础知识并了解卷积网络的工作原理。 相关的代码、数据都在我们 Git 上,希望大家 Follow 一下这个 Git 项目,后面会持续更新不同框架下的任务。 https://githu...

喜欢打酱油的老鸟 357

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

darknet框架_【通知】有三AI发布150页深度学习开源框架指导手册与GitHub项目,欢迎加入我们的开源团队...

之前我们公众号输出了很多深度学习开源框架相关的内容,今天整理成技术手册给大家分享以方便阅读,下面是详细信息。开源框架背景现如今开源生态非常完善,深度学习相关的开源框架众多,光是为人熟知的就有caffe,tensorflow,pytorch/caffe2,keras,mxnet,paddldpaddle,theano,cntk,deeplearning4j,matconvnet等。如何选择...

weixin_39780962的博客 88

深度学习工具包 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")

darknet框架_【杂谈】超过12个,150页深度学习开源框架指导手册与GitHub项目,初学CV你值得拥有...

之前我们公众号输出了很多深度学习开源框架相关的内容,今天整理成技术手册给大家分享以方便阅读,下面是详细信息。开源框架背景现如今开源生态非常完善,深度学习相关的开源框架众多,光是为人熟知的就有caffe,tensorflow,pytorch/caffe2,keras,mxnet,paddldpaddle,theano,cntk,deeplearning4j,matconvnet等。如何选择...

weixin_39745269的博客 92

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

darknet框架_【杂谈】面向新手的深度学习开源框架指导手册与GitHub项目,欢迎加入我们的开源团队...

之前我们公众号输出了很多深度学习开源框架相关的内容,现在整理成技术手册给大家分享以方便阅读,下面是详细信息。开源框架背景现如今开源生态非常完善,深度学习相关的开源框架众多,光是为人熟知的就有caffe,tensorflow,pytorch/caffe2,keras,mxnet,paddldpaddle,theano,cntk,deeplearning4j,matconvnet等。如何选择...

weixin_39634438的博客 123

【pytorch速成】Pytorch图像分类从模型自定义到测试

文章首发于微信公众号《与有三学AI》 【pytorch速成】Pytorch图像分类从模型自定义到测试 前面已跟大家介绍了Caffe和TensorFlow,链接如下。 【caffe速成】caffe图像分类从模型自定义到测试 【tensorflow速成】Tensorflow图像分类从模型自定义到测试 今天说说Pytorch。 作者&编辑|言有三 01 什么是 Py...

hacker_long的专栏 1万+

【darknet速成】Darknet图像分类从模型自定义到测试

欢迎来到专栏《2小时玩转开源框架系列》,这是我们第12篇文章,前面已经说过了caffe,tensorflow,pytorch,mxnet,keras,paddlepaddle,cntk,chainer,deeplearning4j,matconvnet,lasagne。 今天说darknet,也是最后一个框架了,本文所用到的数据,代码请参考我们官方git https://github.com/...

hacker_long的专栏 3168

【tensorflow速成】Tensorflow图像分类从模型自定义到测试

文章首发于微信公众号《与有三学AI》 【tensorflow速成】Tensorflow图像分类从模型自定义到测试 这是给大家准备的tensorflow速成例子 上一篇介绍了 Caffe ,这篇将介绍 TensorFlow。 01 什么是 TensorFlow TensorFlow 是 Google brain 推出的开源机器学习库,与 Caffe 一样,主要用作深度学习相关...

hacker_long的专栏 2339

【paddlepaddle速成】paddlepaddle图像分类从模型自定义到测试

文章首发于微信公众号《与有三学AI》 【paddlepaddle速成】paddlepaddle图像分类从模型自定义到测试 这是给大家准备的paddlepaddle与visualdl速成例子 这一次我们讲讲paddlepadle这个百度开源的机器学习框架,一个图像分类任务从训练到测试出结果的全流程。 将涉及到paddlepaddle和visualdl,git如下:https://github...

hacker_long的专栏 3395

pytorch模型加载测试_「pytorch速成」Pytorch图像分类从模型自定义到测试

原标题:「pytorch速成」Pytorch图像分类从模型自定义到测试前面已跟大家介绍了Caffe和TensorFlow,今天说说Pytorch。1 什么是 Pytorch一句话总结 Pytorch = Python + Torch。Torch 是纽约大学的一个机器学习开源框架,几年前在学术界非常流行,包括 Lecun等大佬都在使用。但是由于使用的是一种绝大部分人绝对没有听过的 Lua 语言,导致...

weixin_39595487的博客 443

pytorch模型加载测试_【Pytorch速成】Pytorch图像分类从模型自定义到测试

前面已跟大家介绍了 Caffe 和 TensorFlow,现在说说 Pytorch,集齐三大主流框架以后方便召唤模型。1 什么是 Pytorch一句话总结 Pytorch = Python + Torch。Torch 是纽约大学的一个机器学习开源框架,几年前在学术界非常流行,包括 Lecun 等大佬都在使用。但是由于使用的是一种绝大部分人绝对没有听过的 Lua 语言,导致很多人都被吓退。后来随着 ...

weixin_39531761的博客 390

【mxnet速成】mxnet图像分类从模型自定义到测试

文章首发于微信公众号《与有三学AI》 【mxnet速成】mxnet图像分类从模型自定义到测试 这是给大家准备的mxnet速成例子 这一次我们讲讲mxnet,相关的代码、数据都在我们 Git 上,希望大家 Follow 一下这个 Git 项目,后面会持续更新不同框架下的任务。 https://github.com/longpeng2008/LongPeng_ML_Course 作者&amp...

hacker_long的专栏 1025

安装mxnet 镜像_【mxnet速成】mxnet图像分类从模型自定义到测试

这一次我们讲讲mxnet,相关的代码、数据都在我们 Git 上,希望大家 Follow 一下这个 Git 项目,后面会持续更新不同框架下的任务。https://github.com/longpeng2008/LongPeng_ML_Course 01 mxnet是什么mxnet是amazon的官方框架,下面参考mxnet的官方简介https://mxnet-bing.readthedocs.io/...

weixin_30877689的博客 345

coco训练集darknet_【darknet速成】Darknet图像分类从模型自定义到测试

欢迎来到专栏《2小时玩转开源框架系列》,这是我们第12篇文章,前面已经说过了caffe,tensorflow,pytorch,mxnet,keras,paddlepaddle,cntk,chainer,deeplearning4j,matconvnet,lasagne。今天说darknet,也是最后一个框架了,本文所用到的数据,代码请参考我们官方git https://github.com/lon...

weixin_39747383的博客 370
上一篇: 【模型解读】“不正经”的卷积神经网络
下一篇: 【tensorflow速成】Tensorflow图像分类从模型自定义到测试
言有三
言有三 领域专家: 人工智能技术领域 领域专家: 人工智能技术领域
博客等级 码龄15年 3635粉丝 976原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

言有三

三人行必有AI

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值