Skip to content

Instantly share code, notes, and snippets.

@arvidfm
Created August 18, 2016 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arvidfm/2208c09865e731d8929bce100db83152 to your computer and use it in GitHub Desktop.
Save arvidfm/2208c09865e731d8929bce100db83152 to your computer and use it in GitHub Desktop.
Traceback (most recent call last):
File ".../.venv/lib/python3.5/site-packages/theano/gof/link.py", line 1012, in f
wrapper(i, node, *thunks)
File ".../.venv/lib/python3.5/site-packages/theano/compile/nanguardmode.py", line 307, in nan_check
do_check_on(x[0], node, fn, False)
File ".../.venv/lib/python3.5/site-packages/theano/compile/nanguardmode.py", line 272, in do_check_on
raise AssertionError(msg)
AssertionError: NaN detected
NanGuardMode found an error in the output of a node in this variable:
Elemwise{true_div} [id A] ''
|Elemwise{mul} [id B] ''
| |Elemwise{mul} [id C] ''
| | |DimShuffle{0,1} [id D] ''
| | | |Reshape{2} [id E] ''
| | | |Dot22 [id F] ''
| | | | |Reshape{2} [id G] ''
| | | | | |Elemwise{mul,no_inplace} [id H] ''
| | | | | | |Elemwise{eq,no_inplace} [id I] ''
| | | | | | | |DimShuffle{0,x,1} [id J] ''
| | | | | | | | |MaxAndArgmax.0 [id K] 'max'
| | | | | | | | |Elemwise{add,no_inplace} [id L] ''
| | | | | | | | | |Reshape{3} [id M] ''
| | | | | | | | | | |Dot22 [id N] ''
| | | | | | | | | | | |Reshape{2} [id O] ''
| | | | | | | | | | | | |DimShuffle{0,1} [id P] ''
| | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id Q] ''
| | | | | | | | | | | | | |TensorConstant{(1, 1) of 0.5} [id R]
| | | | | | | | | | | | | |Elemwise{add,no_inplace} [id S] ''
| | | | | | | | | | | | | |MaxAndArgmax.0 [id T] 'max'
| | | | | | | | | | | | | | |Elemwise{add,no_inplace} [id U] ''
| | | | | | | | | | | | | | | |Reshape{3} [id V] ''
| | | | | | | | | | | | | | | | |Dot22 [id W] ''
| | | | | | | | | | | | | | | | | |Reshape{2} [id X] ''
| | | | | | | | | | | | | | | | | | |DimShuffle{0,1} [id Y] ''
| | | | | | | | | | | | | | | | | | | |input [id Z]
| | | | | | | | | | | | | | | | | | |MakeVector{dtype='int64'} [id BA] ''
| | | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BB] ''
| | | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BD] ''
| | | | | | | | | | | | | | | | | | | |Shape [id BE] ''
| | | | | | | | | | | | | | | | | | | | |DimShuffle{0,1} [id Y] ''
| | | | | | | | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BG] ''
| | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BH] ''
| | | | | | | | | | | | | | | | | | |Shape [id BE] ''
| | | | | | | | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | | | | | | | |Reshape{2} [id BJ] ''
| | | | | | | | | | | | | | | | | |DimShuffle{1,0,2} [id BK] ''
| | | | | | | | | | | | | | | | | | |W1 [id BL]
| | | | | | | | | | | | | | | | | |MakeVector{dtype='int64'} [id BM] ''
| | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BN] ''
| | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BO] ''
| | | | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | | | | |DimShuffle{1,0,2} [id BK] ''
| | | | | | | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BQ] ''
| | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BR] ''
| | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BS] ''
| | | | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | | | | | | | |Subtensor{int64} [id BT] ''
| | | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | | |Constant{-2} [id BU]
| | | | | | | | | | | | | | | | |Join [id BV] ''
| | | | | | | | | | | | | | | | |TensorConstant{0} [id BW]
| | | | | | | | | | | | | | | | |Subtensor{int64:int64:} [id BX] ''
| | | | | | | | | | | | | | | | | |Shape [id BE] ''
| | | | | | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | | | | | | | |Subtensor{int64:int64:} [id BZ] ''
| | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | | | | | | | |Constant{3} [id CA]
| | | | | | | | | | | | | | | |DimShuffle{x,0,1} [id CB] ''
| | | | | | | | | | | | | | | |b1 [id CC]
| | | | | | | | | | | | | | |TensorConstant{(1,) of 1} [id CD]
| | | | | | | | | | | | | |Elemwise{abs_,no_inplace} [id CE] ''
| | | | | | | | | | | | | |MaxAndArgmax.0 [id T] 'max'
| | | | | | | | | | | | |MakeVector{dtype='int64'} [id CF] ''
| | | | | | | | | | | | |Elemwise{mul,no_inplace} [id CG] ''
| | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | |Subtensor{int64} [id CH] ''
| | | | | | | | | | | | | |Shape [id CI] ''
| | | | | | | | | | | | | | |DimShuffle{0,1} [id P] ''
| | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | |Elemwise{mul,no_inplace} [id CJ] ''
| | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | |Subtensor{int64} [id CK] ''
| | | | | | | | | | | | |Shape [id CI] ''
| | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | |Reshape{2} [id CL] ''
| | | | | | | | | | | |DimShuffle{1,0,2} [id CM] ''
| | | | | | | | | | | | |W2 [id CN]
| | | | | | | | | | | |MakeVector{dtype='int64'} [id CO] ''
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id CP] ''
| | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | |Subtensor{int64} [id CQ] ''
| | | | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | | | | |DimShuffle{1,0,2} [id CM] ''
| | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id CS] ''
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id CT] ''
| | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | |Subtensor{int64} [id CU] ''
| | | | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | |Subtensor{int64} [id CV] ''
| | | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | | |Constant{-2} [id BU]
| | | | | | | | | | |Join [id CW] ''
| | | | | | | | | | |TensorConstant{0} [id BW]
| | | | | | | | | | |Subtensor{int64:int64:} [id CX] ''
| | | | | | | | | | | |Shape [id CI] ''
| | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | |Subtensor{int64:int64:} [id CY] ''
| | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | |Constant{3} [id CA]
| | | | | | | | | |DimShuffle{x,0,1} [id CZ] ''
| | | | | | | | | |b2 [id DA]
| | | | | | | | |TensorConstant{(1,) of 1} [id CD]
| | | | | | | |Elemwise{add,no_inplace} [id L] ''
| | | | | | |DimShuffle{0,x,1} [id DB] ''
| | | | | | |SoftmaxGrad [id DC] ''
| | | | | | |AdvancedIncSubtensor{inplace=False, set_instead_of_inc=False} [id DD] ''
| | | | | | | |Elemwise{second,no_inplace} [id DE] ''
| | | | | | | | |Softmax [id DF] ''
| | | | | | | | | |MaxAndArgmax.0 [id K] 'max'
| | | | | | | | |TensorConstant{(1, 1) of 0.0} [id DG]
| | | | | | | |Elemwise{true_div} [id DH] ''
| | | | | | | | |Elemwise{second} [id DI] ''
| | | | | | | | | |Elemwise{log,no_inplace} [id DJ] ''
| | | | | | | | | | |AdvancedSubtensor [id DK] ''
| | | | | | | | | | |Softmax [id DF] ''
| | | | | | | | | | |ARange{dtype='int64'} [id DL] ''
| | | | | | | | | | | |TensorConstant{0} [id BW]
| | | | | | | | | | | |Subtensor{int64} [id DM] ''
| | | | | | | | | | | | |Shape [id DN] ''
| | | | | | | | | | | | | |Softmax [id DF] ''
| | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | |TensorConstant{[0 0 0 0 0..1 1 1 1 1]} [id DO]
| | | | | | | | | |DimShuffle{x} [id DP] ''
| | | | | | | | | |Elemwise{true_div} [id DQ] ''
| | | | | | | | | |TensorConstant{-1.0} [id DR]
| | | | | | | | | |Elemwise{Cast{float32}} [id DS] ''
| | | | | | | | | |Subtensor{int64} [id DT] ''
| | | | | | | | | |Shape [id DU] ''
| | | | | | | | | | |Elemwise{log,no_inplace} [id DJ] ''
| | | | | | | | | |Constant{0} [id BF]
| | | | | | | | |AdvancedSubtensor [id DK] ''
| | | | | | | |ARange{dtype='int64'} [id DL] ''
| | | | | | | |TensorConstant{[0 0 0 0 0..1 1 1 1 1]} [id DO]
| | | | | | |Softmax [id DF] ''
| | | | | |Shape [id DV] ''
| | | | | |Dot22 [id N] ''
| | | | |DimShuffle{1,0} [id DW] ''
| | | | |Reshape{2} [id CL] ''
| | | |Shape [id CI] ''
| | |TensorConstant{(1, 1) of 0.5} [id R]
| |MaxAndArgmax.0 [id T] 'max'
|Elemwise{abs_,no_inplace} [id CE] ''
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 46, in <module>
print(f(inputs))
File ".../.venv/lib/python3.5/site-packages/theano/compile/function_module.py", line 859, in __call__
outputs = self.fn()
File ".../.venv/lib/python3.5/site-packages/theano/gof/link.py", line 1014, in f
raise_with_op(node, *thunks)
File ".../.venv/lib/python3.5/site-packages/theano/gof/link.py", line 314, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File ".../.venv/lib/python3.5/site-packages/six.py", line 685, in reraise
raise value.with_traceback(tb)
File ".../.venv/lib/python3.5/site-packages/theano/gof/link.py", line 1012, in f
wrapper(i, node, *thunks)
File ".../.venv/lib/python3.5/site-packages/theano/compile/nanguardmode.py", line 307, in nan_check
do_check_on(x[0], node, fn, False)
File ".../.venv/lib/python3.5/site-packages/theano/compile/nanguardmode.py", line 272, in do_check_on
raise AssertionError(msg)
AssertionError: NaN detected
NanGuardMode found an error in the output of a node in this variable:
Elemwise{true_div} [id A] ''
|Elemwise{mul} [id B] ''
| |Elemwise{mul} [id C] ''
| | |DimShuffle{0,1} [id D] ''
| | | |Reshape{2} [id E] ''
| | | |Dot22 [id F] ''
| | | | |Reshape{2} [id G] ''
| | | | | |Elemwise{mul,no_inplace} [id H] ''
| | | | | | |Elemwise{eq,no_inplace} [id I] ''
| | | | | | | |DimShuffle{0,x,1} [id J] ''
| | | | | | | | |MaxAndArgmax.0 [id K] 'max'
| | | | | | | | |Elemwise{add,no_inplace} [id L] ''
| | | | | | | | | |Reshape{3} [id M] ''
| | | | | | | | | | |Dot22 [id N] ''
| | | | | | | | | | | |Reshape{2} [id O] ''
| | | | | | | | | | | | |DimShuffle{0,1} [id P] ''
| | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id Q] ''
| | | | | | | | | | | | | |TensorConstant{(1, 1) of 0.5} [id R]
| | | | | | | | | | | | | |Elemwise{add,no_inplace} [id S] ''
| | | | | | | | | | | | | |MaxAndArgmax.0 [id T] 'max'
| | | | | | | | | | | | | | |Elemwise{add,no_inplace} [id U] ''
| | | | | | | | | | | | | | | |Reshape{3} [id V] ''
| | | | | | | | | | | | | | | | |Dot22 [id W] ''
| | | | | | | | | | | | | | | | | |Reshape{2} [id X] ''
| | | | | | | | | | | | | | | | | | |DimShuffle{0,1} [id Y] ''
| | | | | | | | | | | | | | | | | | | |input [id Z]
| | | | | | | | | | | | | | | | | | |MakeVector{dtype='int64'} [id BA] ''
| | | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BB] ''
| | | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BD] ''
| | | | | | | | | | | | | | | | | | | |Shape [id BE] ''
| | | | | | | | | | | | | | | | | | | | |DimShuffle{0,1} [id Y] ''
| | | | | | | | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BG] ''
| | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BH] ''
| | | | | | | | | | | | | | | | | | |Shape [id BE] ''
| | | | | | | | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | | | | | | | |Reshape{2} [id BJ] ''
| | | | | | | | | | | | | | | | | |DimShuffle{1,0,2} [id BK] ''
| | | | | | | | | | | | | | | | | | |W1 [id BL]
| | | | | | | | | | | | | | | | | |MakeVector{dtype='int64'} [id BM] ''
| | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BN] ''
| | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BO] ''
| | | | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | | | | |DimShuffle{1,0,2} [id BK] ''
| | | | | | | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BQ] ''
| | | | | | | | | | | | | | | | | |Elemwise{mul,no_inplace} [id BR] ''
| | | | | | | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | | | | | | |Subtensor{int64} [id BS] ''
| | | | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | | | | | | | |Subtensor{int64} [id BT] ''
| | | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | | |Constant{-2} [id BU]
| | | | | | | | | | | | | | | | |Join [id BV] ''
| | | | | | | | | | | | | | | | |TensorConstant{0} [id BW]
| | | | | | | | | | | | | | | | |Subtensor{int64:int64:} [id BX] ''
| | | | | | | | | | | | | | | | | |Shape [id BE] ''
| | | | | | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | | | | | | | |Subtensor{int64:int64:} [id BZ] ''
| | | | | | | | | | | | | | | | |Shape [id BP] ''
| | | | | | | | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | | | | | | | |Constant{3} [id CA]
| | | | | | | | | | | | | | | |DimShuffle{x,0,1} [id CB] ''
| | | | | | | | | | | | | | | |b1 [id CC]
| | | | | | | | | | | | | | |TensorConstant{(1,) of 1} [id CD]
| | | | | | | | | | | | | |Elemwise{abs_,no_inplace} [id CE] ''
| | | | | | | | | | | | | |MaxAndArgmax.0 [id T] 'max'
| | | | | | | | | | | | |MakeVector{dtype='int64'} [id CF] ''
| | | | | | | | | | | | |Elemwise{mul,no_inplace} [id CG] ''
| | | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | | |Subtensor{int64} [id CH] ''
| | | | | | | | | | | | | |Shape [id CI] ''
| | | | | | | | | | | | | | |DimShuffle{0,1} [id P] ''
| | | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | | |Elemwise{mul,no_inplace} [id CJ] ''
| | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | |Subtensor{int64} [id CK] ''
| | | | | | | | | | | | |Shape [id CI] ''
| | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | |Reshape{2} [id CL] ''
| | | | | | | | | | | |DimShuffle{1,0,2} [id CM] ''
| | | | | | | | | | | | |W2 [id CN]
| | | | | | | | | | | |MakeVector{dtype='int64'} [id CO] ''
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id CP] ''
| | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | |Subtensor{int64} [id CQ] ''
| | | | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | | | | |DimShuffle{1,0,2} [id CM] ''
| | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id CS] ''
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id CT] ''
| | | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | | | |Subtensor{int64} [id CU] ''
| | | | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | | | |Constant{-1} [id BI]
| | | | | | | | | | | |Subtensor{int64} [id CV] ''
| | | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | | |Constant{-2} [id BU]
| | | | | | | | | | |Join [id CW] ''
| | | | | | | | | | |TensorConstant{0} [id BW]
| | | | | | | | | | |Subtensor{int64:int64:} [id CX] ''
| | | | | | | | | | | |Shape [id CI] ''
| | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | |Subtensor{int64:int64:} [id CY] ''
| | | | | | | | | | |Shape [id CR] ''
| | | | | | | | | | |Constant{1} [id BY]
| | | | | | | | | | |Constant{3} [id CA]
| | | | | | | | | |DimShuffle{x,0,1} [id CZ] ''
| | | | | | | | | |b2 [id DA]
| | | | | | | | |TensorConstant{(1,) of 1} [id CD]
| | | | | | | |Elemwise{add,no_inplace} [id L] ''
| | | | | | |DimShuffle{0,x,1} [id DB] ''
| | | | | | |SoftmaxGrad [id DC] ''
| | | | | | |AdvancedIncSubtensor{inplace=False, set_instead_of_inc=False} [id DD] ''
| | | | | | | |Elemwise{second,no_inplace} [id DE] ''
| | | | | | | | |Softmax [id DF] ''
| | | | | | | | | |MaxAndArgmax.0 [id K] 'max'
| | | | | | | | |TensorConstant{(1, 1) of 0.0} [id DG]
| | | | | | | |Elemwise{true_div} [id DH] ''
| | | | | | | | |Elemwise{second} [id DI] ''
| | | | | | | | | |Elemwise{log,no_inplace} [id DJ] ''
| | | | | | | | | | |AdvancedSubtensor [id DK] ''
| | | | | | | | | | |Softmax [id DF] ''
| | | | | | | | | | |ARange{dtype='int64'} [id DL] ''
| | | | | | | | | | | |TensorConstant{0} [id BW]
| | | | | | | | | | | |Subtensor{int64} [id DM] ''
| | | | | | | | | | | | |Shape [id DN] ''
| | | | | | | | | | | | | |Softmax [id DF] ''
| | | | | | | | | | | | |Constant{0} [id BF]
| | | | | | | | | | | |TensorConstant{1} [id BC]
| | | | | | | | | | |TensorConstant{[0 0 0 0 0..1 1 1 1 1]} [id DO]
| | | | | | | | | |DimShuffle{x} [id DP] ''
| | | | | | | | | |Elemwise{true_div} [id DQ] ''
| | | | | | | | | |TensorConstant{-1.0} [id DR]
| | | | | | | | | |Elemwise{Cast{float32}} [id DS] ''
| | | | | | | | | |Subtensor{int64} [id DT] ''
| | | | | | | | | |Shape [id DU] ''
| | | | | | | | | | |Elemwise{log,no_inplace} [id DJ] ''
| | | | | | | | | |Constant{0} [id BF]
| | | | | | | | |AdvancedSubtensor [id DK] ''
| | | | | | | |ARange{dtype='int64'} [id DL] ''
| | | | | | | |TensorConstant{[0 0 0 0 0..1 1 1 1 1]} [id DO]
| | | | | | |Softmax [id DF] ''
| | | | | |Shape [id DV] ''
| | | | | |Dot22 [id N] ''
| | | | |DimShuffle{1,0} [id DW] ''
| | | | |Reshape{2} [id CL] ''
| | | |Shape [id CI] ''
| | |TensorConstant{(1, 1) of 0.5} [id R]
| |MaxAndArgmax.0 [id T] 'max'
|Elemwise{abs_,no_inplace} [id CE] ''
Apply node that caused the error: Elemwise{true_div}(Elemwise{mul}.0, Elemwise{abs_,no_inplace}.0)
Toposort index: 101
Inputs types: [TensorType(float32, matrix), TensorType(float32, matrix)]
Inputs shapes: [(100, 5), (100, 5)]
Inputs strides: [(20, 4), (20, 4)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Elemwise{add,no_inplace}(Elemwise{mul}.0, Elemwise{true_div}.0)]]
Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "main.py", line 35, in <module>
grads = T.grad(cross_entropy, params)
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 561, in grad
grad_dict, wrt, cost_name)
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1324, in _populate_grad_dict
rval = [access_grad_cache(elem) for elem in wrt]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1324, in <listcomp>
rval = [access_grad_cache(elem) for elem in wrt]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in access_term_cache
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in <listcomp>
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in access_term_cache
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in <listcomp>
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in access_term_cache
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in <listcomp>
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in access_term_cache
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in <listcomp>
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in access_term_cache
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in <listcomp>
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in access_term_cache
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 973, in <listcomp>
output_grads = [access_grad_cache(var) for var in node.outputs]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1279, in access_grad_cache
term = access_term_cache(node)[idx]
File ".../.venv/lib/python3.5/site-packages/theano/gradient.py", line 1113, in access_term_cache
input_grads = node.op.grad(inputs, new_output_grads)
Debugprint of the apply node:
Elemwise{true_div} [id A] <TensorType(float32, matrix)> ''
|Elemwise{mul} [id B] <TensorType(float32, matrix)> ''
| |Elemwise{mul} [id C] <TensorType(float32, matrix)> ''
| | |DimShuffle{0,1} [id D] <TensorType(float32, matrix)> ''
| | | |Reshape{2} [id E] <TensorType(float32, matrix)> ''
| | | |Dot22 [id F] <TensorType(float32, matrix)> ''
| | | | |Reshape{2} [id G] <TensorType(float32, matrix)> ''
| | | | | |Elemwise{mul,no_inplace} [id H] <TensorType(float32, 3D)> ''
| | | | | | |Elemwise{eq,no_inplace} [id I] <TensorType(int8, 3D)> ''
| | | | | | | |DimShuffle{0,x,1} [id J] <TensorType(float32, (False, True, False))> ''
| | | | | | | | |MaxAndArgmax.0 [id K] <TensorType(float32, matrix)> 'max'
| | | | | | | |Elemwise{add,no_inplace} [id L] <TensorType(float32, 3D)> ''
| | | | | | | |Reshape{3} [id M] <TensorType(float32, 3D)> ''
| | | | | | | | |Dot22 [id N] <TensorType(float32, matrix)> ''
| | | | | | | | | |Reshape{2} [id O] <TensorType(float32, matrix)> ''
| | | | | | | | | | |DimShuffle{0,1} [id P] <TensorType(float32, matrix)> ''
| | | | | | | | | | | |Elemwise{mul,no_inplace} [id Q] <TensorType(float32, matrix)> ''
| | | | | | | | | | | |TensorConstant{(1, 1) of 0.5} [id R] <TensorType(float32, (True, True))>
| | | | | | | | | | | |Elemwise{add,no_inplace} [id S] <TensorType(float32, matrix)> ''
| | | | | | | | | | | |MaxAndArgmax.0 [id T] <TensorType(float32, matrix)> 'max'
| | | | | | | | | | | |Elemwise{abs_,no_inplace} [id U] <TensorType(float32, matrix)> ''
| | | | | | | | | | | |MaxAndArgmax.0 [id T] <TensorType(float32, matrix)> 'max'
| | | | | | | | | | |MakeVector{dtype='int64'} [id V] <TensorType(int64, vector)> ''
| | | | | | | | | | |Elemwise{mul,no_inplace} [id W] <TensorType(int64, scalar)> ''
| | | | | | | | | | | |TensorConstant{1} [id X] <TensorType(int8, scalar)>
| | | | | | | | | | | |Subtensor{int64} [id Y] <TensorType(int64, scalar)> ''
| | | | | | | | | | | |Shape [id Z] <TensorType(int64, vector)> ''
| | | | | | | | | | | | |DimShuffle{0,1} [id P] <TensorType(float32, matrix)> ''
| | | | | | | | | | | |Constant{0} [id BA] <int64>
| | | | | | | | | | |Elemwise{mul,no_inplace} [id BB] <TensorType(int64, scalar)> ''
| | | | | | | | | | |TensorConstant{1} [id X] <TensorType(int8, scalar)>
| | | | | | | | | | |Subtensor{int64} [id BC] <TensorType(int64, scalar)> ''
| | | | | | | | | | |Shape [id Z] <TensorType(int64, vector)> ''
| | | | | | | | | | |Constant{-1} [id BD] <int64>
| | | | | | | | | |Reshape{2} [id BE] <TensorType(float32, matrix)> ''
| | | | | | | | | |DimShuffle{1,0,2} [id BF] <TensorType(float32, 3D)> ''
| | | | | | | | | | |W2 [id BG] <TensorType(float32, 3D)>
| | | | | | | | | |MakeVector{dtype='int64'} [id BH] <TensorType(int64, vector)> ''
| | | | | | | | | |Elemwise{mul,no_inplace} [id BI] <TensorType(int64, scalar)> ''
| | | | | | | | | | |TensorConstant{1} [id X] <TensorType(int8, scalar)>
| | | | | | | | | | |Subtensor{int64} [id BJ] <TensorType(int64, scalar)> ''
| | | | | | | | | | |Shape [id BK] <TensorType(int64, vector)> ''
| | | | | | | | | | | |DimShuffle{1,0,2} [id BF] <TensorType(float32, 3D)> ''
| | | | | | | | | | |Constant{0} [id BA] <int64>
| | | | | | | | | |Elemwise{mul,no_inplace} [id BL] <TensorType(int64, scalar)> ''
| | | | | | | | | |Elemwise{mul,no_inplace} [id BM] <TensorType(int64, scalar)> ''
| | | | | | | | | | |TensorConstant{1} [id X] <TensorType(int8, scalar)>
| | | | | | | | | | |Subtensor{int64} [id BN] <TensorType(int64, scalar)> ''
| | | | | | | | | | |Shape [id BK] <TensorType(int64, vector)> ''
| | | | | | | | | | |Constant{-1} [id BD] <int64>
| | | | | | | | | |Subtensor{int64} [id BO] <TensorType(int64, scalar)> ''
| | | | | | | | | |Shape [id BK] <TensorType(int64, vector)> ''
| | | | | | | | | |Constant{-2} [id BP] <int64>
| | | | | | | | |Join [id BQ] <TensorType(int64, vector)> ''
| | | | | | | | |TensorConstant{0} [id BR] <TensorType(int8, scalar)>
| | | | | | | | |Subtensor{int64:int64:} [id BS] <TensorType(int64, vector)> ''
| | | | | | | | | |Shape [id Z] <TensorType(int64, vector)> ''
| | | | | | | | | |Constant{0} [id BA] <int64>
| | | | | | | | | |Constant{1} [id BT] <int64>
| | | | | | | | |Subtensor{int64:int64:} [id BU] <TensorType(int64, vector)> ''
| | | | | | | | |Shape [id BK] <TensorType(int64, vector)> ''
| | | | | | | | |Constant{1} [id BT] <int64>
| | | | | | | | |Constant{3} [id BV] <int64>
| | | | | | | |DimShuffle{x,0,1} [id BW] <TensorType(float32, (True, False, False))> ''
| | | | | | | |b2 [id BX] <TensorType(float32, matrix)>
| | | | | | |DimShuffle{0,x,1} [id BY] <TensorType(float32, (False, True, False))> ''
| | | | | | |SoftmaxGrad [id BZ] <TensorType(float32, matrix)> ''
| | | | | | |AdvancedIncSubtensor{inplace=False, set_instead_of_inc=False} [id CA] <TensorType(float32, matrix)> ''
| | | | | | | |Elemwise{second,no_inplace} [id CB] <TensorType(float32, matrix)> ''
| | | | | | | | |Softmax [id CC] <TensorType(float32, matrix)> ''
| | | | | | | | | |MaxAndArgmax.0 [id K] <TensorType(float32, matrix)> 'max'
| | | | | | | | |TensorConstant{(1, 1) of 0.0} [id CD] <TensorType(float32, (True, True))>
| | | | | | | |Elemwise{true_div} [id CE] <TensorType(float32, vector)> ''
| | | | | | | | |Elemwise{second} [id CF] <TensorType(float32, vector)> ''
| | | | | | | | | |Elemwise{log,no_inplace} [id CG] <TensorType(float32, vector)> ''
| | | | | | | | | | |AdvancedSubtensor [id CH] <TensorType(float32, vector)> ''
| | | | | | | | | | |Softmax [id CC] <TensorType(float32, matrix)> ''
| | | | | | | | | | |ARange{dtype='int64'} [id CI] <TensorType(int64, vector)> ''
| | | | | | | | | | | |TensorConstant{0} [id BR] <TensorType(int8, scalar)>
| | | | | | | | | | | |Subtensor{int64} [id CJ] <TensorType(int64, scalar)> ''
| | | | | | | | | | | | |Shape [id CK] <TensorType(int64, vector)> ''
| | | | | | | | | | | | | |Softmax [id CC] <TensorType(float32, matrix)> ''
| | | | | | | | | | | | |Constant{0} [id BA] <int64>
| | | | | | | | | | | |TensorConstant{1} [id X] <TensorType(int8, scalar)>
| | | | | | | | | | |TensorConstant{[0 0 0 0 0..1 1 1 1 1]} [id CL] <TensorType(int64, vector)>
| | | | | | | | | |DimShuffle{x} [id CM] <TensorType(float32, (True,))> ''
| | | | | | | | | |Elemwise{true_div} [id CN] <TensorType(float32, scalar)> ''
| | | | | | | | | |TensorConstant{-1.0} [id CO] <TensorType(float32, scalar)>
| | | | | | | | | |Elemwise{Cast{float32}} [id CP] <TensorType(float32, scalar)> ''
| | | | | | | | | |Subtensor{int64} [id CQ] <TensorType(int64, scalar)> ''
| | | | | | | | | |Shape [id CR] <TensorType(int64, vector)> ''
| | | | | | | | | | |Elemwise{log,no_inplace} [id CG] <TensorType(float32, vector)> ''
| | | | | | | | | |Constant{0} [id BA] <int64>
| | | | | | | | |AdvancedSubtensor [id CH] <TensorType(float32, vector)> ''
| | | | | | | |ARange{dtype='int64'} [id CI] <TensorType(int64, vector)> ''
| | | | | | | |TensorConstant{[0 0 0 0 0..1 1 1 1 1]} [id CL] <TensorType(int64, vector)>
| | | | | | |Softmax [id CC] <TensorType(float32, matrix)> ''
| | | | | |Shape [id CS] <TensorType(int64, vector)> ''
| | | | | |Dot22 [id N] <TensorType(float32, matrix)> ''
| | | | |DimShuffle{1,0} [id CT] <TensorType(float32, matrix)> ''
| | | | |Reshape{2} [id BE] <TensorType(float32, matrix)> ''
| | | |Shape [id Z] <TensorType(int64, vector)> ''
| | |TensorConstant{(1, 1) of 0.5} [id R] <TensorType(float32, (True, True))>
| |MaxAndArgmax.0 [id T] <TensorType(float32, matrix)> 'max'
|Elemwise{abs_,no_inplace} [id U] <TensorType(float32, matrix)> ''
import numpy as np
import theano
import theano.tensor as T
# generate XOR data (25 points at each quadrant (-1, -1), (1, 1), (-1, 1), (1, -1))
data = np.vstack((np.random.normal(scale=0.2, size=(25, 2)) + [-1, -1],
np.random.normal(scale=0.2, size=(25, 2)) + [1, 1],
np.random.normal(scale=0.2, size=(25, 2)) + [-1, 1],
np.random.normal(scale=0.2, size=(25, 2)) + [1, -1])).astype('float32')
# generate corresponding labels
labels = np.array([0]*50 + [1]*50)
# input variable
input = T.matrix('input')
# weights and biases of the 2-5-2 network
W1 = theano.shared(np.random.normal(scale=0.01, size=(1, 2, 5)).astype('float32'), name='W1')
b1 = theano.shared(np.zeros((1, 5,), dtype='float32'), name='b1')
W2 = theano.shared(np.random.normal(scale=0.01, size=(1, 5, 2)).astype('float32'), name='W2')
b2 = theano.shared(np.zeros((1, 2,), dtype='float32'), name='b2')
# calculate maxout output
h1 = T.max(T.dot(input, W1) + b1, axis=1)
# apply activation function
y1 = T.nnet.relu(h1)
# repeat for output layer
h2 = T.max(T.dot(y1, W2) + b2, axis=1)
y2 = T.nnet.softmax(h2)
# calculate cross entropy
cross_entropy = -T.mean(T.log(y2[T.arange(y2.shape[0]),labels]))
# get gradient
params = [W1, b1, W2, b2]
grads = T.grad(cross_entropy, params)
# batch gradient descent with learning rate 0.1
f = theano.function([input], cross_entropy,
updates=[(param, param - 0.1*grad)
for param, grad in zip(params, grads)])
# train the network
for i in range(100000):
print("Iteration {}: {}".format(i+1, f(data)))
# check for nans in the updated parameters
nan_found = False
for param in params:
if np.isnan(param.get_value()).any():
print("nan found in", param.name)
nan_found = True
if nan_found:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment