Пример #1
0
	def __init__(self, input_dim, output_dim, **kwargs):
		"""Initialization.

		Weights are randomly initialized from a normal distribution.
		Biases are initialized to zero.

		Args:
			input_dim: input dimensionality to layer
			output_dim: output dimensionality from layer
			mu (kwargs): set the mean for random initialization
			sigma (kwargs): set the standard deviation for random initialization
		"""
		Layer.__init__(self)

		self.input_dim = input_dim
		self.output_dim = output_dim

		self.mu = kwargs["mu"] if "mu" in kwargs else LinearLayer.DEFAULT_INITIAL_MU
		self.sigma = kwargs["sigma"] if "sigma" in kwargs else LinearLayer.DEFAULT_INITIAL_SIGMA

		# initialize weights
		if output_dim == 1:
			shape = (input_dim,)
		else:
			shape = (output_dim, input_dim)
		self.W = np.random.normal(self.mu, self.sigma, shape)

		# initialize biases
		if output_dim == 1:
			self.b = 0
		else:
			self.b = np.zeros(output_dim)
Пример #2
0
    def __init__(self, input_dim, output_dim, **kwargs):
        """Initialization.

		Weights are randomly initialized from a normal distribution.
		Biases are initialized to zero.

		Args:
			input_dim: input dimensionality to layer
			output_dim: output dimensionality from layer
			mu (kwargs): set the mean for random initialization
			sigma (kwargs): set the standard deviation for random initialization
		"""
        Layer.__init__(self)

        self.input_dim = input_dim
        self.output_dim = output_dim

        self.mu = kwargs[
            "mu"] if "mu" in kwargs else LinearLayer.DEFAULT_INITIAL_MU
        self.sigma = kwargs[
            "sigma"] if "sigma" in kwargs else LinearLayer.DEFAULT_INITIAL_SIGMA

        # initialize weights
        if output_dim == 1:
            shape = (input_dim, )
        else:
            shape = (output_dim, input_dim)
        self.W = np.random.normal(self.mu, self.sigma, shape)

        # initialize biases
        if output_dim == 1:
            self.b = 0
        else:
            self.b = np.zeros(output_dim)
Пример #3
0
    def __init__(self, input_dim, output_dim, **kwargs):
        Layer.__init__(self)

        self.input_dim = input_dim
        self.output_dim = output_dim

        self.mu = kwargs[
            "mu"] if "mu" in kwargs else LinearLayer.DEFAULT_INITIAL_MU
        self.sigma = kwargs[
            "sigma"] if "sigma" in kwargs else LinearLayer.DEFAULT_INITIAL_SIGMA

        if output_dim == 1:
            shape = (input_dim, )
        else:
            shape = (output_dim, input_dim)
        self.W = np.random.normal(self.mu, self.sigma, shape)

        if output_dim == 1:
            self.b = 0
        else:
            self.b = np.zeros(output_dim)
Пример #4
0
 def __init__(self):
     Layer.__init__(self)
Пример #5
0
	def __init__(self):
		Layer.__init__(self)