Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- urls=[]
- labels =[]
- with open('Digits_file.json') as file1:
- lis = []
- for i in json_lines.reader(file1):
- lis.append(i)
- for i in lis:
- urls.append(i['content'])
- labels.append([i['annotation']['labels'][0]])
- urls = np.array(urls)
- labels = np.array(labels)
- x_train, x_test, y_train, y_test = train_test_split(urls, labels, test_size=0.2)
- model = tf.keras.models.Sequential()
- model.add(tf.keras.layers.Flatten(input_shape=[98,98]))
- model.add(tf.keras.layers.Dense(128, activation="relu"))
- model.add(tf.keras.layers.Dense(10, activation="softmax"))
- model.compile(
- loss="sparse_categorical_crossentropy",
- optimizer="adam",
- metrics=["accuracy"]
- )
- model.fit(x_train, y_train, epochs=5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement