[英]What is the borrow parameter in Theano
I see this following line of code: 我看到以下代码行:
n_train_batches = train_set_x.get_value(borrow=True).shape[0] / batch_size
In the above line, what is the borrow parameter exactly? 在上面这行中,借用参数究竟是什么? What is the advantage of adding that there? 添加那个有什么好处? FYI, train_set_x is basically a matrix that was generated using the theano.shared method. 仅供参考,train_set_x基本上是使用theano.shared方法生成的矩阵。
This part of the documentation seems relevant: 这部分文档似乎相关:
By default (
s_default
) and when explicitly settingborrow=False
, the shared variable we construct gets a deep copy of np_array. 默认情况下(s_default
),当显式设置s_default
borrow=False
,我们构造的共享变量获取np_array的深层副本。 So changes we subsequently make tonp_array
have no effect on our shared variable. 因此,我们随后对np_array
更改对我们的共享变量没有影响。
Setting it to True
can then be assumed to make a shallow copy, effectively letting you "borrow" access to the memory. 然后可以假设将其设置为True
可以生成浅层副本,从而有效地让您“借用”对内存的访问权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.