Python Forum
NoneType' object is not subscriptable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NoneType' object is not subscriptable
#7
(Sep-12-2019, 07:33 PM)buran Wrote: This is the same code, and the error I got is "NameError Traceback (most recent call last)
cell_name in async-def-wrapper()
NameError: name 'sequences' is not defined"
from keras.datasets import imdb
from keras import optimizers
from keras import losses
from keras import metrics
import numpy as np
(train_data, train_lables), (test_data, test_lables)=imdb.load_data(num_words=10000)
def vectorize_sequences(sequences, dimension=10000):
    results = np.zeros((len(sequences), dimension))
    print(results)
    for i, sequence in enumerate(sequences):
        results[i, sequence] = 1.
    return results
x_train = vectorize_sequences(train_data)
x_test = vectorize_sequences(test_data)
y_train = np.asarray(train_lables).astype('float32')
y_test = np.asarray(test_lables).astype('float32')
model = models.Sequential()
model.add(layers.Dense(16, activation='relu', input_shape=(10000,)))
model.add(layers.Dense(16, activation='relu'))
model.add(layers.Dense(1, activation='sigmoid'))
model.compile(optimizer='rmsprop',
loss='binary_crossentropy',
metrics=['accuracy'])
x_val =x_train[:10000]
partial_x_train = x_train[10000:]

Reply


Messages In This Thread
RE: NoneType' object is not subscriptable - by shane1236 - Sep-12-2019, 07:36 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  AttributeError: 'NoneType' object has no attribute 'all' synthex 2 5,280 Mar-07-2019, 11:11 AM
Last Post: synthex
  TypeError: 'method' object is not subscriptable ayaz786amd 1 39,291 Nov-24-2018, 11:16 AM
Last Post: j.crater

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020