提交 d7860d0d authored 作者: Chiheb Trabelsi's avatar Chiheb Trabelsi

walltime.py has been modified in order to respect the flake8 style.

上级 4a076fd3
from __future__ import absolute_import, print_function, division
from __future__ import print_function
import sys, time
import sys
import time
from six import iteritems
from theano.compile.pfunc import pfunc
from theano import tensor
......@@ -35,35 +36,47 @@ def showtimes(times):
def cmp_sigmoids(shape):
def numpy_sigmoid(input):
rval = 1.0 / (1.0 + numpy.exp(-input))
sinput = tensor.Tensor(dtype='float32', broadcastable=(0,)*len(shape))()
shared_input = tcn.shared_constructor(numpy.random.rand(*shape), 'shared_input')
times = compare_fns(
dict( numpy=numpy_sigmoid
, theano_cpu=pfunc([sinput], 1.0 / (1.0 + tensor.exp(-sinput)))
, theano_gpu_onboard=pfunc([sinput], [], updates=[(shared_input, 1.0 / (1.0 + tensor.exp(-shared_input)))])
),
input=shared_input.value)
1.0 / (1.0 + numpy.exp(-input))
sinput = tensor.Tensor(
dtype='float32', broadcastable=(0,) * len(shape))()
shared_input = tcn.shared_constructor(
numpy.random.rand(*shape),
'shared_input')
times = compare_fns(dict(
numpy=numpy_sigmoid,
theano_cpu=pfunc([sinput], 1.0 / (1.0 + tensor.exp(-sinput))),
theano_gpu_onboard=pfunc(
[sinput],
[],
updates=[(
shared_input,
1.0 / (1.0 + tensor.exp(-shared_input)))])),
input=shared_input.value)
showtimes(times)
def cmp_sigmoids_T(shape):
def numpy_sigmoid(input):
rval = 1.0 / (1.0 + numpy.exp(-input.T))
sinput = tensor.Tensor(dtype='float32', broadcastable=(0,)*len(shape))()
shared_input = tcn.shared_constructor(numpy.random.rand(*shape), 'shared_input')
times = compare_fns(
dict( numpy=numpy_sigmoid
, theano_cpu=pfunc([sinput], 1.0 / (1.0 + tensor.exp(-sinput.T)))
, theano_gpu_onboard=pfunc([sinput], [], updates=[(shared_input, 1.0 / (1.0 +
tensor.exp(-shared_input.T)))])
),
input=shared_input.value)
1.0 / (1.0 + numpy.exp(-input.T))
sinput = tensor.Tensor(
dtype='float32', broadcastable=(0,) * len(shape))()
shared_input = tcn.shared_constructor(
numpy.random.rand(*shape),
'shared_input')
times = compare_fns(dict(
numpy=numpy_sigmoid,
theano_cpu=pfunc([sinput], 1.0 / (1.0 + tensor.exp(-sinput.T))),
theano_gpu_onboard=pfunc(
[sinput],
[],
updates=[(
shared_input,
1.0 / (1.0 + tensor.exp(-shared_input.T)))])),
input=shared_input.value)
showtimes(times)
if __name__ == '__main__':
eval(sys.argv[1])
# cmp_sigmoids((640, 64*64)) # looks great in profiler
#cmp_sigmoids((173, 74*49))
#cmp_sigmoids_T((173, 74*49))
# cmp_sigmoids((173, 74*49))
# cmp_sigmoids_T((173, 74*49))
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论