The Wayback Machine - https://web.archive.org/web/20200621142855/https://github.com/keras-team/keras/issues/13995
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convolution and dense layers default initializer #13995

Open
saeedalahmari3 opened this issue Apr 23, 2020 · 1 comment
Open

Convolution and dense layers default initializer #13995

saeedalahmari3 opened this issue Apr 23, 2020 · 1 comment
Labels

Comments

@saeedalahmari3
Copy link

@saeedalahmari3 saeedalahmari3 commented Apr 23, 2020

In Keras documentation, glorot_uniform says that the initializer is using Glorot Uniform from this paper. However, the Keras implementation is totally different from the equation on the paper. Also, there are some arguments such as mode ='fan_avg' is the default. It should be same as the referenced paper. 'fan_sum'. Golort uniform is shown in Equation 1, but Keras implementation is shown in Equation 2. I had hard time to produce the same or close results to Keras using Pytorch.
Screen Shot 2020-04-23 at 9 44 11 AM

def __call__(self, shape, dtype=None): fan_in, fan_out = _compute_fans(shape) scale = self.scale if self.mode == 'fan_in': scale /= max(1., fan_in) elif self.mode == 'fan_out': scale /= max(1., fan_out) else: scale /= max(1., float(fan_in + fan_out) / 2) if self.distribution == 'normal': # 0.879... = scipy.stats.truncnorm.std(a=-2, b=2, loc=0., scale=1.) stddev = np.sqrt(scale) / .87962566103423978 x = K.truncated_normal(shape, 0., stddev, dtype=dtype, seed=self.seed) else: limit = np.sqrt(3. * scale) x = K.random_uniform(shape, -limit, limit, dtype=dtype, seed=self.seed) if self.seed is not None: self.seed += 1 return x

@TAMuga-arch
Copy link

@TAMuga-arch TAMuga-arch commented May 7, 2020

Suppose you have a sentence x which is a string; e.g., x = "erath is falt".
Write the Python code for taking a sentence x and producing a dict representing the following two feature templates please help to solve

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants
You can’t perform that action at this time.