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 — converted the code to use numpy random number generator. · mpage/DeepLearningTutorials@29b167a

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • code
    • lstm.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎code/lstm.py‎

Copy file name to clipboardExpand all lines: code/lstm.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'''
44
from collections import OrderedDict
55
import cPickle as pkl
6-
import random
76
import sys
87
import time
98

@@ -19,7 +18,6 @@
1918

2019
# Set the random number generators' seeds for consistency
2120
SEED = 123
22-
random.seed(SEED)
2321
numpy.random.seed(SEED)
2422

2523
def numpy_floatX(data):
@@ -34,7 +32,7 @@ def get_minibatches_idx(n, minibatch_size, shuffle=False):
3432
idx_list = numpy.arange(n, dtype="int32")
3533

3634
if shuffle:
37-
random.shuffle(idx_list)
35+
numpy.random.shuffle(idx_list)
3836

3937
minibatches = []
4038
minibatch_start = 0
@@ -423,7 +421,7 @@ def train_lstm(
423421
# size example. So we must select a random selection of the
424422
# examples.
425423
idx = numpy.arange(len(test[0]))
426-
random.shuffle(idx)
424+
numpy.random.shuffle(idx)
427425
idx = idx[:test_size]
428426
test = ([test[0][n] for n in idx], [test[1][n] for n in idx])
429427

@@ -472,6 +470,7 @@ def train_lstm(
472470
print "%d train examples" % len(train[0])
473471
print "%d valid examples" % len(valid[0])
474472
print "%d test examples" % len(test[0])
473+
475474
history_errs = []
476475
best_p = None
477476
bad_count = 0
@@ -589,7 +588,6 @@ def train_lstm(
589588
if __name__ == '__main__':
590589
# See function train for all possible parameter and there definition.
591590
train_lstm(
592-
#reload_model="lstm_model.npz",
593591
max_epochs=100,
594592
test_size=500,
595593
)

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.