Python theano.tensor.le() Examples
The following are 30
code examples of theano.tensor.le().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
theano.tensor
, or try the search function
.
Example #1
Source File: test_basic_ops.py From D-VAE with MIT License | 6 votes |
def test_elemwise_comparaison_cast(): """ test if an elemwise comparaison followed by a cast to float32 are pushed to gpu. """ a = tensor.fmatrix() b = tensor.fmatrix() av = theano._asarray(numpy.random.rand(4, 4), dtype='float32') bv = numpy.ones((4, 4), dtype='float32') for g, ans in [(tensor.lt, av < bv), (tensor.gt, av > bv), (tensor.le, av <= bv), (tensor.ge, av >= bv)]: f = pfunc([a, b], tensor.cast(g(a, b), 'float32'), mode=mode_with_gpu) out = f(av, bv) assert numpy.all(out == ans) assert any([isinstance(node.op, cuda.GpuElemwise) for node in f.maker.fgraph.toposort()])
Example #2
Source File: core.py From starry with MIT License | 6 votes |
def flux(self, xo, yo, zo, ro, u): """Compute the light curve.""" # Initialize flat light curve flux = tt.ones_like(xo) # Compute the occultation mask b = tt.sqrt(xo ** 2 + yo ** 2) b_occ = tt.invert(tt.ge(b, 1.0 + ro) | tt.le(zo, 0.0) | tt.eq(ro, 0.0)) i_occ = tt.arange(b.size)[b_occ] # Get the Agol `c` coefficients c = self._get_cl(u) if self.udeg == 0: c_norm = c / (np.pi * c[0]) else: c_norm = c / (np.pi * (c[0] + 2 * c[1] / 3)) # Compute the occultation flux los = zo[i_occ] r = ro * tt.ones_like(los) flux = tt.set_subtensor( flux[i_occ], self._limbdark(c_norm, b[i_occ], r, los)[0] ) return flux
Example #3
Source File: layers.py From gated_word_char_rlm with BSD 3-Clause "New" or "Revised" License | 6 votes |
def concat_layer(tparams, X_word, X_char, options, prefix, pretrain_mode, activ='lambda x: x', **kwargs): """ compute the forward pass for a concat layer Parameters ---------- tparams : OrderedDict of theano shared variables, {parameter name: value} X_word : theano 3d tensor, word input, dimensions: (num of time steps, batch size, dim of vector) X_char : theano 3d tensor, char input, dimensions: (num of time steps, batch size, dim of vector) options : dictionary, {hyperparameter: value} prefix : string, layer name pretrain_mode : theano shared scalar, 0. = word only, 1. = char only, 2. = word & char activ : string, activation function: 'liner', 'tanh', or 'rectifier' Returns ------- X : theano 3d tensor, final vector, dimensions: (num of time steps, batch size, dim of vector) """ X = ifelse(tensor.le(pretrain_mode, numpy.float32(1.)), ifelse(tensor.eq(pretrain_mode, numpy.float32(0.)), X_word, X_char), tensor.dot(tensor.concatenate([X_word, X_char], axis=2), tparams[p_name(prefix, 'W')]) + tparams[p_name(prefix, 'b')]) return eval(activ)(X)
Example #4
Source File: layers.py From gated_word_char_rlm with BSD 3-Clause "New" or "Revised" License | 6 votes |
def gate_layer(tparams, X_word, X_char, options, prefix, pretrain_mode, activ='lambda x: x', **kwargs): """ compute the forward pass for a gate layer Parameters ---------- tparams : OrderedDict of theano shared variables, {parameter name: value} X_word : theano 3d tensor, word input, dimensions: (num of time steps, batch size, dim of vector) X_char : theano 3d tensor, char input, dimensions: (num of time steps, batch size, dim of vector) options : dictionary, {hyperparameter: value} prefix : string, layer name pretrain_mode : theano shared scalar, 0. = word only, 1. = char only, 2. = word & char activ : string, activation function: 'liner', 'tanh', or 'rectifier' Returns ------- X : theano 3d tensor, final vector, dimensions: (num of time steps, batch size, dim of vector) """ # compute gating values, Eq.(3) G = tensor.nnet.sigmoid(tensor.dot(X_word, tparams[p_name(prefix, 'v')]) + tparams[p_name(prefix, 'b')][0]) X = ifelse(tensor.le(pretrain_mode, numpy.float32(1.)), ifelse(tensor.eq(pretrain_mode, numpy.float32(0.)), X_word, X_char), G[:, :, None] * X_char + (1. - G)[:, :, None] * X_word) return eval(activ)(X)
Example #5
Source File: test_basic_ops.py From attention-lvcsr with MIT License | 6 votes |
def test_elemwise_comparaison_cast(): """ test if an elemwise comparaison followed by a cast to float32 are pushed to gpu. """ a = tensor.fmatrix() b = tensor.fmatrix() av = theano._asarray(numpy.random.rand(4, 4), dtype='float32') bv = numpy.ones((4, 4), dtype='float32') for g, ans in [(tensor.lt, av < bv), (tensor.gt, av > bv), (tensor.le, av <= bv), (tensor.ge, av >= bv)]: f = pfunc([a, b], tensor.cast(g(a, b), 'float32'), mode=mode_with_gpu) out = f(av, bv) assert numpy.all(out == ans) assert any([isinstance(node.op, cuda.GpuElemwise) for node in f.maker.fgraph.toposort()])
Example #6
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): return input * T.gt(input, 0) + input * T.le(input, 0) * T.shape_padleft(self.W, n_ones=1);
Example #7
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
Example #8
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
Example #9
Source File: smthact_new.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): if self.tied_feamap: return input * T.gt(input, 0) + input * T.le(input, 0) \ * T.shape_padleft(T.shape_padright(self.W[seg], n_ones = len(input_dim) - 2)); else: return input * T.gt(input, 0) + input * T.le(input, 0) \ * T.shape_padleft(self.W);
Example #10
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
Example #11
Source File: theano_backend.py From deepQuest with BSD 3-Clause "New" or "Revised" License | 5 votes |
def less_equal(x, y): return T.le(x, y)
Example #12
Source File: theano_backend.py From KerasNeuralFingerprint with MIT License | 5 votes |
def lesser_equal(x, y): return T.le(x, y)
Example #13
Source File: likelihoods.py From cs-ranking with Apache License 2.0 | 5 votes |
def logp(self, value): p = self.p k = self.k a = self.loss_func(p, value) p = normalize(p) sum_to1 = theano.gradient.zero_grad(tt.le(abs(tt.sum(p, axis=-1) - 1), 1e-5)) value_k = tt.argmax(value, axis=1) return bound(a, value_k >= 0, value_k <= (k - 1), sum_to1)
Example #14
Source File: util.py From cs-ranking with Apache License 2.0 | 5 votes |
def logp(self, value): p = self.p k = self.k a = self.loss_func(p, value) p = ttu.normalize(p) sum_to1 = theano.gradient.zero_grad(tt.le(abs(tt.sum(p, axis=-1) - 1), 1e-5)) value_k = tt.argmax(value, axis=1) return bound(a, value_k >= 0, value_k <= (k - 1), sum_to1)
Example #15
Source File: theano_backend.py From keras-lambda with MIT License | 5 votes |
def less_equal(x, y): return T.le(x, y)
Example #16
Source File: theano_backend.py From Att-ChemdNER with Apache License 2.0 | 5 votes |
def lesser_equal(x, y): return T.le(x, y)
Example #17
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): return input * T.gt(input, 0) + input * T.le(input, 0) * T.shape_padleft(self.W, n_ones=1);
Example #18
Source File: smthact_new.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): if self.tied_feamap: return input * T.gt(input, 0) + input * T.le(input, 0) \ * T.shape_padleft(T.shape_padright(self.W[seg], n_ones = len(input_dim) - 2)); else: return input * T.gt(input, 0) + input * T.le(input, 0) \ * T.shape_padleft(self.W);
Example #19
Source File: smthact_new.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); if self.order == 1: return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend); else: return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
Example #20
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): return input * T.gt(input, 0) + input * T.le(input, 0) * T.shape_padleft(self.W, n_ones=1);
Example #21
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
Example #22
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
Example #23
Source File: smthact_new.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): if self.tied_feamap: return input * T.gt(input, 0) + input * T.le(input, 0) \ * T.shape_padleft(T.shape_padright(self.W[seg], n_ones = len(input_dim) - 2)); else: return input * T.gt(input, 0) + input * T.le(input, 0) \ * T.shape_padleft(self.W);
Example #24
Source File: smthact_new.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); if self.order == 1: return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend); else: return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
Example #25
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
Example #26
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): return x * T.gt(x, 0) + x * T.le(x, 0) * self.W;
Example #27
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + 0.5 * (x - s)**2 * cpstart * cpend + ((e - s) * (x - e) + 0.5 * (e - s)**2) * (1 - cpend);
Example #28
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def basisf(self, x, s, e): cpstart = T.le(s, x); cpend = T.gt(e, x); return 0 * (1 - cpstart) + (x - s) * cpstart * cpend + (e - s) * (1 - cpend);
Example #29
Source File: smthact.py From u24_lymphocyte with BSD 3-Clause "New" or "Revised" License | 5 votes |
def get_output_for(self, input, **kwargs): return input * T.gt(input, 0) + input * T.le(input, 0) * T.shape_padleft(self.W, n_ones=1);
Example #30
Source File: layers_lscnn.py From ShapeNet with GNU General Public License v3.0 | 5 votes |
def cubicBSpline(self, L): b = T.zeros_like(L) idx4 = T.ge(L, 0) * T.lt(L, 1) idx3 = T.ge(L, 1) * T.lt(L, 2) idx2 = T.ge(L, 2) * T.lt(L, 3) idx1 = T.ge(L, 3) * T.le(L, 4) b = T.switch(T.eq(idx4, 1), T.pow(L, 3) / 6, b) b = T.switch(T.eq(idx3, 1), (-3*T.pow(L-1,3) + 3*T.pow(L-1,2) + 3*(L-1) + 1) / 6, b) b = T.switch(T.eq(idx2, 1), ( 3*T.pow(L-2,3) - 6*T.pow(L-2,2) + 4) / 6, b) b = T.switch(T.eq(idx1, 1), (- T.pow(L-3,3) + 3*T.pow(L-3,2) - 3*(L-3) + 1) / 6, b) return b.T # b is K x K' and thus, as we multiply from the right with # betas, we need to transpose it