IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Procházet zdrojové kódy

Merge pull request 'master' (#2) from sadaszewski1/decagon-pytorch:master into master

master
sadaszewski před 4 roky
rodič
revize
40b572ba2a
6 změnil soubory, kde provedl 36 přidání a 0 odebrání
  1. +2
    -0
      .gitignore
  2. +3
    -0
      decagon_pytorch/__init__.py
  3. +0
    -0
      decagon_pytorch/convolve.py
  4. +18
    -0
      decagon_pytorch/dropout.py
  5. +0
    -0
      decagon_pytorch/model.py
  6. +13
    -0
      decagon_pytorch/weights.py

+ 2
- 0
.gitignore Zobrazit soubor

@@ -0,0 +1,2 @@
__pycache__


+ 3
- 0
decagon_pytorch/__init__.py Zobrazit soubor

@@ -0,0 +1,3 @@
from .weights import *
from .convolve import *
from .model import *

+ 0
- 0
decagon_pytorch/convolve.py Zobrazit soubor


+ 18
- 0
decagon_pytorch/dropout.py Zobrazit soubor

@@ -0,0 +1,18 @@
import torch
def dropout_sparse(x, keep_prob):
"""Dropout for sparse tensors.
"""
x = x.coalesce()
i = x._indices()
v = x._values()
size = x.size()
n = keep_prob + torch.rand(len(v))
n = torch.floor(n).to(torch.bool)
i = i[:,n]
v = v[n]
x = torch.sparse_coo_tensor(i, v, size=size)
return x * (1./keep_prob)

+ 0
- 0
decagon_pytorch/model.py Zobrazit soubor


+ 13
- 0
decagon_pytorch/weights.py Zobrazit soubor

@@ -0,0 +1,13 @@
import torch
import numpy as np
def init_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

Načítá se…
Zrušit
Uložit