Cython文档显示了如何使用重载方法声明现有C++类.
但是,如果我cppclass使用重载方法定义自己的...
cdef cppclass point:
float x, y
point():
this.x = 0
this.y = 0
float sum():
return this.x + this.y
float sum(int z): # COMPILE ERROR
return this.x + this.y + z
Run Code Online (Sandbox Code Playgroud)
我明白了
函数签名与先前的声明不匹配
重载构造函数会在那里产生相同的错误:
cdef cppclass point:
float x, y
point():
this.x = 0
this.y = 0
point(float X, float Y): # COMPILE ERROR
this.x = X
this.y = Y
float sum():
return this.x + this.y
Run Code Online (Sandbox Code Playgroud)
我这样做不正确,还是缺少此功能?
更新:默认参数似乎也不可用:
cdef cppclass point:
float x, …Run Code Online (Sandbox Code Playgroud) 所有或几乎所有使用辍学的论文都将其用于监督学习.似乎它可以很容易地用于规范深度自动编码器,RBM和DBN.那么为什么辍学不用于无监督学习呢?
machine-learning neural-network unsupervised-learning supervised-learning
据我所知,通过健全的统一,SLD 解析不应该创建循环数据结构(这是正确的吗?)
如果是这样,理论上可以以不需要垃圾收集 (GC) 的方式实现 Prolog。但话又说回来,一个人可能不会。
对于基于 WAM 的 Prolog 实现来说,这是真的吗?
SWI-Prolog 是这样吗?(我相信它不是基于 WAM 的)当发生检查全局启用时,在 SWI-Prolog 中禁用 GC 是否安全?
具体来说:
:- set_prolog_flag(occurs_check, true).
:- set_prolog_flag(gc, false). /* is this safe? */
Run Code Online (Sandbox Code Playgroud) prolog logic-programming swi-prolog warren-abstract-machine occurs-check
在多CPU机器中,不同的CPU是否竞争相同的内存带宽,还是独立访问DRAM?
换句话说,如果一个程序的内存带宽有限,例如1-CPU 8核系统,那么转向4-CPU 4*8核机器就有机会加速它(假设CPU和DRAM)是可比的)?
const声明是否有助于编译器(GCC)生成更快的代码,或者它们仅对可读性和正确性有用吗?
Zed Shaw认为const在C/C++中无用或过度使用:
接下来是const的所有奇怪的魅力.由于一些奇怪的原因,C++喜欢让你在声明的每个部分都使用const,但是我得到与C相同的最终结果:调用一个函数.(......)
(来自:http://librelist.com/browser//mongrel2/2010/7/15/c-verses-c++/#770d94bcfc6ddf1d8510199996b607dd)
既然Chez Scheme是开源的,我想知道它在性能方面与Racket和其他方案或语言的比较,以便人们可以在一个项目中做出明智的选择.
不幸的是,我找不到任何相关的基准.
我找到了以下内容:
https://ecraven.github.io/r7rs-benchmarks/benchmark.html
问题:没有Racket或其他语言(更新10/13/18:Chez现在包含在一些基准测试中)
http://www.larcenists.org/benchmarksGenuineR6Linux.html
问题:没有Chez Scheme或其他语言
https://benchmarksgame-team.pages.debian.net/benchmarksgame/
问题:只有Racket,可疑的比较(例如,Python不允许使用Numpy显然有帮助,而Racket正在向GMP发出FFI调用)
因此,我找到的基准测试中没有一个允许您将Racket与Chez进行比较,或者将Chez与SBCL或Java进行比较.是否有Chez基准测试可以让您了解它的速度有多快?
Chez Scheme通常被认为是最快的Scheme/Lisp.我们应该知道它是否比典型的业务逻辑应用程序的Java更快.
np.repeat(np.repeat([[1, 2, 3]], 3, axis=0), 3, axis=1)
Run Code Online (Sandbox Code Playgroud)
按预期工作并产生
array([[1, 1, 1, 2, 2, 2, 3, 3, 3],
[1, 1, 1, 2, 2, 2, 3, 3, 3],
[1, 1, 1, 2, 2, 2, 3, 3, 3]])
Run Code Online (Sandbox Code Playgroud)
然而,
np.repeat([[1, 2, 3]], [3, 3])
Run Code Online (Sandbox Code Playgroud)
和
np.repeat([[1, 2, 3]], [3, 3], axis=0)
Run Code Online (Sandbox Code Playgroud)
产生错误。
是否可以repeat同时处理多个维度的数组?
如果dot_product声明为
float dot_product(const float* restrict a, const float* restrict b, unsigned n);
Run Code Online (Sandbox Code Playgroud)
会打电话给
dot_product(x, x, x_len)
Run Code Online (Sandbox Code Playgroud)
根据C99标准,"未定义"?
编辑
x是一个指针,当然,指向sizeof(float) * x_len内存的字节,x_len是unsigned.这个问题是关于别名的.
为Session.run(fetches, feed_dict)保证执行其fetches有序参数呢?
文档似乎没有提到它.
例如,如果你跑
sess.run([accuracy, train_op], feed_dict=feed_dict)
Run Code Online (Sandbox Code Playgroud)
执行的顺序很重要:train_op将更新影响的参数accuracy.
注意:这个问题是关于CPU指令的,而不是高级语言(你受编译器的支配)
来自一个流行的答案:
相同的浮点运算,在相同的硬件上运行,总是产生相同的结果。
我们能否在 x86-64 上做出更有力的保证?如果硬件有点不同怎么办?CPU 指令可以在同一系列 CPU 中重现吗?再现性的边界在哪里?
python ×3
c ×2
assembly ×1
c++ ×1
c99 ×1
chez-scheme ×1
cython ×1
g++ ×1
gcc ×1
hardware ×1
hpc ×1
ieee-754 ×1
lisp ×1
numpy ×1
occurs-check ×1
performance ×1
pointers ×1
prolog ×1
racket ×1
scheme ×1
swi-prolog ×1
tensorflow ×1
x86 ×1
x86-64 ×1