How to use the cgt.core.Result function in cgt

To help you get started, we’ve selected a few cgt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joschu / cgt / cgt / core.py View on Github external
def irfft(x, axes):
    return Result(IRFFT(axes),[x])
github joschu / cgt / cgt / nn_ops / cudnn_ops.py View on Github external
def pullback(self, inputs, _output, gout):
        X,W,b = inputs
        # pass in an extra first argument to make output shape computation simpler
        return [core.Result(CudnnConvBackwardData(self.ph, self.pw, self.sv, self.sh),   [X,   gout, W]), 
                core.Result(CudnnConvBackwardFilter(self.ph, self.pw, self.sv, self.sh), [W,   gout, X]), 
                core.Result(CudnnConvBackwardBias(self.ph, self.pw, self.sv, self.sh),   [b,   gout])]
github joschu / cgt / cgt / core.py View on Github external
def size(x, axis):
    return Result(Size(axis), [x])
github joschu / cgt / cgt / api.py View on Github external
def zeros(shape, dtype=None): #pylint: disable=W0621
    """
    Like numpy.zeros
    """
    if (dtype is None):
        dtype = cgt.floatX
    return core.Result(core.Fill(np.array(0, dtype)), shape)
github joschu / cgt / cgt / core.py View on Github external
def pullback(self, inputs, output, goutput):
        return [Result(Repeat(self.axes), [goutput] + [size(inputs[0],ax) for ax in self.axes])]
    def shp_apply(self, inputs):
github joschu / cgt / cgt / core.py View on Github external
def reshape(x, shape): #pylint: disable=W0621
    return Result(Reshape(), [x] + list(shape))
github joschu / cgt / cgt / api.py View on Github external
def fill(val, shape):
    """
    Create an array of shape `shape` filled with scalar `val`
    """
    assert isinstance(shape, list)
    val = core.as_node(val)
    # if val is a constant, use a Fill Op, which includes the value as a attribute
    if isinstance(val.op, core.Constant):
        return core.Result(core.Fill(val.op.value), shape)
    # if val is a non-constant variable, we can use a Repeat Op
    else:
        singleton = reshape(val, [1]*len(shape))
        return core.Result(core.Repeat(range(len(shape))), [singleton] + shape)
github joschu / cgt / cgt / api.py View on Github external
def _subtensor4(x, slis, y):
    for (ax,sli) in enumerate(slis):
        if _is1dintarray(sli):
            if y is None:
                return core.Result(core.GetFancySli(ax), [x, sli])
            else:
                return core.Result(core.IncFancySli(ax), [x, sli, y])
    assert 0, "should be unreachable"
github joschu / cgt / cgt / core.py View on Github external
def batched_matmul(x, y):
    return Result(BatchedMul22(False,False), [x,y])
github joschu / cgt / cgt / api_autogen.py View on Github external
def cos(x):
    "Applies function cos elementwise to argument x"
    return core.Result(core.ElwiseUnary("cos"), [x])