Python Forum
How to change input data set for character recognition program?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change input data set for character recognition program?
#1
I am new to Python and machine learning. Trying to learn by working on tested examples. Tried the character recognition program (from Chollet) using MNIST data set, later tried to change the input data set (numbers instead of character images).

I cannot run it with this error:
Error:
train_images=((1,1,0,0,1) TypeError: 'tuple' object is not callable
How can I correct this? Maybe it is more complicated than this in changing the input data set. Thanks.

# from keras.datasets import mnist
# (train_images, train_labels), (test_images, test_labels) = mnist.load_data()

train_images=((1,1,0,0,1)
              (0,0,1,1,1)
              (1,1,0,1,1))
train_labels=[[10,10,0,0,10]
              [0,0,10,10,10]
              [10,10,0,10,10]]
test_images=[[0,1,0,1,1]
              [0,0,1,0,1]
              [1,1,1,1,1]]
test_labels=[[0,10,0,10,10]
              [0,0,10,0,10]
              [10,10,10,10,10]]

from keras import models
from keras import layers

network = models.Sequential()
network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))
network.add(layers.Dense(10, activation='softmax'))

network.compile(optimizer='rmsprop',
                loss='categorical_crossentropy',
                metrics=['accuracy'])

train_images = train_images.reshape((60000, 28 * 28))
train_images = train_images.astype('float32') / 255
test_images = test_images.reshape((10000, 28 * 28))
test_images = test_images.astype('float32') / 255

#from keras.utils import to_categorical
from tensorflow.keras.utils import to_categorical

train_labels = to_categorical(train_labels)
test_labels = to_categorical(test_labels)
network.fit(train_images, train_labels, epochs=5, batch_size=128)
Reply


Messages In This Thread
How to change input data set for character recognition program? - by plumberpy - Apr-12-2022, 03:03 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how do change data in a database CompleteNewb 5 2,395 Mar-20-2022, 11:31 PM
Last Post: Larz60+
  MergeSort data input Silvioo 0 1,775 Oct-11-2018, 06:53 AM
Last Post: Silvioo

Forum Jump:

User Panel Messages

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