当前位置: 首页>>代码示例>>Python>>正文


Python NervanaGPU.pool_layer方法代码示例

本文整理汇总了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)
开发者ID:KayneWest,项目名称:nervanagpu,代码行数:33,代码来源:pool_test.py

示例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)
开发者ID:chagge,项目名称:nervanagpu,代码行数:33,代码来源:pool_test.py


注:本文中的nervanagpu.NervanaGPU.pool_layer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。