本文整理汇总了Python中nervanagpu.NervanaGPU.pool_layer方法的典型用法代码示例。如果您正苦于以下问题:Python NervanaGPU.pool_layer方法的具体用法?Python NervanaGPU.pool_layer怎么用?Python NervanaGPU.pool_layer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nervanagpu.NervanaGPU
的用法示例。
在下文中一共展示了NervanaGPU.pool_layer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: NervanaGPU
# 需要导入模块: from nervanagpu import NervanaGPU [as 别名]
# 或者: from nervanagpu.NervanaGPU import pool_layer [as 别名]
from operator import mul
print context.get_device().name()
np.set_printoptions(threshold=8193, linewidth=600, formatter={'int':lambda x: "%10d" % x,'float':lambda x: "% .3f" % x})
dtype = np.float16
cpu = 1
repeat = 1
ng = NervanaGPU(stochastic_round=False, bench=True)
pool = ng.pool_layer(
"max",
64, # N
64,1,64,64, # C,D,H,W
4,1,2,2, # J,T,R,S
0,0,0,0, # padding
4,1,2,2) # strides
dimI = pool.dimI
dimO = pool.dimO
# colapse pooling dimensions into one
# this allows for easy cpu pooling in numpy
def slicable(dim, pad=0):
dim0 = reduce(mul, dim[:-1], 1) + pad
return (dim0, dim[-1])
# cpu input arrays
cpuI = np.random.uniform(0.0, 9.4, slicable(dimI,1)).astype(np.float16).astype(np.float32)
示例2: print
# 需要导入模块: from nervanagpu import NervanaGPU [as 别名]
# 或者: from nervanagpu.NervanaGPU import pool_layer [as 别名]
from operator import mul
print(context.get_device().name())
np.set_printoptions(threshold=8193, linewidth=600, formatter={'int':lambda x: "%10d" % x,'float':lambda x: "% .3f" % x})
dtype = np.float32
cpu = 1
repeat = 1
ng = NervanaGPU(stochastic_round=False, bench=True)
pool = ng.pool_layer(dtype,
"max",
32, # N
32,1,32,32, # C,D,H,W
2,1,3,3, # J,T,R,S
0,0,0,0, # padding
2,1,2,2) # strides
dimI = pool.dimI
dimO = pool.dimO
# colapse pooling dimensions into one
# this allows for easy cpu pooling in numpy
def slicable(dim, pad=0):
dim0 = reduce(mul, dim[:-1], 1) + pad
return (dim0, dim[-1])
# cpu input arrays
cpuI = np.random.uniform(0.0, 1.0, slicable(dimI,1)).astype(np.float16).astype(np.float32)