London guy
London guy

Reputation: 28032

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.

Upvotes: 4

Views: 1079

Answers (1)

unwind
unwind

Reputation: 400109

This part of the documentation seems relevant:

By default (s_default) and when explicitly setting borrow=False, the shared variable we construct gets a deep copy of np_array. So changes we subsequently make to np_array have no effect on our shared variable.

Setting it to True can then be assumed to make a shallow copy, effectively letting you "borrow" access to the memory.

Upvotes: 6

Related Questions