Skip to content

Commit e03abea

Browse files
committed
Remove remaining uses of .value
1 parent 66e9bff commit e03abea

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

code/dA.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ def test_dA( learning_rate = 0.1, training_epochs = 15, dataset ='../data/mnist.
239239
train_set_x, train_set_y = datasets[0]
240240

241241
# compute number of minibatches for training, validation and testing
242-
n_train_batches = train_set_x.value.shape[0] / batch_size
242+
n_train_batches = train_set_x.get_value(borrow=True).shape[0] / batch_size
243243

244244
# allocate symbolic variables for the data
245245
index = T.lscalar() # index to a [mini]batch
@@ -286,7 +286,7 @@ def test_dA( learning_rate = 0.1, training_epochs = 15, dataset ='../data/mnist.
286286
training_time = (end_time - start_time)
287287

288288
print >> sys.stderr, ('The no corruption code for file '+os.path.split(__file__)[1]+' ran for %.2fm' % ((training_time)/60.))
289-
image = PIL.Image.fromarray(tile_raster_images( X = da.W.value.T,
289+
image = PIL.Image.fromarray(tile_raster_images(X = da.W.get_value(borrow=True).T,
290290
img_shape = (28,28),tile_shape = (10,10),
291291
tile_spacing=(1,1)))
292292
image.save('filters_corruption_0.png')
@@ -329,7 +329,7 @@ def test_dA( learning_rate = 0.1, training_epochs = 15, dataset ='../data/mnist.
329329

330330
print >> sys.stderr, ('The 30% corruption code for file '+os.path.split(__file__)[1]+' ran for %.2fm' % (training_time/60.))
331331

332-
image = PIL.Image.fromarray(tile_raster_images( X = da.W.value.T,
332+
image = PIL.Image.fromarray(tile_raster_images(X = da.W.get_value(borrow=True).T,
333333
img_shape = (28,28),tile_shape = (10,10),
334334
tile_spacing=(1,1)))
335335
image.save('filters_corruption_30.png')

doc/dA.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ save the filters as an image :
588588

589589
.. code-block:: python
590590

591-
image = PIL.Image.fromarray(tile_raster_images( X = da.W.value.T,
591+
image = PIL.Image.fromarray(tile_raster_images(X = da.W.get_value(borrow=True).T,
592592
img_shape = (28,28),tile_shape = (10,10),
593593
tile_spacing=(1,1)))
594594
image.save('filters_corruption_30.png')

doc/gettingstarted.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -682,19 +682,19 @@ like:
682682

683683
>>> import cPickle
684684
>>> save_file = open('path', 'wb') # this will overwrite current contents
685-
>>> cPickle.dump(w.value, save_file, -1) # the -1 is for HIGHEST_PROTOCOL
686-
>>> cPickle.dump(v.value, save_file, -1) # .. and it triggers much more efficient
687-
>>> cPickle.dump(u.value, save_file, -1) # .. storage than numpy's default
685+
>>> cPickle.dump(w.get_value(borrow=True), save_file, -1) # the -1 is for HIGHEST_PROTOCOL
686+
>>> cPickle.dump(v.get_value(borrow=True), save_file, -1) # .. and it triggers much more efficient
687+
>>> cPickle.dump(u.get_value(borrow=True), save_file, -1) # .. storage than numpy's default
688688
>>> save_file.close()
689689

690690
Then later, you can load your data back like this:
691691

692692
.. code-block:: python
693693

694694
>>> save_file = open('path')
695-
>>> w.value = cPickle.load(save_file)
696-
>>> v.value = cPickle.load(save_file)
697-
>>> u.value = cPickle.load(save_file)
695+
>>> w.set_value(cPickle.load(save_file), borrow=True)
696+
>>> v.set_value(cPickle.load(save_file), borrow=True)
697+
>>> u.set_value(cPickle.load(save_file), borrow=True)
698698

699699
This technique is a bit verbose, but it is tried and true. You will be able
700700
to load your data and render it in matplotlib without trouble, years after

0 commit comments

Comments
 (0)