1. pytorch提供接口

method 1  torch.nn.init里面有很多初始化分布

 import torch.nn.init as init

 self.conv1 = nn.Conv2d(3, 20, 5, stride=1, bias=True)
init.xavier_uniform(self.conv1.weight, gain=np.sqrt(2.0))
init.constant(self.conv1.bias, 0.1)

method 2 http://pytorch.org/docs/master/nn.html

 def init_weights(m):
print(m)
if isinstance(m, nn.Linear):
m.weight.data.fill_(1.0)
print(m.weight) net = nn.Sequential(nn.Linear(2, 2), nn.Linear(2, 2))
net.apply(init_weights)

conv.py中有定义函数

 def reset_parameters(self):
n = self.in_channels
for k in self.kernel_size:
n *= k
stdv = 1. / math.sqrt(n)
self.weight.data.uniform_(-stdv, stdv)
if self.bias is not None:
self.bias.data.uniform_(-stdv, stdv)

weight initilzation的更多相关文章

  1. [LeetCode] Nested List Weight Sum II 嵌套链表权重和之二

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

  2. Codeforces Round #326 (Div. 2) B. Pasha and Phone C. Duff and Weight Lifting

    B. Pasha and PhonePasha has recently bought a new phone jPager and started adding his friends' phone ...

  3. weight属性你用的真的6嘛?

    相信大家在日常开发中一定使用过weight这个属性,它的作用一个是权重,另一个就是渲染优先级,但是你真的能很6的使用它嘛?如果不是,那么请继续往下看!!! 我们知道,当weight起到不同作用的时候, ...

  4. Android Hack1 使用weight属性实现视图的居中显示

    本文地址:http://www.cnblogs.com/wuyudong/p/5898403.html,转载请注明源地址. 如果要实现如下图所示的将按钮居中显示,并且占据父视图的一半,无论屏幕是否旋转 ...

  5. Android weight属性详解

    android:layout_weight是一个经常会用到的属性,它只在LinearLayout中生效,下面我们就来看一下: 当我们把组件宽度设置都为”match_parent”时: <Butt ...

  6. LeetCode Nested List Weight Sum

    原题链接在这里:https://leetcode.com/problems/nested-list-weight-sum/ 题目: Given a nested list of integers, r ...

  7. Java基础-继承-编写一个Java应用程序,设计一个汽车类Vehicle,包含的属性有车轮个数 wheels和车重weight。小车类Car是Vehicle的子类,其中包含的属性有载人数 loader。卡车类Truck是Car类的子类,其中包含的属性有载重量payload。每个 类都有构造方法和输出相关数据的方法。最后,写一个测试类来测试这些类的功 能。

    #29.编写一个Java应用程序,设计一个汽车类Vehicle,包含的属性有车轮个数 wheels和车重weight.小车类Car是Vehicle的子类,其中包含的属性有载人数 loader.卡车类T ...

  8. ACM Same binary weight

    Same binary weight 时间限制:300 ms  |  内存限制:65535 KB 难度:3   描述 The binary weight of a positive  integer ...

  9. Leetcode: Nested List Weight Sum II

    Given a nested list of integers, return the sum of all integers in the list weighted by their depth. ...

随机推荐

  1. TCP/IP网络编程之多种I/O函数

    send和recv函数 在之前的学习中,我们在不少示例中用到send和recv这两个函数,但一直没有详细解释过着两个函数中每个参数的含义.本节将介绍Linux平台下的send&recv函数 # ...

  2. App 设计技巧

    http://www.360doc.com/content/14/1120/18/21412_426730809.shtml http://veryui.diandian.com/post/2013- ...

  3. WebApi 跨域

    http://www.cnblogs.com/lori/p/3557111.html http://bbs.csdn.net/topics/391020576

  4. IOS开发---菜鸟学习之路--(九)-利用PullingRefreshTableView实现下拉刷新

    本章主要讲解如何利用PullingRefreshTableView实现下拉(上拉)刷新的操作 PullingRefreshTableView 实现上下拉刷新的例子百度有很多,大家可以自己搜索下,先看下 ...

  5. 【Jump Game】cpp

    题目: Given an array of non-negative integers, you are initially positioned at the first index of the ...

  6. python-day4-内置函数2

    摘要:python中有好多可用性特别强的内置函数,熟练掌握对于以后的编程过程中有很大的帮助~~~~ callable函数.chr函数与ord函数.random函数.compile函数.evec与eva ...

  7. sqlserver执行时间和自行效率

    SET STATISTICS PROFILE ON --SET STATISTICS IO ON --SET STATISTICS TIME ON declare @dtm datetime SQL语 ...

  8. 贪吃蛇—C—基于easyx图形库(上):基本控制函数实现 画图程序

    自从学了c语言,就一直想做个游戏,今天将之付之行动,第一次写的特别烂,各种bug:就不贴了.今天网上看了好几个贪吃蛇,重新写了一次,做出来的效果还可以. p.s.  easyx图形库是为了方便图形学教 ...

  9. ibatis selectKey

    <insert id="insert" parameterClass="A"> <selectKey keyProperty="uu ...

  10. nyoj 题目6 喷水装置

    喷水装置(一) 时间限制:3000 ms  |  内存限制:65535 KB 难度:3   描述 现有一块草坪,长为20米,宽为2米,要在横中心线上放置半径为Ri的喷水装置,每个喷水装置的效果都会让以 ...