提交 4978a2df authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Fix markup in code sample

上级 ee915f91
...@@ -26,7 +26,9 @@ clarity. For example, when you write C code that assumes memory is contiguous, ...@@ -26,7 +26,9 @@ clarity. For example, when you write C code that assumes memory is contiguous,
you should check the strides and alignment. you should check the strides and alignment.
.. class:: Fibby(theano.Op) .. code-block:: python
class Fibby(theano.Op):
""" """
An arbitrarily generalized Fibbonacci sequence An arbitrarily generalized Fibbonacci sequence
...@@ -34,18 +36,22 @@ you should check the strides and alignment. ...@@ -34,18 +36,22 @@ you should check the strides and alignment.
def __eq__(self, other): def __eq__(self, other):
return type(self) == type(other) return type(self) == type(other)
def __hash__(self): def __hash__(self):
return hash(type(self)) return hash(type(self))
def make_node(self, x): def make_node(self, x):
x_ = tensor.as_tensor_variable(x) x_ = tensor.as_tensor_variable(x)
return theano.Apply(self, return theano.Apply(self,
inputs=[x_], inputs=[x_],
outputs=[x_.type()]) outputs=[x_.type()])
def perform(self, node, inputs, output_storage): def perform(self, node, inputs, output_storage):
x, = inputs x, = inputs
y = output_storage[0][0] = x.copy() y = output_storage[0][0] = x.copy()
for i in range(2,len(x)): for i in range(2,len(x)):
y[i] = y[i-1] * y[i-2] + x[i] y[i] = y[i-1] * y[i-2] + x[i]
def c_code(self, node, name, inames, onames, sub): def c_code(self, node, name, inames, onames, sub):
x, = inames x, = inames
y, = onames y, = onames
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论