예제 #1
0
 def initialize(self, weight_type="none"):
     """Initialize weights and bias
     
     Parameters
     ----------
     weight_type : string
         type of weights: "none", "tanh", "sigmoid"
     """
     
     if self.W==None:
         self.W=util.init_weights("W", self.out_dim, self.in_dim, weight_type=weight_type);
         
     if self.use_bias==True and self.bias==None:
         self.bias=util.init_weights("bias", self.out_dim, weight_type=weight_type);
예제 #2
0
    def initialize(self, weight_type="none"):
        """Initialize weights and bias
        
        Parameters
        ----------
        weight_type : string
            type of weights: "none", "tanh", "sigmoid"
        """

        # should have better implementation for convnet weights

        fan_in = self.num_channels * np.prod(self.filter_size)
        fan_out = self.num_filters * np.prod(self.filter_size)

        filter_bound = np.sqrt(6. / (fan_in + fan_out))
        filter_shape = (self.num_filters,
                        self.num_channels) + (self.filter_size)
        self.filters = theano.shared(np.asarray(np.random.uniform(
            low=-filter_bound, high=filter_bound, size=filter_shape),
                                                dtype='float32'),
                                     borrow=True)

        if self.use_bias == True:
            self.bias = util.init_weights("bias",
                                          self.num_filters,
                                          weight_type=weight_type)
예제 #3
0
파일: convnet.py 프로젝트: yenat/opencog
 def initialize(self, weight_type="none"):
     """Initialize weights and bias
     
     Parameters
     ----------
     weight_type : string
         type of weights: "none", "tanh", "sigmoid"
     """
     
     # should have better implementation for convnet weights
     
     fan_in = self.num_channels*np.prod(self.filter_size);
     fan_out = self.num_filters*np.prod(self.filter_size);
     
     filter_bound=np.sqrt(6./(fan_in + fan_out));
     filter_shape=(self.num_filters, self.num_channels)+(self.filter_size);
     self.filters = theano.shared(np.asarray(np.random.uniform(low=-filter_bound,
                                                               high=filter_bound,
                                                               size=filter_shape),
                                                               dtype='float32'),
                                                               borrow=True);
     
     if self.use_bias==True:
         self.bias=util.init_weights("bias", self.num_filters, weight_type=weight_type);