Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
72528716
提交
72528716
authored
5月 28, 2009
作者:
bergstra@ip05.m
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added max_gotcha to doc/sandbox
上级
32c89d03
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
39 行增加
和
0 行删除
+39
-0
max_gotcha.txt
doc/sandbox/max_gotcha.txt
+39
-0
没有找到文件。
doc/sandbox/max_gotcha.txt
0 → 100644
浏览文件 @
72528716
Guillaume and I just found a bug in some experiment code that was
basically caused by confusing semantics of max(). The same sort of
thing applies to min. This is an FYI email to help others on the list
avoid this mistake, which is (I think) easy to make.
Python's max() function takes multiple arguments and returns the
largest one of them. (I won't go into the details of how it deals with
corner cases.)
IN CONTRAST
numpy's max() function takes multiple arguments and returns the
largest element[s] from the *first* argument. The second argument is
used to identify the axis along which to evaluate the [python-style]
max. The third argument is an array into which the result can be
written.
So for example:
.. code-block:: python
>>> max(3, 4)
4
>>> numpy.max(3, 4)
3
>>> a,b,c = [numpy.asarray(i) for i in [0,1,2]]
>>> numpy.max(a,b,c)
0
>>> c
array(0)
Be careful!
Theano defines a max function (called theano.tensor.max) that is
similar numpy's max.
Theano also defines a function called theano.tensor.largest that is
closer to python's, but not identical since it works elemwise for
tensors. There is a corresponding 'smallest' function that is like
min()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论