提交 5237b952 authored 作者: lamblin's avatar lamblin

Merge pull request #1152 from nouiz/doc_sphinx_warn

A few small things.
...@@ -135,7 +135,7 @@ Community ...@@ -135,7 +135,7 @@ Community
* We use `Github tickets <http://github.com/Theano/Theano/issues>`__ to keep track of issues * We use `Github tickets <http://github.com/Theano/Theano/issues>`__ to keep track of issues
(however, some old tickets can still be found on (however, some old tickets can still be found on
``Assembla <http://www.assembla.com/spaces/theano/tickets>`__). `Assembla <http://www.assembla.com/spaces/theano/tickets>`__).
* Come visit us in Montreal! Most developers are students in the LISA_ group at the `University of Montreal`_. * Come visit us in Montreal! Most developers are students in the LISA_ group at the `University of Montreal`_.
......
...@@ -652,6 +652,14 @@ Theano dependencies is easy, but be aware that it will take a long time ...@@ -652,6 +652,14 @@ Theano dependencies is easy, but be aware that it will take a long time
$ python -c "import theano; theano.test()" $ python -c "import theano; theano.test()"
Homebrew
~~~~~~~~
There is some :ref:`instruction
<https://github.com/samueljohn/homebrew-python>` on how to install
Theano dependencies with Homebrew instead of MacPort by Samuel John.
.. _gpu_macos: .. _gpu_macos:
Using the GPU Using the GPU
......
...@@ -1220,6 +1220,7 @@ Linear Algebra ...@@ -1220,6 +1220,7 @@ Linear Algebra
:param x: A Tensor with sizes e.g.: for 3D (dim1, dim3, dim2) :param x: A Tensor with sizes e.g.: for 3D (dim1, dim3, dim2)
:param y: A Tensor with sizes e.g.: for 3D (dim1, dim2, dim4) :param y: A Tensor with sizes e.g.: for 3D (dim1, dim2, dim4)
This function computes the dot product between the two tensors, by iterating This function computes the dot product between the two tensors, by iterating
over the first dimension using scan. over the first dimension using scan.
Returns a tensor of size e.g. if it is 3D: (dim1, dim3, dim4) Returns a tensor of size e.g. if it is 3D: (dim1, dim3, dim4)
......
...@@ -230,10 +230,10 @@ shows how to print all inputs and outputs: ...@@ -230,10 +230,10 @@ shows how to print all inputs and outputs:
import theano import theano
def inspect_inputs(i, node, fn): def inspect_inputs(i, node, fn):
print i, node, [input[0] for input in fn.inputs], print i, node, "input(s) value(s):", [input[0] for input in fn.inputs],
def inspect_outputs(i, node, fn): def inspect_outputs(i, node, fn):
print [output[0] for output in fn.outputs] print "output(s) value(s):", [output[0] for output in fn.outputs]
x = theano.tensor.dscalar('x') x = theano.tensor.dscalar('x')
f = theano.function([x], [5 * x], f = theano.function([x], [5 * x],
......
...@@ -433,12 +433,12 @@ to another is shown below. ...@@ -433,12 +433,12 @@ to another is shown below.
This gives the following output: This gives the following output:
.. code-block:: shell .. code-block:: bash
By default, the two functions are out of sync. # By default, the two functions are out of sync.
f1() returns [ 0.72803009] f1() returns [ 0.72803009]
f2() returns [ 0.55056769] f2() returns [ 0.55056769]
We now copy the state of the theano random number generators. # We now copy the state of the theano random number generators.
f1() returns [ 0.59044123] f1() returns [ 0.59044123]
f2() returns [ 0.59044123] f2() returns [ 0.59044123]
......
...@@ -384,11 +384,11 @@ def grad(cost, wrt, consider_constant=None, ...@@ -384,11 +384,11 @@ def grad(cost, wrt, consider_constant=None,
:type return_disconnected: string :type return_disconnected: string
:param return_disconnected: :param return_disconnected:
'zero' : If wrt[i] is disconnected, return value i will be - 'zero' : If wrt[i] is disconnected, return value i will be
wrt[i].zeros_like() wrt[i].zeros_like()
'None' : If wrt[i] is disconnected, return value i will be - 'None' : If wrt[i] is disconnected, return value i will be
None None
'Disconnected' : returns variables of type DisconnectedType - 'Disconnected' : returns variables of type DisconnectedType
:rtype: Variable or list/tuple of Variables (depending upon `wrt`) :rtype: Variable or list/tuple of Variables (depending upon `wrt`)
......
...@@ -67,10 +67,9 @@ def execute(execute=True, verbose=True, M=2000, N=2000, K=2000, ...@@ -67,10 +67,9 @@ def execute(execute=True, verbose=True, M=2000, N=2000, K=2000,
order=order)) order=order))
c = theano.shared(numpy.ones((M, K), dtype=theano.config.floatX, c = theano.shared(numpy.ones((M, K), dtype=theano.config.floatX,
order=order)) order=order))
f = theano.function([], updates={c: 0.4 * c + .8 * T.dot(a, b)}, f = theano.function([], updates=[(c, 0.4 * c + .8 * T.dot(a, b))],
mode=theano.compile.ProfileMode()) mode=theano.compile.ProfileMode())
if any([x.op.__class__.__name__ == 'Gemm' for x in if any([x.op.__class__.__name__ == 'Gemm' for x in
f.maker.fgraph.toposort()]): f.maker.fgraph.toposort()]):
c_impl = f.profile.apply_cimpl.values() c_impl = f.profile.apply_cimpl.values()
...@@ -206,6 +205,8 @@ if __name__ == "__main__": ...@@ -206,6 +205,8 @@ if __name__ == "__main__":
GTX470/4.2 0.238s GTX470/4.2 0.238s
C2075/4.2 0.25s C2075/4.2 0.25s
GTX285/4.2 0.452s #cuda 3.0 seam faster? driver version? GTX285/4.2 0.452s #cuda 3.0 seam faster? driver version?
GT520/4.2 2.68s
GTX560/4.2 0.30s
GTX460/4.0 0.45s GTX460/4.0 0.45s
......
...@@ -2443,9 +2443,10 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp): ...@@ -2443,9 +2443,10 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
def copy_of_x(self, x): def copy_of_x(self, x):
""" """
x: a string giving the name of a C variable pointing to an array :param x: a string giving the name of a C variable
pointing to an array
Returns C code expression to make a copy of x. :return: C code expression to make a copy of x
Base class uses PyArrayObject *, subclasses may override for Base class uses PyArrayObject *, subclasses may override for
different types of arrays. different types of arrays.
...@@ -2454,8 +2455,8 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp): ...@@ -2454,8 +2455,8 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
def make_view_array(self, x, view_ndim): def make_view_array(self, x, view_ndim):
""" """
x: a string identifying an array to be viewed :param x: a string identifying an array to be viewed
view_ndim: a string specifying the number of dimensions :param view_ndim: a string specifying the number of dimensions
to have in the view to have in the view
This doesn't need to actually set up the view with the This doesn't need to actually set up the view with the
......
...@@ -4971,9 +4971,10 @@ class IncSubtensor(Op): ...@@ -4971,9 +4971,10 @@ class IncSubtensor(Op):
def copy_of_x(self, x): def copy_of_x(self, x):
""" """
x: a string giving the name of a C variable pointing to an array :param x: a string giving the name of a C variable
pointing to an array
Returns C code expression to make a copy of x. :return: C code expression to make a copy of x
Base class uses PyArrayObject *, subclasses may override for Base class uses PyArrayObject *, subclasses may override for
different types of arrays. different types of arrays.
...@@ -4991,8 +4992,8 @@ class IncSubtensor(Op): ...@@ -4991,8 +4992,8 @@ class IncSubtensor(Op):
def make_view_array(self, x, view_ndim): def make_view_array(self, x, view_ndim):
""" """
x: a string identifying an array to be viewed :param x: a string identifying an array to be viewed
view_ndim: a string specifying the number of dimensions :param view_ndim: a string specifying the number of dimensions
to have in the view to have in the view
This doesn't need to actually set up the view with the This doesn't need to actually set up the view with the
......
...@@ -7119,10 +7119,12 @@ class TestTensorInstanceMethods(unittest.TestCase): ...@@ -7119,10 +7119,12 @@ class TestTensorInstanceMethods(unittest.TestCase):
def test_dot(self): def test_dot(self):
X, Y = self.vars X, Y = self.vars
x, y = self.vals x, y = self.vals
assert_array_equal(x.dot(y), X.dot(Y).eval({X: x, Y: y})) # Use allclose comparison as a user reported on the mailing
# list failure otherwise with array that print exactly the same.
assert_allclose(x.dot(y), X.dot(Y).eval({X: x, Y: y}))
Z = X.dot(Y) Z = X.dot(Y)
z = x.dot(y) z = x.dot(y)
assert_array_equal(x.dot(z), X.dot(Z).eval({X: x, Z: z})) assert_allclose(x.dot(z), X.dot(Z).eval({X: x, Z: z}))
def test_real_imag(self): def test_real_imag(self):
X, Y = self.vars X, Y = self.vars
......
...@@ -240,9 +240,30 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile, ...@@ -240,9 +240,30 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile,
prof_master_nosort = [] prof_master_nosort = []
prof_rawlog = [] prof_rawlog = []
dummy_out = open(os.devnull, 'w') dummy_out = open(os.devnull, 'w')
path_rawlog = os.path.join(sav_dir, 'timeprof_rawlog')
stamp = str(datetime.datetime.now()) + '\n\n'
f_rawlog = open(path_rawlog, 'w')
f_rawlog.write('TIME-PROFILING OF THEANO\'S NOSETESTS'
' (raw log)\n\n' + stamp)
f_rawlog.flush()
stamp = str(datetime.datetime.now()) + '\n\n'
fields = ('Fields: computation time; nosetests sequential id;'
' test name; parent class (if any); outcome\n\n')
path_nosort = os.path.join(sav_dir, 'timeprof_nosort')
f_nosort = open(path_nosort, 'w')
f_nosort.write('TIME-PROFILING OF THEANO\'S NOSETESTS'
' (by sequential id)\n\n' + stamp + fields)
f_nosort.flush()
for test_floor in xrange(1, n_tests + 1, batch_size): for test_floor in xrange(1, n_tests + 1, batch_size):
for test_id in xrange(test_floor, min(test_floor + batch_size, for test_id in xrange(test_floor, min(test_floor + batch_size,
n_tests + 1)): n_tests + 1)):
# Print the test we will start in the raw log to help
# debug tests that are too long.
f_rawlog.write("\nWill run test #%d %s\n" % (test_id,
data["ids"][test_id]))
f_rawlog.flush()
proc = subprocess.Popen( proc = subprocess.Popen(
([python, theano_nose, '-v', '--with-id'] ([python, theano_nose, '-v', '--with-id']
+ [str(test_id)] + argv + + [str(test_id)] + argv +
...@@ -257,8 +278,10 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile, ...@@ -257,8 +278,10 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile,
# recovering and processing data from pipe # recovering and processing data from pipe
err = proc.stderr.read() err = proc.stderr.read()
# building the raw log # print the raw log
prof_rawlog.append(err) f_rawlog.write(err)
f_rawlog.flush()
# parsing the output # parsing the output
l_err = err.split() l_err = err.split()
try: try:
...@@ -292,34 +315,31 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile, ...@@ -292,34 +315,31 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile,
' on test') ' on test')
prof_pass = '' prof_pass = ''
prof_tuple = (prof_time, prof_id, prof_test, prof_pass) prof_tuple = (prof_time, prof_id, prof_test, prof_pass)
# appending tuple to master list # appending tuple to master list
prof_master_nosort.append(prof_tuple) prof_master_nosort.append(prof_tuple)
# write the no sort file
s_nosort = ((str(prof_tuple[0]) + 's').ljust(10) +
" " + prof_tuple[1].ljust(7) + " " +
prof_tuple[2] + prof_tuple[3] +
"\n")
f_nosort.write(s_nosort)
f_nosort.flush()
print '%s%% time-profiled' % ((test_id * 100) // n_tests) print '%s%% time-profiled' % ((test_id * 100) // n_tests)
f_rawlog.close()
# sorting tests according to running-time # sorting tests according to running-time
prof_master_sort = sorted(prof_master_nosort, prof_master_sort = sorted(prof_master_nosort,
key=lambda test: test[0], reverse=True) key=lambda test: test[0], reverse=True)
# saving results to readable files # saving results to readable files
path_nosort = os.path.join(sav_dir, 'timeprof_nosort')
path_sort = os.path.join(sav_dir, 'timeprof_sort') path_sort = os.path.join(sav_dir, 'timeprof_sort')
path_rawlog = os.path.join(sav_dir, 'timeprof_rawlog')
f_nosort = open(path_nosort, 'w')
f_sort = open(path_sort, 'w') f_sort = open(path_sort, 'w')
f_rawlog = open(path_rawlog, 'w')
stamp = str(datetime.datetime.now()) + '\n\n'
fields = ('Fields: computation time; nosetests sequential id;'
' test name; parent class (if any); outcome\n\n')
f_nosort.write('TIME-PROFILING OF THEANO\'S NOSETESTS'
' (by sequential id)\n\n' + stamp + fields)
f_sort.write('TIME-PROFILING OF THEANO\'S NOSETESTS' f_sort.write('TIME-PROFILING OF THEANO\'S NOSETESTS'
' (sorted by computation time)\n\n' + stamp + fields) ' (sorted by computation time)\n\n' + stamp + fields)
for i in xrange(len(prof_master_nosort)): for i in xrange(len(prof_master_nosort)):
s_nosort = ((str(prof_master_nosort[i][0]) + 's').ljust(10) +
" " + prof_master_nosort[i][1].ljust(7) + " " +
prof_master_nosort[i][2] + prof_master_nosort[i][3] +
"\n")
f_nosort.write(s_nosort)
s_sort = ((str(prof_master_sort[i][0]) + 's').ljust(10) + s_sort = ((str(prof_master_sort[i][0]) + 's').ljust(10) +
" " + prof_master_sort[i][1].ljust(7) + " " + " " + prof_master_sort[i][1].ljust(7) + " " +
prof_master_sort[i][2] + prof_master_sort[i][3] + prof_master_sort[i][2] + prof_master_sort[i][3] +
...@@ -327,11 +347,6 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile, ...@@ -327,11 +347,6 @@ def run(stdout, stderr, argv, theano_nose, batch_size, time_profile,
f_sort.write(s_sort) f_sort.write(s_sort)
f_nosort.close() f_nosort.close()
f_sort.close() f_sort.close()
f_rawlog.write('TIME-PROFILING OF THEANO\'S NOSETESTS'
' (raw log)\n\n' + stamp)
for i in xrange(len(prof_rawlog)):
f_rawlog.write(prof_rawlog[i])
f_rawlog.close()
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) sys.exit(main())
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论