提交 99667825 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Replace theano.tensor alias T with tt in theano.misc

上级 f42f2163
...@@ -7,7 +7,8 @@ GPU power consumption then gemm call. ...@@ -7,7 +7,8 @@ GPU power consumption then gemm call.
import numpy as np import numpy as np
import theano import theano
import theano.tensor as T import theano.tensor as tt
from theano.gpuarray import dnn from theano.gpuarray import dnn
from theano.tensor.nnet.abstract_conv import get_conv_output_shape from theano.tensor.nnet.abstract_conv import get_conv_output_shape
...@@ -17,9 +18,9 @@ def burn(): ...@@ -17,9 +18,9 @@ def burn():
img_shp = [sz, sz, sz, sz] img_shp = [sz, sz, sz, sz]
kern_shp = [sz // 2, sz, 3, 3] kern_shp = [sz // 2, sz, 3, 3]
out_shp = get_conv_output_shape(img_shp, kern_shp, "valid", (1, 1)) out_shp = get_conv_output_shape(img_shp, kern_shp, "valid", (1, 1))
img = T.tensor4("img") img = tt.tensor4("img")
kern = T.tensor4("kern") kern = tt.tensor4("kern")
out = T.tensor4("out") out = tt.tensor4("out")
def rand(shp): def rand(shp):
return np.random.rand(*shp).astype(theano.config.floatX) return np.random.rand(*shp).astype(theano.config.floatX)
......
...@@ -10,11 +10,12 @@ ...@@ -10,11 +10,12 @@
import os import os
import sys import sys
import time import time
from optparse import OptionParser
import numpy as np import numpy as np
import theano import theano
import theano.tensor as T import theano.tensor as tt
from optparse import OptionParser
def execute(execute=True, verbose=True, M=2000, N=2000, K=2000, iters=10, order="C"): def execute(execute=True, verbose=True, M=2000, N=2000, K=2000, iters=10, order="C"):
...@@ -52,7 +53,7 @@ def execute(execute=True, verbose=True, M=2000, N=2000, K=2000, iters=10, order= ...@@ -52,7 +53,7 @@ def execute(execute=True, verbose=True, M=2000, N=2000, K=2000, iters=10, order=
a = theano.shared(np.ones((M, N), dtype=theano.config.floatX, order=order)) a = theano.shared(np.ones((M, N), dtype=theano.config.floatX, order=order))
b = theano.shared(np.ones((N, K), dtype=theano.config.floatX, order=order)) b = theano.shared(np.ones((N, K), dtype=theano.config.floatX, order=order))
c = theano.shared(np.ones((M, K), dtype=theano.config.floatX, order=order)) c = theano.shared(np.ones((M, K), dtype=theano.config.floatX, order=order))
f = theano.function([], updates=[(c, 0.4 * c + 0.8 * T.dot(a, b))]) f = theano.function([], updates=[(c, 0.4 * c + 0.8 * tt.dot(a, b))])
if any([x.op.__class__.__name__ == "Gemm" for x in f.maker.fgraph.toposort()]): if any([x.op.__class__.__name__ == "Gemm" for x in f.maker.fgraph.toposort()]):
c_impl = [ c_impl = [
......
from optparse import OptionParser
import sys import sys
import time import time
import numpy as np import numpy as np
import theano import theano
import theano.tensor as T import theano.tensor as tt
from optparse import OptionParser
parser = OptionParser( parser = OptionParser(
...@@ -42,11 +43,11 @@ def evalTime(f, v, script=False, loops=1000): ...@@ -42,11 +43,11 @@ def evalTime(f, v, script=False, loops=1000):
def ElemwiseOpTime(N, script=False, loops=1000): def ElemwiseOpTime(N, script=False, loops=1000):
x = T.vector("x") x = tt.vector("x")
np.random.seed(1235) np.random.seed(1235)
v = np.random.random(N).astype(theano.config.floatX) v = np.random.random(N).astype(theano.config.floatX)
f = theano.function([x], 2 * x + x * x) f = theano.function([x], 2 * x + x * x)
f1 = theano.function([x], T.tanh(x)) f1 = theano.function([x], tt.tanh(x))
if not script: if not script:
if theano.config.openmp: if theano.config.openmp:
print("With openmp:") print("With openmp:")
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论