Lakshmi Nikitha
Lakshmi Nikitha

Reputation: 19

TypeError: 'type' object is not subscriptable

data_path = "/home/nikitha/Desktop/SOftmax/cifar-10-batches-bin/data_batch_1"

fo = open(data_path,'rb')
fo.seek(0)
fo.seek(0)
dict = (pickle.load(fo,encoding='bytes'))
l=np.array(dict[b'labels'])
d=np.array(dict[b'data'])
l=np.array(dict[b'labels'])

TypeError: 'type' object is not subscriptable

This is the above error I get when I run the code

Upvotes: 1

Views: 15988

Answers (2)

makassi
makassi

Reputation: 102

In Python, dict is an object of type 'type'. You can't use it as a variable.

Upvotes: 1

dv3
dv3

Reputation: 4579

Please refer to this answer here

You're trying to assign 'type' to something, but 'type' already exists in python.

Upvotes: -1

Related Questions