Skip to content

Commit

Permalink
Add seed_rng() calls in tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
abergeron committed Nov 4, 2014
1 parent a4b621a commit 1b8e5b6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
5 changes: 2 additions & 3 deletions advanced.tex
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ \section{How to Make an Op (Python)}
\end{frame}

\begin{frame}{Tests}
To test the \code{infer_shape} method we use \code{InferShapeTester}
\lstinputlisting[linerange={5-5,19-32}]{test_doubleop.py}
\lstinputlisting[linerange={5-5,20-34}]{test_doubleop.py}
\end{frame}

\begin{frame}{Gradient}
Expand All @@ -220,7 +219,7 @@ \section{How to Make an Op (Python)}

\begin{frame}{Tests}
To test the gradient we use \code{verify_grad}
\lstinputlisting[linerange={5-5,33-41}]{test_doubleop.py}
\lstinputlisting[linerange={5-5,36-44}]{test_doubleop.py}
It will compute the gradient numerically and symbolically (using our \code{grad()} method) and compare the two.
\end{frame}

Expand Down
8 changes: 3 additions & 5 deletions test_doubleop.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@


def test_doubleop():
utt.seed_rng()
x = matrix()
f = function([x], DoubleOp()(x))
inp = numpy.asarray(numpy.random.rand(5, 4),
Expand All @@ -19,6 +20,7 @@ def test_doubleop():

class test_Double(utt.InferShapeTester):
def test_infer_shape(self):
utt.seed_rng()
x = matrix()
self._compile_and_check(
# function inputs (symbolic)
Expand All @@ -33,14 +35,10 @@ def test_infer_shape(self):


def test_doubleop_grad():
utt.seed_rng()
utt.verify_grad(
# Op instance
DoubleOp(),
# Numeric inputs
[numpy.random.rand(5, 7, 2)]
)


class test_DoubleRop(RopLop_checker):
def test_double_rop(self):
self.check_rop_lop(DoubleOp()(self.x), self.in_shape)

0 comments on commit 1b8e5b6

Please sign in to comment.