Mercurial > repos > rnateam > rnacommender
comparison model.py @ 4:a609d6dc8047 draft
planemo upload for repository https://github.com/bgruening/galaxytools/tree/rna_commander/tools/rna_tools/rna_commender commit 7ad344d108076116e702e1c1e91cea73d8fcadc4
author | rnateam |
---|---|
date | Thu, 28 Jul 2016 05:55:25 -0400 |
parents | 8918de535391 |
children |
comparison
equal
deleted
inserted
replaced
3:ecf125a1ad73 | 4:a609d6dc8047 |
---|---|
3 | 3 |
4 import sys | 4 import sys |
5 | 5 |
6 import numpy as np | 6 import numpy as np |
7 | 7 |
8 from theano import config, function, shared | 8 from theano import function, shared |
9 import theano.tensor as T | 9 import theano.tensor as T |
10 | 10 |
11 __author__ = "Gianluca Corrado" | 11 __author__ = "Gianluca Corrado" |
12 __copyright__ = "Copyright 2016, Gianluca Corrado" | 12 __copyright__ = "Copyright 2016, Gianluca Corrado" |
13 __license__ = "MIT" | 13 __license__ = "MIT" |
59 | 59 |
60 self.learning_rate = learning_rate | 60 self.learning_rate = learning_rate |
61 self.lambda_reg = lambda_reg | 61 self.lambda_reg = lambda_reg |
62 np.random.seed(seed) | 62 np.random.seed(seed) |
63 # explictit features for proteins | 63 # explictit features for proteins |
64 fp = T.matrix("Fp", dtype=config.floatX) | 64 fp = T.matrix("Fp", dtype='float32') |
65 # explictit features for RNAs | 65 # explictit features for RNAs |
66 fr = T.matrix("Fr", dtype=config.floatX) | 66 fr = T.matrix("Fr", dtype='float32') |
67 # Correct label | 67 # Correct label |
68 y = T.vector("y") | 68 y = T.vector("y") |
69 | 69 |
70 # projection matrix for proteins | 70 # projection matrix for proteins |
71 self.Ap = shared(((.5 - np.random.rand(kp, sp)) * | 71 self.Ap = shared(((.5 - np.random.rand(kp, sp)) * |
72 irange).astype(config.floatX), name="Ap") | 72 irange).astype('float32'), name="Ap") |
73 self.bp = shared(((.5 - np.random.rand(kp)) * | 73 self.bp = shared(((.5 - np.random.rand(kp)) * |
74 irange).astype(config.floatX), name="bp") | 74 irange).astype('float32'), name="bp") |
75 # projection matrix for RNAs | 75 # projection matrix for RNAs |
76 self.Ar = shared(((.5 - np.random.rand(kr, sr)) * | 76 self.Ar = shared(((.5 - np.random.rand(kr, sr)) * |
77 irange).astype(config.floatX), name="Ar") | 77 irange).astype('float32'), name="Ar") |
78 self.br = shared(((.5 - np.random.rand(kr)) * | 78 self.br = shared(((.5 - np.random.rand(kr)) * |
79 irange).astype(config.floatX), name="br") | 79 irange).astype('float32'), name="br") |
80 # generalization matrix | 80 # generalization matrix |
81 self.B = shared(((.5 - np.random.rand(kp, kr)) * | 81 self.B = shared(((.5 - np.random.rand(kp, kr)) * |
82 irange).astype(config.floatX), name="B") | 82 irange).astype('float32'), name="B") |
83 | 83 |
84 # Latent space for proteins | 84 # Latent space for proteins |
85 p = T.nnet.sigmoid(T.dot(fp, self.Ap.T) + self.bp) | 85 p = T.nnet.sigmoid(T.dot(fp, self.Ap.T) + self.bp) |
86 # Latent space for RNAs | 86 # Latent space for RNAs |
87 r = T.nnet.sigmoid(T.dot(fr, self.Ar.T) + self.br) | 87 r = T.nnet.sigmoid(T.dot(fr, self.Ar.T) + self.br) |