Skip to content

Commit de0598b

Browse files
committed
Replace setsubtensor by set_subtensor.
1 parent 69349d1 commit de0598b

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

code/rbm.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,16 +243,9 @@ def get_pseudo_likelihood_cost(self, updates):
243243
fe_xi = self.free_energy(xi)
244244

245245
# flip bit x_i of matrix xi and preserve all other bits x_{\i}
246-
# Equivalent to xi[:,bit_i_idx] = 1-xi[:, bit_i_idx]
247-
# NB: slice(start,stop,step) is the python object used for
248-
# slicing, e.g. to index matrix x as follows: x[start:stop:step]
249-
# In our case, idx_list is a tuple. The first element of the tuple
250-
# describes what slice we want from the first dimension.
251-
# ``slice(None,None,None)`` means that we want all values, equivalent
252-
# to numpy notation ``:``. The second element of the tuple is the
253-
# value bit_i_idx, meaning that we are looking for [:,bit_i_idx].
254-
xi_flip = T.setsubtensor(xi, 1-xi[:, bit_i_idx],
255-
idx_list=(slice(None,None,None),bit_i_idx))
246+
# Equivalent to xi[:,bit_i_idx] = 1-xi[:, bit_i_idx], but assigns
247+
# the result to xi_flip, instead of working in place on xi.
248+
xi_flip = T.set_subtensor(xi[:,bit_i_idx], 1-xi[:,bit_i_idx])
256249

257250
# calculate free energy with bit flipped
258251
fe_xi_flip = self.free_energy(xi_flip)

doc/rbm.txt

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -696,16 +696,9 @@ compute the pseudo-likelihood:
696696
fe_xi = self.free_energy(xi)
697697

698698
# flip bit x_i of matrix xi and preserve all other bits x_{\i}
699-
# Equivalent to xi[:,bit_i_idx] = 1-xi[:, bit_i_idx]
700-
# NB: slice(start,stop,step) is the python object used for
701-
# slicing, e.g. to index matrix x as follows: x[start:stop:step]
702-
# In our case, idx_list is a tuple. The first element of the tuple
703-
# describes what slice we want from the first dimension.
704-
# ``slice(None,None,None)`` means that we want all values, equivalent
705-
# to numpy notation ``:``. The second element of the tuple is the
706-
# value bit_i_idx, meaning that we are looking for [:,bit_i_idx].
707-
xi_flip = T.setsubtensor(xi, 1-xi[:, bit_i_idx],
708-
idx_list=(slice(None,None,None),bit_i_idx))
699+
# Equivalent to xi[:,bit_i_idx] = 1-xi[:, bit_i_idx], but assigns
700+
# the result to xi_flip, instead of working in place on xi.
701+
xi_flip = T.set_subtensor(xi[:,bit_i_idx], 1-xi[:,bit_i_idx])
709702

710703
# calculate free energy with bit flipped
711704
fe_xi_flip = self.free_energy(xi_flip)

0 commit comments

Comments
 (0)