GeezerVison is showing github.com — Replace setsubtensor by set_subtensor. · alabarga/DeepLearningTutorials@de0598b
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: code/rbm.py +3-10Lines changed: 3 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -243,16 +243,9 @@ def get_pseudo_likelihood_cost(self, updates): | 243 | 243 | fe_xi = self.free_energy(xi) | 244 | 244 |
| 245 | 245 | # 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]) | 256 | 249 |
| 257 | 250 | # calculate free energy with bit flipped | 258 | 251 | fe_xi_flip = self.free_energy(xi_flip) | |
Collapse file Copy file name to clipboardExpand all lines: doc/rbm.txt +3-10Lines changed: 3 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -696,16 +696,9 @@ compute the pseudo-likelihood: | 696 | 696 | fe_xi = self.free_energy(xi) | 697 | 697 |
| 698 | 698 | # 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]) | 709 | 702 |
| 710 | 703 | # calculate free energy with bit flipped | 711 | 704 | fe_xi_flip = self.free_energy(xi_flip) | |
|