Caffe中对MNIST执行train操作执行流程解析

2023-11-10

之前在 http://blog.csdn.net/fengbingchun/article/details/49849225 中简单介绍过使用Caffe train MNIST的文章,当时只是仿照caffe中的example实现了下,下面说一下执行流程,并精简代码到仅有10余行:

1.        先注册所有层,执行layer_factory.hpp中类LayerRegisterer的构造函数,类LayerRegistry的AddCreator和Registry静态函数;关于Caffe中Layer的注册可以参考 http://blog.csdn.net/fengbingchun/article/details/54310956

2.        指定执行mode是采用CPU还是GPU;

3.        构造SolverParameter类对象,存放Solver 参数信息;

4.        调用ReadProtoFromTextFile函数解析Solver文本文件(lenet_solver.prototxt),其文件内的各字段名需要在caffe.proto的message SolverParameter中存在,否则会解析不成功,其文件内容如下:

# The train/test net protocol buffer definition
# Proto filename for the train net, possibly combined with one or more test nets.
# train net 和 test net在同一个文件中
net: "E:/GitCode/Caffe_Test/test_data/model/mnist/lenet_train_test.prototxt"
# Solver type,采用哪种Solver优化方法
solver_type: SGD
# test_iter specifies how many forward passes the test should carry out.
# In the case of MNIST, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
# The number of iterations for each test net.
# batch size * test iter = test images,即 100 * 100 = 10000
test_iter: 100
# Carry out testing every 500 training iterations.
# The number of iterations between two testing phases.
#  指定执行多少次训练网络执行一次测试网络
test_interval: 500
# The base learning rate, momentum and the weight decay of the network.
# The base learning rate, 基础学习率
base_lr: 0.01
# The momentum value, 动量
momentum: 0.9
# The weight decay, 权值衰减
weight_decay: 0.0005
# The learning rate policy, 学习策略
lr_policy: "inv"
# The parameter to compute the learning rate,学习率计算参数
gamma: 0.0001
# The parameter to compute the learning rate,学习率计算参数
power: 0.75
# Display every 100 iterations
# the number of iterations between displaying info.
# If display = 0, no info will be displayed.
# 指定训练多少次显示一次结果信息,如loss值等
display: 100
# The maximum number of iterations,最多执行训练次数
max_iter: 10000
# snapshot intermediate results,执行多少次训练保存一次中间结果
snapshot: 5000
# The prefix for the snapshot, file save position,中间结果保存位置
snapshot_prefix: "E:/GitCode/Caffe_Test/test_data/model/mnist/lenet"

5.        将MNIST原始数据转换成LMDB数据库格式,在train和test时会使用;

6.        根据Solver type,New一个SGDSolver类对象并进行初始化操作:

(1)、调用GetSolver函数,new一个SGDSolver了对象;

(2)、调用Solver类的Init函数;

(3)、调用SolverParameter的DebugString函数打印解析后的lenet_solver.prototxt信息,输出结果如下:

test_iter: 100
test_interval: 500
base_lr: 0.01
display: 100
max_iter: 10000
lr_policy: "inv"
gamma: 0.0001
power: 0.75
momentum: 0.9
weight_decay: 0.0005
snapshot: 5000
snapshot_prefix: "E:/GitCode/Caffe_Test/test_data/model/mnist/lenet"
net: "E:/GitCode/Caffe_Test/test_data/model/mnist/lenet_train_test.prototxt"
solver_type: SGD

(4)、调用ReadNetParamsFromTextFileOrDie函数,解析lenet_train_test.prototxt文件(此文件中的各个layer段的位置不是固定的,每个layer内的各个段位置也不是固定的,它们的位置无关紧要,只是一般按照流程顺序从上到下排列),各个字段的说明如下:

name: "LeNet" # net名
layer { # memory required: (50175+64)*4=200960
  name: "mnist" # layer名字
  type: "Data" # layer类型,数据层,Data enters Caffe through data layers,read data from LEVELDB or LMDB
  top: "data" # top名字, shape: 64 1 28 28 (50175)
  top: "label" # top名字, shape: 64 (64)
  include { # 指定何时将此layer mnist包含到网络中
    phase: TRAIN # 训练阶段会将此layer mnist包含到网络中
  }
  transform_param { # 图像预处理
    scale: 0.00390625 # 对图像像素值进行scale操作,范围[0, 1)
  }
  data_param { # data parameter
    source: "E:/GitCode/Caffe_Test/test_data/MNIST/train" # 数据存放路径
    batch_size: 64 # 指定一次处理图像的数量
    backend: LMDB # 数据存储方式
  }
}
layer { # memory required: (78400+100)*4=314000
  name: "mnist" # layer名字
  type: "Data" # layer类型,数据层,Data enters Caffe through data layers,read data from LEVELDB or LMDB
  top: "data" # top名字, shape: 100 1 28 28 (78400)
  top: "label" # top名字, shape: 100 (100)
  include { # 指定何时将此layer mnist包含到网络中
    phase: TEST # 测试阶段会将此layer mnist包含到此网络中
  }
  transform_param { # 图像预处理
    scale: 0.00390625 # 对图像像素值进行scale操作,范围[0, 1)
  }
  data_param { # data parameter
    source: "E:/GitCode/Caffe_Test/test_data/MNIST/test" # 数据存放路径
    batch_size: 100 # 指定一次处理图像的数量
    backend: LMDB # 数据存储方式
  }
}
# test 阶段会创建一个layer: label_mnist_1_split,如下:
# layer_factory.hpp:75] Creating layer label_mnist_1_split
# net.cpp:110] Creating Layer label_mnist_1_split
# net.cpp:476] label_mnist_1_split <- label
# net.cpp:432] label_mnist_1_split -> label_mnist_1_split_0
# net.cpp:432] label_mnist_1_split -> label_mnist_1_split_1
# net.cpp:155] Setting up label_mnist_1_split
# net.cpp:163] Top shape: 100 (100)
# net.cpp:163] Top shape: 100 (100)
layer { # memory required: 737280*4=2949120/1152000*4=4608000
  name: "conv1" # layer名字
  type: "Convolution" # layer类型,卷积层
  bottom: "data" # bottom名字
  top: "conv1" # top名字, shape: 64 20 24 24 (737280)/100 20 24 24 (1152000)
  param { # 训练时用到的参数
    lr_mult: 1 # The multiplier on the global learning rate
  }
  param { # 训练时用到的参数
    lr_mult: 2 # The multiplier on the global learning rate
  }
  convolution_param { # convolution parameter
    num_output: 20 # 输出特征图(feature map)数量
    kernel_size: 5 # 卷积核大小(卷积核其实就是权值)
    stride: 1 # 滑动步长
    weight_filler { # The filler for the weight
      type: "xavier" # 权值使用xavier滤波
    }
    bias_filler { # The filler for the bias
      type: "constant" # 偏置使用常量滤波
    }
  }
}
layer { # memory required: 184320*4=737280/288000*4=1152000
  name: "pool1" # layer名字
  type: "Pooling" # layer类型,Pooling层
  bottom: "conv1" # bottom名字
  top: "pool1" # top名字, shape: 64 20 12 12 (184320)/ 100 20 12 12 (288000)
  pooling_param { # pooling parameter,pooling层参数
    pool: MAX # pooling方法:最大值采样
    kernel_size: 2 # 滤波器大小
    stride: 2 # 滑动步长
  }
}
layer { # memory required: 204800*4=819200/320000*4=1280000
  name: "conv2" # layer名字
  type: "Convolution" # layer类型,卷积层
  bottom: "pool1" # bottom名字
  top: "conv2" # top名字, shape: 64 50 8 8 (204800)/ 100 50 8 8 (320000)
  param { # 训练时用到的参数
    lr_mult: 1 # The multiplier on the global learning rate
  }
  param { # 训练时用到的参数
    lr_mult: 2 # The multiplier on the global learning rate
  }
  convolution_param { # convolution parameter,卷基层参数
    num_output: 50 # 输出特征图(feature map)数量
    kernel_size: 5 # 卷积核大小(卷积核其实就是权值)
    stride: 1 # 滑动步长
    weight_filler { # The filler for the weight
      type: "xavier" # 权值使用xavier滤波
    }
    bias_filler { # The filler for the bias
      type: "constant" # 偏置使用常量滤波
    }
  }
}
layer { # memory required: 51200*4=204800/80000*4=320000
  name: "pool2" # layer名字
  type: "Pooling" # layer类型,Pooling层
  bottom: "conv2" # bottom名字
  top: "pool2" # top名字, shape: 64 50 4 4 (51200)/ 100 50 4 4 (80000)
  pooling_param { # pooling parameter,卷积层参数
    pool: MAX # pooling方法:最大值采样
    kernel_size: 2 # 滤波器大小
    stride: 2 # 滑动步长
  }
}
layer { # memory required: 32000*4=128000/50000*4=200000
  name: "ip1" # layer名字
  type: "InnerProduct" # layer类型,全连接层
  bottom: "pool2" # bottom名字
  top: "ip1" # top名字, shape: 64 500 (32000)/ 100 500 (50000)
  param { # 训练时用到的参数
    lr_mult: 1 # The multiplier on the global learning rate
  }
  param { # 训练时用到的参数
    lr_mult: 2 # The multiplier on the global learning rate
  }
  inner_product_param { # 全连接层参数
    num_output: 500 # 输出特征图(feature map)数量
    weight_filler { # The filler for the weight
      type: "xavier" # 权值使用xavier滤波
    }
    bias_filler { # The filler for the bias
      type: "constant" # 偏置使用常量滤波
    }
  }
}
# ReLU: Given an input value x, The ReLU layer computes the output as x if x > 0 and 
# negative_slope * x if x <= 0. When the negative slope parameter is not set,
# it is equivalent to the standard ReLU function of taking max(x, 0).
# It also supports in-place computation, meaning that the bottom and
# the top blob could be the same to preserve memory consumption
layer { # memory required: 32000*4=128000/50000*4=200000
  name: "relu1" # layer名字
  type: "ReLU" # layer类型
  bottom: "ip1" # bottom名字
  top: "ip1" # top名字 (in-place), shape: 64 500 (32000)/ 100 500 (50000)
}
layer { # memory required: 640*4=2560/1000*4=4000
  name: "ip2" # layer名字
  type: "InnerProduct" # layer类型,全连接层
  bottom: "ip1" # bottom名字
  top: "ip2" # top名字, shape: 64 10 (640)/ 100 10 (1000)
  param { # 训练时用到的参数
    lr_mult: 1 # The multiplier on the global learning rate
  }
  param { # 训练时用到的参数
    lr_mult: 2 # The multiplier on the global learning rate
  }
  inner_product_param { # 全连接层参数
    num_output: 10 # 输出特征图(feature map)数量
    weight_filler { # The filler for the weight
      type: "xavier" # 权值使用xavier滤波
    }
    bias_filler { # The filler for the bias
      type: "constant" # 偏置使用常量滤波
    }
  }
}
# test阶段会创建一个layer: ip2_ip2_0_split,如下:
# layer_factory.hpp:75] Creating layer ip2_ip2_0_split
# net.cpp:110] Creating Layer ip2_ip2_0_split
# net.cpp:476] ip2_ip2_0_split <- ip2
# net.cpp:432] ip2_ip2_0_split -> ip2_ip2_0_split_0
# net.cpp:432] ip2_ip2_0_split -> ip2_ip2_0_split_1
# net.cpp:155] Setting up ip2_ip2_0_split
# net.cpp:163] Top shape: 100 10 (1000)
# net.cpp:163] Top shape: 100 10 (1000)
layer { # memory required: 1*4=4
  name: "accuracy" # layer名字
  type: "Accuracy" # layer类型,计算输出准确率
  bottom: "ip2" # bottom名字
  bottom: "label" # bottom名字
  top: "accuracy" # top名字, shape: (1)
  include { # 指定何时将此layer accuracy包含到网络中
    phase: TEST # 测试阶段会将此layer accuracy包含到此网络中
  }
}
# SoftmaxWithLoss: Computes the multinomial logistic loss for a one-of-many
# classification task, passing real-valued predictions through a
# softmax to get a probability distribution over classes.
layer { # memory required: 1*4=4/1*4=4
  name: "loss" # layer名字
  type: "SoftmaxWithLoss" # layer类型
  bottom: "ip2" # bottom名字
  bottom: "label" # bottom名字
  top: "loss" # top名字, shape: (1)/ (1)
}

# 在训练网络中,占用总内存大小为:200960+2949120+737280+819200+204800+128000+128000+2560+4=5169924
# 在测试网络中,占用总内存大小为:314000+(100+100)*4+4608000+1152000+1280000+320000+200000+200000+4000+(1000+1000)*4+4+4=8086808
lenet_train_test.prototxt可视化结果如下图( http://ethereon.github.io/netscope/quickstart.html):此视图给出的是train阶段时的流程图,不包括测试阶段:


(5)、创建训练网络Net对象,并调用Net类的InitTrainNet函数构建训练网络,训练网络输出结果如下:

name: "LeNet"
state {
  phase: TRAIN
}
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "E:/GitCode/Caffe_Test/test_data/MNIST/train"
    batch_size: 64
    backend: LMDB
  }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 20
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 50
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}
(6)、创建测试网络Net对象,并调用Net类的InitTestNets函数构建测试网络,测试网络输出结果如下:

name: "LeNet"
state {
  phase: TEST
}
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "E:/GitCode/Caffe_Test/test_data/MNIST/test"
    batch_size: 100
    backend: LMDB
  }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 20
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 50
    kernel_size: 5
    stride: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}
(7)、调用SGDSolver类的PreSolve函数。

7.        调用Solver类的Solve函数开始进行训练和测试:

(1)、当训练次数是500的倍数时(在lenet_solver.prototxt中设置test_interval为500),执行一次测试网络的Forward计算,循环100次(在lenet_solver.prototxt中设置test_iter为100,在lenet_train_test.prototxt文件中,测试阶段batch size为100,这样100*100=10000正好覆盖到所有的测试图像),测试网络最终会有两个结果输出,一个是accuracy,一个是loss;

(2)、执行一次训练网络的ForwardBackward计算,训练网络最终会有一个结果输出即loss;

(3)、更新训练网络的权值和偏置;

(4)、每训练5000次(在lenet_solver.prototxt中设置snapshot为5000)保存一次结果,包括.caffemodel和.caffestate;

(5)、按照以上(1)、(2)、(3)、(4)中的步骤,循环执行10000次(在lenet_solver.prototxt中设置max_iter为10000)。

精简后的mnist train代码如下:

#include "funset.hpp"
#include "common.hpp"

int mnist_train()
{
	caffe::Caffe::set_mode(caffe::Caffe::CPU);

	const std::string filename{ "E:/GitCode/Caffe_Test/test_data/model/mnist/lenet_solver.prototxt" };
	caffe::SolverParameter solver_param;
	if (!caffe::ReadProtoFromTextFile(filename.c_str(), &solver_param)) {
		fprintf(stderr, "parse solver.prototxt fail\n");
		return -1;
	}

	mnist_convert(); // convert MNIST to LMDB

	boost::shared_ptr<caffe::Solver<float> > solver(caffe::GetSolver<float>(solver_param));
	solver->Solve();

	fprintf(stderr, "train finish\n");
	return 0;
}
train最终结果如下:



GitHubhttps://github.com/fengbingchun/Caffe_Test

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Caffe中对MNIST执行train操作执行流程解析 的相关文章

  • nVidia TK1 基于深度学习框架 Caffe 的物体识别

    By Toradex 胡珊逢 1 简介 深度学习目前正吸引着越来越多人的关注 相关算法框架层出不穷 例如TensorFlow Caffe Keras CNTK Torch7等等 这些算法在数据分析 聚类 识别和预测方面提供了极大的帮助 因此
  • Windows下编译caffe

    Windows下编译caffe 最近在windows上重新部署了下caffe 发现微软对提供的caffe做了很多改进 解决了很多编译配置的bug 程序下载caffe依赖包NugetPackages和编译速度也快了很多 现在上手caffe算是
  • Windows 版 Caffe 中的未知图层类型(裁剪)

    我想使用以下卷积神经网络 http lmb informatik uni freiburg de people ronneber u net 与咖啡构建https github com BVLC caffe tree windows 适用于
  • 大图像的语义分割

    我正在处理数量有限的大尺寸图像 每个图像都可以有3072 3072像素 为了使用 FCN 或 U net 训练语义分割模型 我构建了一个大样本的训练集 每个训练图像是128 128 在预测阶段 我所做的是将大图像切成小块 与训练集相同128
  • Caffe sigmoid交叉熵损失

    我正在使用 sigmoid 交叉熵损失函数来解决多标签分类问题 如下所示本教程 然而 在他们的教程结果和我的结果中 输出预测都在范围内 Inf Inf 而 sigmoid 的范围是 0 1 sigmoid 仅在反向传播中处理吗 也就是说 前
  • 如何将 cv::MAT 转换为 NHCW 格式?

    在User Guide html中 tensorRT的输入 输出需要使用NCHW格式 什么是 NCHW 格式 如何将 cv MAT 转换为 NCHW 格式 我使用 TensorRT 运行推理 如下代码所示 没有任何错误 但是 这不是正确的输
  • 如何编写带有预加载的caffe python数据层?

    如何编写异步数据层以在执行其他处理时预加载批次 有一些示例代码吗 谢谢 有多种方法可以实现您想要的目标 我将尝试在这里勾勒出一种选择 系统的总体视图是 你有n Loader异步加载数据并送入队列 然后该层读取batch size队列中的项目
  • 如何修改Imagenet Caffe模型?

    我想修改 ImageNet caffe 模型 如下所述 由于时间网络的输入通道数与此不同 空间网络 20 vs 3 我们对 ImageNet 模型滤波器进行平均 先跨过通道一层 然后复制平均结果 20 时间网络的初始化 我的问题是如何才能达
  • OpenCV 深度学习人脸检测函数“cv::dnn::ConvolutionLayerImpl::getMemoryShapes”中的断言错误

    我跟着tutorial https www pyimagesearch com 2018 02 26 face detection with opencv and deep learning 实现人脸检测image https ibb co
  • 打开deploy.prototxt时出现运行时错误

    我正在尝试使用 caffe 运行一个应该打开的简单代码deploy prototxt但它无法打开文件并引发此错误 RuntimeError Could not open file home ebadawy git caffemodels b
  • Caffe 中的“lr_policy”是什么?

    我只是想知道如何使用Caffe http caffe berkeleyvision org 为此 我只是看看不同的 prototxt示例文件夹中的文件 有一个选项我不明白 The learning rate policy lr policy
  • 在 Python 中未安装 caffe 的情况下从 .caffemodel 中提取权重

    有没有一种相对简单的方法可以从 Caffe Zoo 中的众多预训练模型之一中提取 Python 中的权重没有咖啡 也不是 pyCaffe 即解析 caffemodel转换为 hdf5 numpy 或任何 Python 可以读取的格式 我找到
  • 使用 Caffe 没有提高 RMSprop、Adam、AdaDelta 测试精度

    I am finetuning using Caffe在图像数据集上Tesla K40 用一个batch size 47 solver type SGD base lr 0 001 lr policy step momentum 0 9 g
  • Caffe的train.prototxt中平均值的顺序是什么?

    在我的咖啡馆里 train prototxt 我正在做一些输入数据转换 如下所示 transform param mirror true crop size 321 mean value 104 Red mean value 116 Blu
  • Caffe 到 Tensorflow(Kaffe by Ethereon):TypeError:不应直接创建描述符,而只能从其父级检索

    我想使用 ethereon 的精彩包 caffe tensorflow 但遇到了中描述的相同问题这个已关闭的问题 https github com ethereon caffe tensorflow issues 10 当我运行该示例或尝试
  • Caffe 求解器中的average_loss 字段有什么用?

    有什么用average loss 有人可以举个例子或者用通俗易懂的语言解释一下吗 您可以在caffe proto https github com BVLC caffe blob master src caffe proto caffe p
  • 在caffe中定义新层时如何获取学习率或迭代次数

    我想当迭代次数达到一定次数时改变损失层中的损失计算方法 为了实现它 我认为我需要获取当前的学习率或迭代次数 然后我使用if短语选择是否改变损失计算方法 您可以添加一个成员变量咖啡类保存当前的学习率或迭代次数并在您想要的层中访问它 例如 要获
  • 如何设计深度卷积神经网络? [关闭]

    Closed 这个问题不符合堆栈溢出指南 help closed questions 目前不接受答案 据我了解 所有 CNN 都非常相似 它们都有一个卷积层 后面是池化层和 relu 层 有些具有专门的层 例如 FlowNet 和 Segn
  • 在 Yosemite 上编译 caffe

    我正在尝试在 Yosemite 上安装 caffe 但我的 C 不是最强的 这是我的错误 Alis MacBook Pro caffe ali make all NVCC src caffe layers absval layer cu u
  • 如何在 Caffe 的网络中出现多次损失?

    如果我在网络中定义多个损失层 从这些末端到网络的开头是否会发生多个反向传播 我的意思是 他们真的是这样工作的吗 假设我有这样的事情 Layer1 Layer2 Layer n Layer cls1 bottom layer n top cl

随机推荐

  • 【python】20行代码实现有道翻译api接口调用

    文章目录 1 目标站点 2 完整代码 3 测试样例 3 1 测试样例 汉译英 3 2 测试样例 英译汉 4 调用文档 4 1 接口地址 4 2 请求方法 4 3 请求参数 4 4 请求示例 4 5 成功响应 5 接口分析 6 相关推荐 1
  • GDB下查看内存命令(x命令)

    GDB下查看内存命令 x命令 你可以使用examine命令 简写是x 来查看内存地址中的值 x命令的语法如下所示 x
  • 计算机软件摊销会计分录,财务软件摊销会计分录怎么写?

    摘要 这是一篇关于财务软件摊销会计分录怎么写 的文章 在财务软件摊销会计分录怎么写 文章中给各位财务人员讲解的是有关财务软件摊销会计分录怎么写 的会计实务处理 财务软件摊销会计分录怎么写 外帐按规定财务软件应该按无形资产处理10年摊销 或跟
  • vcruntime140.dll无法继续执行代码?vcruntime140.dll如何修复?只需要3步即可

    vcruntime140 dll是用于Microsoft Visual C Redistributable 可再发行组件 的一部分 它是一个动态链接库文件 包含了该软件包提供的运行库 在许多应用程序和游戏中 vcruntime140 dll
  • 深入理解Java中的BigInteger和 BigDecimal,再也不怕面试了

    Integer类作为int的包装类 能存储的最大整型值为2 31 1 Long类最大为2 63 1 虽然比Integer类大了很多 但是也是有限的 如果想要表示更大的整数 不管是基本数据类型还是它们对应的包装类都无法实现 Java中提供了两
  • 20221102模型调用 报错invalid load key, ‘\x00‘.invalid load key, ‘\x10‘.

    一 模型保存和调用 保存方法不一样 调用方法也不一样 joblib import joblib 保存 joblib dump model model1 pkl 加载 model joblib load open model1 pkl rb
  • 深拷贝构造函数和浅拷贝构造函数

    深拷贝构造函数和浅拷贝构造函数 拷贝构造函数有深拷贝构造函数和浅拷贝构造函数 分类 拷贝构造函数分为深拷贝构造函数和浅拷贝构造函数 区别 浅拷贝 即只复制对象空间 不复制对象资源 深拷贝 既复制对象空间又复制资源 由C 语言提供的默认拷贝构
  • leetcode 3. 无重复字符的最长子串

    题目描述 初始化 ans for 初始化慢指针 0 快指针 0 in 可迭代集合 更新窗口内信息 while 窗口内不符合维护的条件 扩展或者收缩窗口 慢指针移动 if 是合法的答案 更新答案 返回 ans 给定一个字符串 s 请你找出其中
  • Spring Boot2配置Swagger2生成API接口文档

    一 Swagger2介绍 前后端分离开发模式中 api文档是最好的沟通方式 Swagger 是一个规范和完整的框架 用于生成 描述 调用和可视化 RESTful 风格的 Web 服务 及时性 接口变更后 能够及时准确地通知相关前后端开发人员
  • 数据库备份工具有哪些

    本文主要介绍下数据库备份工具 数据库备份工具有很多种 以下是一些常见的数据库备份工具 mysqldump MySQL官方提供的命令行备份工具 适用于MySQL和MariaDB数据库 它可以将数据库导出为SQL文件 方便进行备份和恢复 属于逻
  • 测试用例(进阶篇)(测试的分类)

    目录 一 测试金字塔 二 按照开发阶段划分 1 单元测试 2 集成测试 3 系统测试 4 验收测试 三 按照测试的实施组织划分 1 测试 2 测试 3 第三方 四 按照是否运行划分 1 静态测试 2 动态测试 五 按照是否手工划分 1 手工
  • Jetson Orin NX install Pytorch

    steJInstalling PyTorch for Jetson Platform NVIDIA Docshttps docs nvidia com deeplearning frameworks install pytorch jets
  • JS 常用插件——下拉刷新、上拉加载,左右滑动,移动端调试,图片预览、放大缩小、旋转

    常用插件大全 非常好用 可以达到事半功倍的效果 下拉刷新 上拉加载 mescroll 上下 左右滑动 better scroll 移动端调试 Vconsole 图片预览 放大缩小 旋转 viewerjs 对象转字符串 并以 拼接成URL q
  • Python 将数据写入csv、xlsx、xls文件中(工厂方法、封装、优雅)

    记录 将数据写入csv xlsx xls文件中 工厂方法 封装 优雅 前言 文件目录存放结构 my file save py wrapper verify param py 封装csv my csv py 工厂方法 savedata fac
  • vite、vue3本地页面正常显示不刷新,外网穿透后页面不停刷新

    明明本地不会刷新 但映射到外网就会不停刷新页面 百度了一篇CSDN文章 vite项目 通过外网域名访问 无限刷新 的解决办法 没有解决我的问题 我使用的是natapp进行外网穿透 报错信息是 WebSocket connection to
  • C++ 生成随机数

    C 库有一个名为 rand 的函数 每次调用该函数都将返回一个非负整数 要使用 rand 函数 必须在程序中包含
  • 软件工程第一次阅读作业

    项目 内容 本作业属于北航软件工程课程 博客园班级链接 作业要求请点击链接查看 作业要求 我在这门课程的目标是 成为一个具有一定经验的软件开发人员 这个作业在哪个具体方面帮助我实现目标 让我对自己目前的状况有一个更加清醒的认识 1 快速阅读
  • 【华为OD统一考试A卷

    华为OD统一考试A卷 B卷 新题库说明 2023年5月份 华为官方已经将的 2022 0223Q 1 2 3 4 统一修改为OD统一考试 A卷 和OD统一考试 B卷 你收到的链接上面会标注A卷还是B卷 请注意 根据反馈 目前大部分收到的都是
  • jQuery如何判断input元素是否获得焦点(点击编辑时)

    问题提出 如果你要判断input元素是否获得焦点 或者是否处在活动编辑状态 使用jQuery的 hasFocus 方法或 is focus 方法貌似都无效 搜索网上给出的办法 几乎净是采用上述处理方法 然并卵 都是扯淡 我的解决办法 监听点
  • Caffe中对MNIST执行train操作执行流程解析

    之前在 http blog csdn net fengbingchun article details 49849225 中简单介绍过使用Caffe train MNIST的文章 当时只是仿照caffe中的example实现了下 下面说一下