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 — Keep random subset of the test set · willfu/DeepLearningTutorials@6e38783

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
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,13 @@ def train_lstm(
415415
train, valid, test = load_data(n_words=n_words, valid_portion=0.05,
416416
maxlen=maxlen)
417417
if test_size > 0:
418-
test = (test[0][:test_size], test[1][:test_size])
418+
# The test set is sorted by size, but we want to keep random
419+
# size example. So we must select a random selection of the
420+
# examples.
421+
idx = numpy.arange(len(test[0]))
422+
random.shuffle(idx)
423+
idx = idx[:test_size]
424+
test = ([test[0][n] for n in idx], [test[1][n] for n in idx])
419425

420426
ydim = numpy.max(train[1]) + 1
421427

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.