๓
เฦ๗Xc           @` s   d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l m	 Z
 d e j f d     YZ e d k r e j   n  d S(   i    (   t   absolute_importt   print_functiont   divisionN(   t   unittest_toolst   T_scipyc           B` s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C` s   t  j   t j j |  _ d  S(   N(   t   uttt   seed_rngt   theanot   configt   floatXt   orig_floatX(   t   self(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/diverse_tests.pyt   setUp   s    
c         C` s   |  j  t j _ d  S(   N(   R
   R   R   R	   (   R   (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/diverse_tests.pyt   tearDown   s    c         C` su   t  j j d  } | | d } t  j | g |  } t j | d d d g  t j d d d g  k  sq t  d  S(   Nt   ai
   i    i   i   i  (   R   t   tensort   vectort   functiont   numpyt   allt   arrayt   AssertionError(   R   R   t   bt   f(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/diverse_tests.pyt   test_scipy_paper_example1   s    c         C` s่  t  j } t  j } t  j } t j } d t  j _ | j   } | j	   } | | j
 d   } | t j d   } d d | j | j | |  |  }	 | | j |	  d | | j d |	  }
 |	 d k } |
 j   d | d j   } | j | | | g  \ } } | d | | g d | |
 g d	 | | d
 | f | | d
 | f g  } | d | g d |  d } d } | j
 | |  | j d d d d d d  f } d } x1 t |  D]# } | | d | d  \ } } qฝWd S(   s7    This just sees if things compile well and if they run t   float64id   i   g      เ?g{ฎGแz?i   t   inputst   outputst   updatesgน?i   t   sizet   lowi    t   highi
   N(    (   R   R   t   sharedR   R   t   randomR   R	   t   matrixR   t   randnt   zerost   expt   dott   logt   meant   sumt   gradt   randintt   range(   R   t   TR    R   t   rngt   xt   yt   wR   t   p_1t   xentt
   predictiont   costt   gwt   gbt   traint   Nt   featst   Dt   training_stepst   it   predt   err(    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/diverse_tests.pyt   test_scipy_paper_example2!   s2    				(-+0(   t   __name__t
   __module__R   R   R   R@   (    (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/diverse_tests.pyR      s   			t   __main__(   t
   __future__R    R   R   t   unittestR   t   numpy.randomR   t   theano.testsR   R   t   TestCaseR   RA   t   main(    (    (    s:   /tmp/pip-build-X4mzal/theano/theano/tests/diverse_tests.pyt   <module>   s   5