changeset 903:3b53ed688747

extension to kouh2008 layer have linear and softplus inputs
author James Bergstra <bergstrj@iro.umontreal.ca>
date Fri, 12 Mar 2010 01:50:40 -0500
parents e966d5ab8103
children 08b37147dec1
files pylearn/shared/layers/kouh2008.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/shared/layers/kouh2008.py	Mon Mar 08 17:56:51 2010 -0500
+++ b/pylearn/shared/layers/kouh2008.py	Fri Mar 12 01:50:40 2010 -0500
@@ -218,8 +218,14 @@
 
         #softsign's range is (-1, 1)
         # we want filter responses to span (x_low, x_high)
-        x_list = [x_low + (x_high-x_low)*(d(0.5) + d(0.5)*softsign(tensor.dot(input, f_list[i])+b_list[i]))
-                    for i in xrange(n_terms)]
+        if x_low < x_high:
+            x_list = [x_low + (x_high-x_low)*(d(0.5) + d(0.5)*softsign(tensor.dot(input, f_list[i])+b_list[i]))
+                        for i in xrange(n_terms)]
+        else:
+            if x_low == x_high:
+                x_list = [(tensor.dot(input, f_list[i])+b_list[i]) for i in xrange(n_terms)]
+            else: #x_low > x_high
+                x_list = [softplus(tensor.dot(input, f_list[i])+b_list[i]) for i in xrange(n_terms)]
 
         rval = cls.new_expbounds(rng, x_list, n_out, dtype=dtype, params=f_list + b_list,
                 p_range=p_range,