Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0c74eac2
提交
0c74eac2
authored
1月 20, 2011
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Minor improvements in doc about how to write a new type
上级
79fda719
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
8 行删除
+9
-8
type.txt
doc/extending/type.txt
+9
-8
没有找到文件。
doc/extending/type.txt
浏览文件 @
0c74eac2
...
@@ -122,10 +122,10 @@ must define ``filter`` and shall override ``values_eq_approx``.
...
@@ -122,10 +122,10 @@ must define ``filter`` and shall override ``values_eq_approx``.
else:
else:
return float(x)
return float(x)
If ``strict
== True`` we need to return ``x``. If ``strict ==
True`` and ``x`` is not a
If ``strict
is True`` we need to return ``x``. If ``strict is
True`` and ``x`` is not a
``float`` (for example, ``x`` could easily be an ``int``) then it is
``float`` (for example, ``x`` could easily be an ``int``) then it is
incompatible with our Type and we must raise an exception. If
incompatible with our Type and we must raise an exception. If
``strict
==
False`` then we are allowed to cast ``x`` to a ``float``,
``strict
is
False`` then we are allowed to cast ``x`` to a ``float``,
so if ``x`` is an ``int`` it we will return an equivalent ``float``.
so if ``x`` is an ``int`` it we will return an equivalent ``float``.
...
@@ -143,7 +143,7 @@ graph in such a way that it produces slightly different variables, for
...
@@ -143,7 +143,7 @@ graph in such a way that it produces slightly different variables, for
example because of numerical instability like rounding errors at the
example because of numerical instability like rounding errors at the
end of the mantissa. For instance, ``a + a + a + a + a + a`` might not
end of the mantissa. For instance, ``a + a + a + a + a + a`` might not
actually produce the exact same output as ``6 * a`` (try with a=0.1),
actually produce the exact same output as ``6 * a`` (try with a=0.1),
but with ``values_eq_approx`` we do
n'
t necessarily mind.
but with ``values_eq_approx`` we do
no
t necessarily mind.
We added an extra ``tolerance`` argument here. Since this argument is
We added an extra ``tolerance`` argument here. Since this argument is
not part of the API, it must have a default value, which we
not part of the API, it must have a default value, which we
...
@@ -215,8 +215,9 @@ There are several ways to make sure that equality testing works properly:
...
@@ -215,8 +215,9 @@ There are several ways to make sure that equality testing works properly:
#. Define ``Double.__eq__`` so that instances of type Double
#. Define ``Double.__eq__`` so that instances of type Double
are equal. For example:
are equal. For example:
.. If you modify this code, also change :
.. If you modify this code, also change :
.. theano/tests/test_tutorial.py:T_extending.test_extending_1
.. theano/tests/test_tutorial.py:T_extending.test_extending_1
.. code-block:: python
.. code-block:: python
def __eq__(self, other):
def __eq__(self, other):
...
@@ -225,8 +226,8 @@ There are several ways to make sure that equality testing works properly:
...
@@ -225,8 +226,8 @@ There are several ways to make sure that equality testing works properly:
#. Override ``Double.__new__`` to always return the same instance.
#. Override ``Double.__new__`` to always return the same instance.
#. Hide the Double class and only advertise a single instance of it.
#. Hide the Double class and only advertise a single instance of it.
Here we will prefer the final option, because it
'
s the simplest.
Here we will prefer the final option, because it
i
s the simplest.
O
ften Ops in the Theano code define the ``__eq__`` function
though.
O
ps in the Theano code often define the ``__eq__`` method
though.
Untangling some concepts
Untangling some concepts
...
@@ -257,7 +258,7 @@ attempt to clear up the confusion:
...
@@ -257,7 +258,7 @@ attempt to clear up the confusion:
a set of Type instances that share
a set of Type instances that share
structural similarities. In the ``double`` example that we are doing,
structural similarities. In the ``double`` example that we are doing,
there is actually only one Type in that set, therefore the subclass
there is actually only one Type in that set, therefore the subclass
does
n't represent anything that one of its instances doesn'
t. In this
does
not represent anything that one of its instances does no
t. In this
case it is a singleton, a set with one element. However, the
case it is a singleton, a set with one element. However, the
:class:`TensorType`
:class:`TensorType`
class in Theano (which is a subclass of Type)
class in Theano (which is a subclass of Type)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论