GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — manual pep8 in doc · imclab/DeepLearningTutorials@d451573

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • doc
    • deep.txt
    • gettingstarted.txt
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎doc/deep.txt‎

Copy file name to clipboardExpand all lines: doc/deep.txt
+7-7Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ share.
6666
.. code-block:: python
6767

6868
def deep_main(learning_rate=0.1,
69-
pretraining_epochs = 20,
70-
pretrain_lr = 0.1,
71-
training_epochs = 1000,
72-
batch_size = 20,
69+
pretraining_epochs=20,
70+
pretrain_lr=0.1,
71+
training_epochs=1000,
72+
batch_size=20,
7373
mnist_file='mnist.pkl.gz'):
7474

7575
n_train_examples, train_valid_test = load_mnist(mnist_file)
@@ -113,9 +113,9 @@ share.
113113

114114
train_fn, valid_scores, test_scores =\
115115
deep_model.finetune_functions(
116-
train_valid_test[0][0], # training dataset
117-
learning_rate=finetune_lr, # the learning rate
118-
batch_size = batch_size) # number of examples to use at once
116+
train_valid_test[0][0], # training dataset
117+
learning_rate=finetune_lr, # the learning rate
118+
batch_size=batch_size) # number of examples to use at once
119119

120120

121121
# use these functions as part of the generic early-stopping procedure
Collapse file

‎doc/gettingstarted.txt‎

Copy file name to clipboardExpand all lines: doc/gettingstarted.txt
+19-19Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ MNIST Dataset
7575
import cPickle, gzip, numpy
7676

7777
# Load the dataset
78-
f = gzip.open('mnist.pkl.gz','rb')
78+
f = gzip.open('mnist.pkl.gz', 'rb')
7979
train_set, valid_set, test_set = cPickle.load(f)
8080
f.close()
8181

@@ -141,8 +141,8 @@ MNIST Dataset
141141

142142
# accessing the third minibatch of the training set
143143

144-
data = train_set_x[2*500:3*500]
145-
label = train_set_y[2*500:3*500]
144+
data = train_set_x[2 * 500: 3 * 500]
145+
label = train_set_y[2 * 500: 3 * 500]
146146

147147

148148
The data has to be stored as floats on the GPU ( the right
@@ -294,7 +294,7 @@ In python, using Theano this can be written as :
294294
# expression of the zero one loss ; to get the actual value this
295295
# symbolic expression has to be compiled into a Theano function (see
296296
# the Theano tutorial for more details)
297-
zero_one_loss = T.sum(T.neq(T.argmax(p_y_given_x),y))
297+
zero_one_loss = T.sum(T.neq(T.argmax(p_y_given_x), y))
298298

299299

300300
.. index:: Negative Log--Likelihood Loss
@@ -338,7 +338,7 @@ This can be computed using the following line of code :
338338
# NLL is a symbolic variable ; to get the actual value of NLL, this symbolic
339339
# expression has to be compiled into a Theano function (see the Theano
340340
# tutorial for more details)
341-
NLL = -T.sum(T.log(p_y_given_x)[T.arange(y.shape[0]),y])
341+
NLL = -T.sum(T.log(p_y_given_x)[T.arange(y.shape[0]), y])
342342
# note on syntax: T.arange(y.shape[0]) is a vector of integers [0,1,2,...,len(y)].
343343
# Indexing a matrix M by the two vectors [0,1,...,K], [a,b,...,k] returns the
344344
# elements M[0,a], M[1,b], ..., M[K,k] as a vector. Here, we use this
@@ -438,8 +438,8 @@ algorithm in Theano can be done as follows :
438438
d_loss_wrt_params = T.grad(loss, params)
439439

440440
# compile the MSGD step into a theano function
441-
updates = { params: params - learning_rate * d_loss_wrt_params}
442-
MSGD = theano.function([x_batch,y_batch], loss, updates = updates)
441+
updates = {params: params - learning_rate * d_loss_wrt_params}
442+
MSGD = theano.function([x_batch,y_batch], loss, updates=updates)
443443

444444
for (x_batch, y_batch) in train_batches:
445445
# here x_batch and y_batch are elements of train_batches and
@@ -525,7 +525,7 @@ L2 regularization term weighted by :math:`\lambda_2`
525525
L1 = T.sum(abs(param))
526526

527527
# symbolic Theano variable that represents the squared L2 term
528-
L2_sqr = T.sum(param**2)
528+
L2_sqr = T.sum(param ** 2)
529529

530530
# the loss
531531
loss = NLL + lambda_1 * L1 + lambda_2 * L2
@@ -557,20 +557,20 @@ of a strategy based on a geometrically increasing amount of patience.
557557
.. code-block:: python
558558

559559
# early-stopping parameters
560-
patience = 5000 # look as this many examples regardless
561-
patience_increase = 2 # wait this much longer when a new best is
560+
patience = 5000 # look as this many examples regardless
561+
patience_increase = 2 # wait this much longer when a new best is
562562
# found
563-
improvement_threshold = 0.995 # a relative improvement of this much is
564-
# considered significant
565-
validation_frequency = min(n_train_batches, patience/2)
563+
improvement_threshold = 0.995 # a relative improvement of this much is
564+
# considered significant
565+
validation_frequency = min(n_train_batches, patience/2)
566566
# go through this many
567567
# minibatches before checking the network
568568
# on the validation set; in this case we
569569
# check every epoch
570570

571-
best_params = None
571+
best_params = None
572572
best_validation_loss = numpy.inf
573-
test_score = 0.
573+
test_score = 0.
574574
start_time = time.clock()
575575

576576
done_looping = False
@@ -593,7 +593,7 @@ of a strategy based on a geometrically increasing amount of patience.
593593
if this_validation_loss < best_validation_loss:
594594

595595
# improve patience if loss improvement is good enough
596-
if this_validation_loss < best_validation_loss*improvement_threshold:
596+
if this_validation_loss < best_validation_loss * improvement_threshold:
597597

598598
patience = max(patience, iter * patience_increase)
599599
best_params = copy.deepcopy(params)
@@ -682,9 +682,9 @@ like:
682682

683683
>>> import cPickle
684684
>>> save_file = open('path', 'wb') # this will overwrite current contents
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
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:

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.