From add6670eb9b56e3b49042ce70f7cf9f51a28bcc9 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Sat, 9 May 2020 07:58:07 +0200 Subject: [PATCH] Added weight_variable_glorot --- .gitignore | 2 ++ decagon_pytorch/convolve.py | 0 decagon_pytorch/weight.py | 13 +++++++++++++ 3 files changed, 15 insertions(+) create mode 100644 .gitignore create mode 100755 decagon_pytorch/convolve.py create mode 100755 decagon_pytorch/weight.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c20c2ab --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +__pycache__ + diff --git a/decagon_pytorch/convolve.py b/decagon_pytorch/convolve.py new file mode 100755 index 0000000..e69de29 diff --git a/decagon_pytorch/weight.py b/decagon_pytorch/weight.py new file mode 100755 index 0000000..5321660 --- /dev/null +++ b/decagon_pytorch/weight.py @@ -0,0 +1,13 @@ +import torch +import numpy as np + + +def weight_variable_glorot(input_dim, output_dim): + """Create a weight variable with Glorot & Bengio (AISTATS 2010) + initialization. + """ + init_range = np.sqrt(6.0 / (input_dim + output_dim)) + initial = -init_range + 2 * init_range * \ + torch.rand(( input_dim, output_dim ), dtype=torch.float32) + initial = initial.requires_grad_(True) + return initial