true

pytorch权重初始化(2)

耗尽温柔 提交于 2019-12-04 06:04:37
权重初始化 def weights_normal_init (model, dev= 0.01 ) : if isinstance(model, list): for m in model: weights_normal_init(m, dev) else : for m in model.modules(): if isinstance(m, nn.Conv2d): #print torch.sum(m.weight) m.weight.data.normal_( 0.0 , dev) if m.bias is not None : m.bias.data.fill_( 0.0 ) elif isinstance(m, nn.Linear): m.weight.data.normal_( 0.0 , dev) 网络结构 class Conv2d (nn.Module) : def __init__ (self, in_channels, out_channels, kernel_size, stride= 1 , relu=True, same_padding=False, bn=False) : super(Conv2d, self).__init__() padding = int((kernel_size - 1 ) / 2 ) if same_padding else 0

是什么 !! (不是)JavaScript中的运算符?

可紊 提交于 2019-12-03 16:45:24
我看到了一些似乎使用不认识的运算符的代码,它以两个感叹号的形式出现,像这样: !! 。 有人可以告诉我这个操作员做什么吗? 我看到的背景是 this.vertical = vertical !== undefined ? !!vertical : this.vertical; #1楼 !!expr 根据表达式的 真实性 返回布尔值( true 或 false )。 在非布尔类型上使用时更有意义。 考虑以下示例,尤其是第三个示例及以后的示例: !!false === false !!true === true !!0 === false !!parseInt("foo") === false // NaN is falsy !!1 === true !!-1 === true // -1 is truthy !!"" === false // empty string is falsy !!"foo" === true // non-empty string is truthy !!"false" === true // ...even if it contains a falsy value !!window.foo === false // undefined is falsy !!null === false // null is falsy !!{} === true //

前端技术之:如何通过类的属性获取类名

人走茶凉 提交于 2019-12-03 12:47:02
class A { constructor(a, b = 'bbb', c = 1) { this.a = a; this.b = b; this.c = c; } } 获取类的原型对象constructor属性: const desc3 = Object.getOwnPropertyDescriptor(A.prototype, 'constructor'); console.info(desc3); 结果如下: { value: [Function: A], writable: true, enumerable: false, configurable: true } 由此看出A的原型对象constructor属性的值实际上是一个Function,我们进一步获取这个Function的属性描述: console.info(Object.getOwnPropertyDescriptors(desc3.value)); 或者直接获取: console.info(Object.getOwnPropertyDescriptors(A.prototype.constructor)); 得到如下结果: { length: { value: 1, writable: false, enumerable: false, configurable: true }, prototype: {

How can i close a bootstrap-popover with a button inside the popover?

匿名 (未验证) 提交于 2019-12-03 08:41:19
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I have made a jsFiddle where i use twitter bootstrap popover function on an icon. <div style="margin-top:200px"> <ul> <li class="in-row"> <a href="#" id="meddelanden" data-title="Meddelanden" data-toggle="clickover" data-placement="right"><i class="icon-globe"></i></a> </li> </ul> </div> jquery: var elem = '<div class="well"><a href="google.com">Message one, From someone.</a></div>'+ '<div class="well"><a href="google.com">Message one, From someone.</a></div>'+ '<button id="close-popover" class="btn btn-small btn-primary pull-right">Close

学习pandas-索引操作

瘦欲@ 提交于 2019-12-03 08:39:59
import pandas as pd df1 = pd . DataFrame ( { 'var1' : 1.0 , 'var2' : [ 1 , 2 , 3 , 4 ] , 'var3' : [ 'test' , 'tran' , 'test' , 'tran' ] , 'var4' : 'cons' } , index = [ 'a' , 'b' , 'c' , 'd' ] ) df2 = pd . read_csv ( '123.csv' , encoding = 'utf-8' , index_col = '店家' ) 设置索引 ‘’’ df.set_index( keys:colums be assigned as index, composite index need list type drop = True:if or not delet the columns after creat index append = False:if or not add index on the base of original index,replace is default inplace = False:if or not directly modify original df ) ‘’’ df2_new = df2 . set_index ( '地址' ) df2

Propel case-sensitive phpNames for columns

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: The relevant portion of my schema.xml : <database name="Inventory" defaultIdMethod="native"> <table name="Users" phpName="User"> <column name="UserId" type="varchar" size="20" required="true" primaryKey="true" /> <column name="FirstName" type="varchar" size="255" required="true" /> <column name="LastName" type="varchar" size="255" required="true" /> <column name="Password" type="varchar" size="255" required="true" /> <column name="Salt" type="char" size="22" required="true" /> <column name="RoleId" type="integer" required="true" /> <column

How to avoid “out of memory exception” when doing Bitmap processing?

匿名 (未验证) 提交于 2019-12-03 03:08:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In onPictureTaken , I want to do the following: Bitmap decodedPicture = BitmapFactory.decodeByteArray(data, 0, data.length); Matrix matrix = new Matrix(); matrix.preScale(-1.0f, 1.0f); Bitmap picture = Bitmap.createBitmap(decodedPicture, 0, 0, decodedPicture.getWidth(), decodedPicture.getHeight(), matrix, false); View v1 = mainLayout.getRootView(); v1.setDrawingCacheEnabled(true); Bitmap screenshot = Bitmap.createBitmap(v1.getDrawingCache()); v1.setDrawingCacheEnabled(false); Bitmap scaledPicture = Bitmap.createScaledBitmap(picture,

H2 database error: Database may be already in use: “Locked by another process”

匿名 (未验证) 提交于 2019-12-03 02:45:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am trying to use the H2 database from a Java application. I created the database and its tables through the H2 Console and then I try to connect from Java using Connection con = DriverManager.getConnection("jdbc:h2:~/dbname", "username", "password"); However I receive the following error: Exception in thread "main" org.h2.jdbc.JdbcSQLException: Database may be already in use: "Locked by another process". Possible solutions: close all other connection(s); use the server mode [90020-161] I tried to delete the dbname.lock.db file but it is

Grails throws Table “xxx” not found

匿名 (未验证) 提交于 2019-12-03 02:03:01
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: In Grails I can create domain objects to a H2 in memory dataSource in BootStrap and get results back ok, but once the app is up (eg query from GSP or controller) and I try to run a query I get this: org.h2.jdbc.JdbcSQLException: Table "FUNCTIONAL_DOC_TYPE" not found; SQL statement: select this_.id as id1_0_, this_.version as version1_0_, this_.direction_id as direction3_1_0_, this_.functional_group_id as functional4_1_0_, this_.type_name as type5_1_0_ from functional_doc_type this_ [42102-147] at org.h2.message.DbException

Pandas groupby count non-null values as percentage

匿名 (未验证) 提交于 2019-12-03 01:34:02
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Given this dataset, I would like to count missing, NaN, values: df = pd.DataFrame({'A' : [1, np.nan, 2 , 55, 6, np.nan, -17, np.nan], 'Team' : ['one', 'one', 'two', 'three','two', 'two', 'one', 'three'], 'C' : [4, 14, 3 , 8, 8, 7, np.nan, 11], 'D' : [np.nan, np.nan, -12 , 12, 12, -12, np.nan, np.nan]}) Specifically I want to count (as a percentage) per group in the 'Team' column. I can get the raw count by this: df.groupby('Team').count() This will get the number of nonmissing numbers. What I would like to do is create a percentage, so