SlideShare a Scribd company logo
1 of 7
Download to read offline
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/re
uters.npz

2113536/2110848 [==============================] - 3s 2us/step

2121728/2110848 [==============================] - 3s 2us/step

C:Userswaleeanaconda3libsite-packageskerasdatasetsreuters.py:143: VisibleDep
recationWarning: Creating an ndarray from ragged nested sequences (which is a list-o
r-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecat
ed. If you meant to do this, you must specify 'dtype=object' when creating the ndarr
ay

x_train, y_train = np.array(xs[:idx]), np.array(labels[:idx])

C:Userswaleeanaconda3libsite-packageskerasdatasetsreuters.py:144: VisibleDep
recationWarning: Creating an ndarray from ragged nested sequences (which is a list-o
r-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecat
ed. If you meant to do this, you must specify 'dtype=object' when creating the ndarr
ay

x_test, y_test = np.array(xs[idx:]), np.array(labels[idx:])

8982
2246
[1,

245,

273,

207,

156,

53,

74,

160,

26,

14,

46,

296,

26,

39,

74,

2979,

3554,

14,

46,

4689,

4329,

86,

61,

3499,

4795,

14,

61,

451,

4329,

17,

12]
In [1]: from keras.datasets import reuters

(train_data, train_labels), (test_data, test_labels) = reuters.load_data(num_words=1
In [2]: len(train_data)

Out[2]:
In [3]: len(test_data)

Out[3]:
In [4]: train_data[10]

Out[4]:
In [5]: word_index = reuters.get_word_index()

reverse_word_index = dict([(value, key) for (key, value) in word_index.items()])

# Offset indices by 3
Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/re
uters_word_index.json

557056/550378 [==============================] - 1s 2us/step

565248/550378 [==============================] - 1s 2us/step

'? ? ? said as a result of its december acquisition of space co it expects earnings
per share in 1987 of 1 15 to 1 30 dlrs per share up from 70 cts in 1986 the company
said pretax net should rise to nine to 10 mln dlrs from six mln dlrs in 1986 and ren
tal operation revenues to 19 to 22 mln dlrs from 12 5 mln dlrs it said cash flow per
share this year should be 2 50 to three dlrs reuter 3'
3
# because 0, 1 and 2 are reserved indices for "padding", "start of sequence", and "u
decoded_newswire = ' '.join([reverse_word_index.get(i - 3, '?') for i in train_data[
In [6]: decoded_newswire

Out[6]:
In [7]: train_labels[10]

Out[7]:
In [8]: import numpy as np

def vectorize_sequences(sequences, dimension=10000):

results = np.zeros((len(sequences), dimension))

for i, sequence in enumerate(sequences):

results[i, sequence] = 1.

return results

# Our vectorized training data

x_train = vectorize_sequences(train_data)

# Our vectorized test data

x_test = vectorize_sequences(test_data)

In [9]: def to_one_hot(labels, dimension=46):

results = np.zeros((len(labels), dimension))

for i, label in enumerate(labels):

results[i, label] = 1.

return results

# Our vectorized training labels

one_hot_train_labels = to_one_hot(train_labels)

# Our vectorized test labels

one_hot_test_labels = to_one_hot(test_labels)

In [10]: from keras.utils.np_utils import to_categorical

one_hot_train_labels = to_categorical(train_labels)

one_hot_test_labels = to_categorical(test_labels)

In [11]: from keras import models

from keras import layers

model = models.Sequential()

model.add(layers.Dense(64, activation='relu', input_shape=(10000,)))

model.add(layers.Dense(64, activation='relu'))

model.add(layers.Dense(46, activation='softmax'))

In [12]: model.compile(optimizer='rmsprop',

loss='categorical_crossentropy',

metrics=['accuracy'])

In [13]: x_val = x_train[:1000]

partial_x_train = x_train[1000:]

y_val = one_hot_train_labels[:1000]

partial_y_train = one_hot_train_labels[1000:]

In [14]: history = model.fit(partial_x_train,

partial_y_train,
Epoch 1/20

16/16 [==============================] - 39s 125ms/step - loss: 3.2245 - accuracy:
0.3478 - val_loss: 1.7983 - val_accuracy: 0.6600

Epoch 2/20

16/16 [==============================] - 1s 41ms/step - loss: 1.5213 - accuracy: 0.7
100 - val_loss: 1.3048 - val_accuracy: 0.7230

Epoch 3/20

16/16 [==============================] - 1s 34ms/step - loss: 1.0804 - accuracy: 0.7
787 - val_loss: 1.1374 - val_accuracy: 0.7580

Epoch 4/20

16/16 [==============================] - 1s 35ms/step - loss: 0.8291 - accuracy: 0.8
275 - val_loss: 1.0291 - val_accuracy: 0.7910

Epoch 5/20

16/16 [==============================] - 1s 35ms/step - loss: 0.6616 - accuracy: 0.8
663 - val_loss: 0.9549 - val_accuracy: 0.7970

Epoch 6/20

16/16 [==============================] - 1s 38ms/step - loss: 0.5123 - accuracy: 0.8
973 - val_loss: 0.9079 - val_accuracy: 0.8160

Epoch 7/20

16/16 [==============================] - 1s 38ms/step - loss: 0.4107 - accuracy: 0.9
206 - val_loss: 0.9038 - val_accuracy: 0.8100

Epoch 8/20

16/16 [==============================] - 1s 37ms/step - loss: 0.3268 - accuracy: 0.9
343 - val_loss: 0.8954 - val_accuracy: 0.8040

Epoch 9/20

16/16 [==============================] - 1s 35ms/step - loss: 0.2674 - accuracy: 0.9
441 - val_loss: 0.9077 - val_accuracy: 0.8080

Epoch 10/20

16/16 [==============================] - 1s 39ms/step - loss: 0.2275 - accuracy: 0.9
504 - val_loss: 0.8904 - val_accuracy: 0.8220

Epoch 11/20

16/16 [==============================] - 1s 37ms/step - loss: 0.1932 - accuracy: 0.9
551 - val_loss: 0.8983 - val_accuracy: 0.8190

Epoch 12/20

16/16 [==============================] - 1s 37ms/step - loss: 0.1673 - accuracy: 0.9
572 - val_loss: 0.9229 - val_accuracy: 0.8190

Epoch 13/20

16/16 [==============================] - 1s 35ms/step - loss: 0.1513 - accuracy: 0.9
583 - val_loss: 0.9595 - val_accuracy: 0.8070

Epoch 14/20

16/16 [==============================] - 1s 35ms/step - loss: 0.1424 - accuracy: 0.9
579 - val_loss: 0.9638 - val_accuracy: 0.8150

Epoch 15/20

16/16 [==============================] - 1s 36ms/step - loss: 0.1248 - accuracy: 0.9
623 - val_loss: 0.9832 - val_accuracy: 0.8070

Epoch 16/20

16/16 [==============================] - 1s 36ms/step - loss: 0.1246 - accuracy: 0.9
571 - val_loss: 1.0030 - val_accuracy: 0.8120

Epoch 17/20

16/16 [==============================] - 1s 35ms/step - loss: 0.1177 - accuracy: 0.9
608 - val_loss: 1.0174 - val_accuracy: 0.8040

Epoch 18/20

16/16 [==============================] - 1s 36ms/step - loss: 0.1055 - accuracy: 0.9
625 - val_loss: 1.0484 - val_accuracy: 0.8100

Epoch 19/20

16/16 [==============================] - 1s 34ms/step - loss: 0.1068 - accuracy: 0.9
614 - val_loss: 1.0720 - val_accuracy: 0.8040

Epoch 20/20

16/16 [==============================] - 1s 37ms/step - loss: 0.1055 - accuracy: 0.9
583 - val_loss: 1.0762 - val_accuracy: 0.8000

epochs=20,

batch_size=512,

validation_data=(x_val, y_val))

In [15]: import matplotlib.pyplot as plt

loss = history.history['loss']

val_loss = history.history['val_loss']

epochs = range(1, len(loss) + 1)
plt.plot(epochs, loss, 'bo', label='Training loss')

plt.plot(epochs, val_loss, 'b', label='Validation loss')

plt.title('Training and validation loss')

plt.xlabel('Epochs')

plt.ylabel('Loss')

plt.legend()

plt.show()

In [16]: plt.clf() # clears the figure

acc = history.history['accuracy']
val_acc = history.history['val_accuracy']

plt.plot(epochs, acc, 'bo', label='Training acc')

plt.plot(epochs, val_acc, 'b', label='Validation acc')

plt.title('Training and validation accuracy')

plt.xlabel('Epochs')

plt.ylabel('Loss')

plt.legend()

plt.show()

In [17]: model = models.Sequential()

model.add(layers.Dense(64, activation='relu', input_shape=(10000,)))

model.add(layers.Dense(64, activation='relu'))

model.add(layers.Dense(46, activation='softmax'))

model.compile(optimizer='rmsprop',

loss='categorical_crossentropy',

metrics=['accuracy'])

model.fit(partial_x_train,

partial_y_train,
Epoch 1/8

16/16 [==============================] - 3s 67ms/step - loss: 3.0656 - accuracy: 0.4
297 - val_loss: 1.6959 - val_accuracy: 0.6300

Epoch 2/8

16/16 [==============================] - 1s 32ms/step - loss: 1.5030 - accuracy: 0.6
813 - val_loss: 1.2944 - val_accuracy: 0.7150

Epoch 3/8

16/16 [==============================] - 1s 36ms/step - loss: 1.0861 - accuracy: 0.7
640 - val_loss: 1.1250 - val_accuracy: 0.7540

Epoch 4/8

16/16 [==============================] - 1s 39ms/step - loss: 0.8546 - accuracy: 0.8
190 - val_loss: 1.0358 - val_accuracy: 0.7760

Epoch 5/8

16/16 [==============================] - 1s 39ms/step - loss: 0.6699 - accuracy: 0.8
599 - val_loss: 0.9529 - val_accuracy: 0.7990

Epoch 6/8

16/16 [==============================] - 1s 37ms/step - loss: 0.5317 - accuracy: 0.8
909 - val_loss: 0.9138 - val_accuracy: 0.8120

Epoch 7/8

16/16 [==============================] - 1s 38ms/step - loss: 0.4173 - accuracy: 0.9
173 - val_loss: 0.9121 - val_accuracy: 0.8040

Epoch 8/8

16/16 [==============================] - 1s 38ms/step - loss: 0.3313 - accuracy: 0.9
337 - val_loss: 0.8866 - val_accuracy: 0.8190

71/71 [==============================] - 0s 3ms/step - loss: 0.9642 - accuracy: 0.78
63

[0.964229941368103, 0.7862867116928101]
0.18699910952804988
(46,)
1.0000001
3
epochs=8,

batch_size=512,

validation_data=(x_val, y_val))

results = model.evaluate(x_test, one_hot_test_labels)

In [18]: results

Out[18]:
In [19]: import copy

test_labels_copy = copy.copy(test_labels)

np.random.shuffle(test_labels_copy)

float(np.sum(np.array(test_labels) == np.array(test_labels_copy))) / len(test_labels
Out[19]:
In [20]: predictions = model.predict(x_test)

In [21]: predictions[0].shape

Out[21]:
In [22]: np.sum(predictions[0])

Out[22]:
In [23]: np.argmax(predictions[0])

Out[23]:
In [24]: y_train = np.array(train_labels)

y_test = np.array(test_labels)

In [25]: model.compile(optimizer='rmsprop', loss='sparse_categorical_crossentropy', metrics=[
In [26]: model = models.Sequential()
Epoch 1/20

63/63 [==============================] - 4s 32ms/step - loss: 3.4182 - accuracy: 0.1
167 - val_loss: 2.5418 - val_accuracy: 0.4070

Epoch 2/20

63/63 [==============================] - 1s 16ms/step - loss: 2.3245 - accuracy: 0.4
161 - val_loss: 2.0374 - val_accuracy: 0.4260

Epoch 3/20

63/63 [==============================] - 1s 16ms/step - loss: 1.8282 - accuracy: 0.4
539 - val_loss: 1.7261 - val_accuracy: 0.4410

Epoch 4/20

63/63 [==============================] - 1s 16ms/step - loss: 1.4547 - accuracy: 0.5
176 - val_loss: 1.4957 - val_accuracy: 0.6370

Epoch 5/20

63/63 [==============================] - 1s 17ms/step - loss: 1.2671 - accuracy: 0.6
758 - val_loss: 1.4441 - val_accuracy: 0.6600

Epoch 6/20

63/63 [==============================] - 1s 15ms/step - loss: 1.1477 - accuracy: 0.7
117 - val_loss: 1.4194 - val_accuracy: 0.6750

Epoch 7/20

63/63 [==============================] - 1s 21ms/step - loss: 1.0301 - accuracy: 0.7
430 - val_loss: 1.4107 - val_accuracy: 0.6880

Epoch 8/20

63/63 [==============================] - 1s 18ms/step - loss: 0.9645 - accuracy: 0.7
553 - val_loss: 1.4553 - val_accuracy: 0.6880

Epoch 9/20

63/63 [==============================] - 1s 17ms/step - loss: 0.9077 - accuracy: 0.7
690 - val_loss: 1.4827 - val_accuracy: 0.6780

Epoch 10/20

63/63 [==============================] - 1s 19ms/step - loss: 0.8553 - accuracy: 0.7
733 - val_loss: 1.4980 - val_accuracy: 0.6870

Epoch 11/20

63/63 [==============================] - 1s 19ms/step - loss: 0.8322 - accuracy: 0.7
800 - val_loss: 1.5350 - val_accuracy: 0.6820

Epoch 12/20

63/63 [==============================] - 1s 21ms/step - loss: 0.7728 - accuracy: 0.7
883 - val_loss: 1.5694 - val_accuracy: 0.6790

Epoch 13/20

63/63 [==============================] - 1s 17ms/step - loss: 0.7678 - accuracy: 0.7
847 - val_loss: 1.6703 - val_accuracy: 0.6820

Epoch 14/20

63/63 [==============================] - 1s 20ms/step - loss: 0.7472 - accuracy: 0.7
846 - val_loss: 1.7068 - val_accuracy: 0.6820

Epoch 15/20

63/63 [==============================] - 1s 22ms/step - loss: 0.7523 - accuracy: 0.7
822 - val_loss: 1.7743 - val_accuracy: 0.6810

Epoch 16/20

63/63 [==============================] - 1s 19ms/step - loss: 0.7087 - accuracy: 0.7
904 - val_loss: 1.8168 - val_accuracy: 0.6750

Epoch 17/20

63/63 [==============================] - 1s 14ms/step - loss: 0.7009 - accuracy: 0.7
919 - val_loss: 1.8658 - val_accuracy: 0.6870

Epoch 18/20

63/63 [==============================] - 1s 19ms/step - loss: 0.6559 - accuracy: 0.8
070 - val_loss: 1.9383 - val_accuracy: 0.6790

Epoch 19/20

63/63 [==============================] - 1s 15ms/step - loss: 0.6627 - accuracy: 0.8
041 - val_loss: 2.0031 - val_accuracy: 0.6810

model.add(layers.Dense(64, activation='relu', input_shape=(10000,)))

model.add(layers.Dense(4, activation='relu'))

model.add(layers.Dense(46, activation='softmax'))

model.compile(optimizer='rmsprop',

loss='categorical_crossentropy',

metrics=['accuracy'])

model.fit(partial_x_train,

partial_y_train,
epochs=20,

batch_size=128,

validation_data=(x_val, y_val))
Epoch 20/20

63/63 [==============================] - 1s 14ms/step - loss: 0.6398 - accuracy: 0.8
039 - val_loss: 1.9840 - val_accuracy: 0.6790

<keras.callbacks.History at 0x1328abf6910>
Out[26]:
In [ ]:

More Related Content

Similar to Assignment 5.2.pdf

Time Series Analysis and Mining with R
Time Series Analysis and Mining with RTime Series Analysis and Mining with R
Time Series Analysis and Mining with RYanchang Zhao
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxTseChris
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxlauracallander
 
Classification examp
Classification exampClassification examp
Classification exampRyan Hong
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RRsquared Academy
 
Math for anomaly detection
Math for anomaly detectionMath for anomaly detection
Math for anomaly detectionMenglinLiu1
 
school-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdfschool-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdfashishkum805
 
Do snow.rwn
Do snow.rwnDo snow.rwn
Do snow.rwnARUN DN
 
support vector regression
support vector regressionsupport vector regression
support vector regressionAkhilesh Joshi
 
you need to complete the r code and a singlepage document c.pdf
you need to complete the r code and a singlepage document c.pdfyou need to complete the r code and a singlepage document c.pdf
you need to complete the r code and a singlepage document c.pdfadnankhan605720
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions Dr. Volkan OBAN
 
logistic regression with python and R
logistic regression with python and Rlogistic regression with python and R
logistic regression with python and RAkhilesh Joshi
 
Using the following code Install Packages pip install .pdf
Using the following code Install Packages   pip install .pdfUsing the following code Install Packages   pip install .pdf
Using the following code Install Packages pip install .pdfpicscamshoppe
 
Forecast stock prices python
Forecast stock prices pythonForecast stock prices python
Forecast stock prices pythonUtkarsh Asthana
 
Machine Learning Model for M.S admissions
Machine Learning Model for M.S admissionsMachine Learning Model for M.S admissions
Machine Learning Model for M.S admissionsOmkar Rane
 

Similar to Assignment 5.2.pdf (20)

Time Series Analysis and Mining with R
Time Series Analysis and Mining with RTime Series Analysis and Mining with R
Time Series Analysis and Mining with R
 
alexnet.pdf
alexnet.pdfalexnet.pdf
alexnet.pdf
 
Python 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptxPython 03-parameters-graphics.pptx
Python 03-parameters-graphics.pptx
 
Need help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docxNeed help filling out the missing sections of this code- the sections.docx
Need help filling out the missing sections of this code- the sections.docx
 
Xgboost
XgboostXgboost
Xgboost
 
Classification examp
Classification exampClassification examp
Classification examp
 
R Programming: Mathematical Functions In R
R Programming: Mathematical Functions In RR Programming: Mathematical Functions In R
R Programming: Mathematical Functions In R
 
Math for anomaly detection
Math for anomaly detectionMath for anomaly detection
Math for anomaly detection
 
knn classification
knn classificationknn classification
knn classification
 
school-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdfschool-management-by-shivkamal-singh.pdf
school-management-by-shivkamal-singh.pdf
 
Do snow.rwn
Do snow.rwnDo snow.rwn
Do snow.rwn
 
support vector regression
support vector regressionsupport vector regression
support vector regression
 
you need to complete the r code and a singlepage document c.pdf
you need to complete the r code and a singlepage document c.pdfyou need to complete the r code and a singlepage document c.pdf
you need to complete the r code and a singlepage document c.pdf
 
ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions ggtimeseries-->ggplot2 extensions
ggtimeseries-->ggplot2 extensions
 
logistic regression with python and R
logistic regression with python and Rlogistic regression with python and R
logistic regression with python and R
 
Using the following code Install Packages pip install .pdf
Using the following code Install Packages   pip install .pdfUsing the following code Install Packages   pip install .pdf
Using the following code Install Packages pip install .pdf
 
Forecast stock prices python
Forecast stock prices pythonForecast stock prices python
Forecast stock prices python
 
wk5ppt2_Iris
wk5ppt2_Iriswk5ppt2_Iris
wk5ppt2_Iris
 
R programming
R programmingR programming
R programming
 
Machine Learning Model for M.S admissions
Machine Learning Model for M.S admissionsMachine Learning Model for M.S admissions
Machine Learning Model for M.S admissions
 

More from dash41

Assignment7.pdf
Assignment7.pdfAssignment7.pdf
Assignment7.pdfdash41
 
Assignment 6.3.pdf
Assignment 6.3.pdfAssignment 6.3.pdf
Assignment 6.3.pdfdash41
 
Assignment 6.1.pdf
Assignment 6.1.pdfAssignment 6.1.pdf
Assignment 6.1.pdfdash41
 
Assignment 5.3.pdf
Assignment 5.3.pdfAssignment 5.3.pdf
Assignment 5.3.pdfdash41
 
Assignment 4.pdf
Assignment 4.pdfAssignment 4.pdf
Assignment 4.pdfdash41
 
Assignment 3.pdf
Assignment 3.pdfAssignment 3.pdf
Assignment 3.pdfdash41
 
rdbms.pdf
rdbms.pdfrdbms.pdf
rdbms.pdfdash41
 
documentsdb.pdf
documentsdb.pdfdocumentsdb.pdf
documentsdb.pdfdash41
 

More from dash41 (8)

Assignment7.pdf
Assignment7.pdfAssignment7.pdf
Assignment7.pdf
 
Assignment 6.3.pdf
Assignment 6.3.pdfAssignment 6.3.pdf
Assignment 6.3.pdf
 
Assignment 6.1.pdf
Assignment 6.1.pdfAssignment 6.1.pdf
Assignment 6.1.pdf
 
Assignment 5.3.pdf
Assignment 5.3.pdfAssignment 5.3.pdf
Assignment 5.3.pdf
 
Assignment 4.pdf
Assignment 4.pdfAssignment 4.pdf
Assignment 4.pdf
 
Assignment 3.pdf
Assignment 3.pdfAssignment 3.pdf
Assignment 3.pdf
 
rdbms.pdf
rdbms.pdfrdbms.pdf
rdbms.pdf
 
documentsdb.pdf
documentsdb.pdfdocumentsdb.pdf
documentsdb.pdf
 

Recently uploaded

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Delhi Call girls
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Callshivangimorya083
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxolyaivanovalion
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfMarinCaroMartnezBerg
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Onlineanilsa9823
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...shivangimorya083
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Callshivangimorya083
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxolyaivanovalion
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...shambhavirathore45
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023ymrp368
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysismanisha194592
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfadriantubila
 

Recently uploaded (20)

Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls CP 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
Best VIP Call Girls Noida Sector 22 Call Me: 8448380779
 
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
꧁❤ Greater Noida Call Girls Delhi ❤꧂ 9711199171 ☎️ Hard And Sexy Vip Call
 
VidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptxVidaXL dropshipping via API with DroFx.pptx
VidaXL dropshipping via API with DroFx.pptx
 
FESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdfFESE Capital Markets Fact Sheet 2024 Q1.pdf
FESE Capital Markets Fact Sheet 2024 Q1.pdf
 
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
꧁❤ Aerocity Call Girls Service Aerocity Delhi ❤꧂ 9999965857 ☎️ Hard And Sexy ...
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service OnlineCALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
CALL ON ➥8923113531 🔝Call Girls Chinhat Lucknow best sexual service Online
 
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...Vip Model  Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
Vip Model Call Girls (Delhi) Karol Bagh 9711199171✔️Body to body massage wit...
 
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip CallDelhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
Delhi Call Girls Punjabi Bagh 9711199171 ☎✔👌✔ Whatsapp Hard And Sexy Vip Call
 
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
(PARI) Call Girls Wanowrie ( 7001035870 ) HI-Fi Pune Escorts Service
 
Edukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFxEdukaciniai dropshipping via API with DroFx
Edukaciniai dropshipping via API with DroFx
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...Determinants of health, dimensions of health, positive health and spectrum of...
Determinants of health, dimensions of health, positive health and spectrum of...
 
Data-Analysis for Chicago Crime Data 2023
Data-Analysis for Chicago Crime Data  2023Data-Analysis for Chicago Crime Data  2023
Data-Analysis for Chicago Crime Data 2023
 
April 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's AnalysisApril 2024 - Crypto Market Report's Analysis
April 2024 - Crypto Market Report's Analysis
 
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdfAccredited-Transport-Cooperatives-Jan-2021-Web.pdf
Accredited-Transport-Cooperatives-Jan-2021-Web.pdf
 

Assignment 5.2.pdf

  • 1. Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/re uters.npz 2113536/2110848 [==============================] - 3s 2us/step 2121728/2110848 [==============================] - 3s 2us/step C:Userswaleeanaconda3libsite-packageskerasdatasetsreuters.py:143: VisibleDep recationWarning: Creating an ndarray from ragged nested sequences (which is a list-o r-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecat ed. If you meant to do this, you must specify 'dtype=object' when creating the ndarr ay x_train, y_train = np.array(xs[:idx]), np.array(labels[:idx]) C:Userswaleeanaconda3libsite-packageskerasdatasetsreuters.py:144: VisibleDep recationWarning: Creating an ndarray from ragged nested sequences (which is a list-o r-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecat ed. If you meant to do this, you must specify 'dtype=object' when creating the ndarr ay x_test, y_test = np.array(xs[idx:]), np.array(labels[idx:]) 8982 2246 [1, 245, 273, 207, 156, 53, 74, 160, 26, 14, 46, 296, 26, 39, 74, 2979, 3554, 14, 46, 4689, 4329, 86, 61, 3499, 4795, 14, 61, 451, 4329, 17, 12] In [1]: from keras.datasets import reuters (train_data, train_labels), (test_data, test_labels) = reuters.load_data(num_words=1 In [2]: len(train_data) Out[2]: In [3]: len(test_data) Out[3]: In [4]: train_data[10] Out[4]: In [5]: word_index = reuters.get_word_index() reverse_word_index = dict([(value, key) for (key, value) in word_index.items()]) # Offset indices by 3
  • 2. Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/re uters_word_index.json 557056/550378 [==============================] - 1s 2us/step 565248/550378 [==============================] - 1s 2us/step '? ? ? said as a result of its december acquisition of space co it expects earnings per share in 1987 of 1 15 to 1 30 dlrs per share up from 70 cts in 1986 the company said pretax net should rise to nine to 10 mln dlrs from six mln dlrs in 1986 and ren tal operation revenues to 19 to 22 mln dlrs from 12 5 mln dlrs it said cash flow per share this year should be 2 50 to three dlrs reuter 3' 3 # because 0, 1 and 2 are reserved indices for "padding", "start of sequence", and "u decoded_newswire = ' '.join([reverse_word_index.get(i - 3, '?') for i in train_data[ In [6]: decoded_newswire Out[6]: In [7]: train_labels[10] Out[7]: In [8]: import numpy as np def vectorize_sequences(sequences, dimension=10000): results = np.zeros((len(sequences), dimension)) for i, sequence in enumerate(sequences): results[i, sequence] = 1. return results # Our vectorized training data x_train = vectorize_sequences(train_data) # Our vectorized test data x_test = vectorize_sequences(test_data) In [9]: def to_one_hot(labels, dimension=46): results = np.zeros((len(labels), dimension)) for i, label in enumerate(labels): results[i, label] = 1. return results # Our vectorized training labels one_hot_train_labels = to_one_hot(train_labels) # Our vectorized test labels one_hot_test_labels = to_one_hot(test_labels) In [10]: from keras.utils.np_utils import to_categorical one_hot_train_labels = to_categorical(train_labels) one_hot_test_labels = to_categorical(test_labels) In [11]: from keras import models from keras import layers model = models.Sequential() model.add(layers.Dense(64, activation='relu', input_shape=(10000,))) model.add(layers.Dense(64, activation='relu')) model.add(layers.Dense(46, activation='softmax')) In [12]: model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) In [13]: x_val = x_train[:1000] partial_x_train = x_train[1000:] y_val = one_hot_train_labels[:1000] partial_y_train = one_hot_train_labels[1000:] In [14]: history = model.fit(partial_x_train, partial_y_train,
  • 3. Epoch 1/20 16/16 [==============================] - 39s 125ms/step - loss: 3.2245 - accuracy: 0.3478 - val_loss: 1.7983 - val_accuracy: 0.6600 Epoch 2/20 16/16 [==============================] - 1s 41ms/step - loss: 1.5213 - accuracy: 0.7 100 - val_loss: 1.3048 - val_accuracy: 0.7230 Epoch 3/20 16/16 [==============================] - 1s 34ms/step - loss: 1.0804 - accuracy: 0.7 787 - val_loss: 1.1374 - val_accuracy: 0.7580 Epoch 4/20 16/16 [==============================] - 1s 35ms/step - loss: 0.8291 - accuracy: 0.8 275 - val_loss: 1.0291 - val_accuracy: 0.7910 Epoch 5/20 16/16 [==============================] - 1s 35ms/step - loss: 0.6616 - accuracy: 0.8 663 - val_loss: 0.9549 - val_accuracy: 0.7970 Epoch 6/20 16/16 [==============================] - 1s 38ms/step - loss: 0.5123 - accuracy: 0.8 973 - val_loss: 0.9079 - val_accuracy: 0.8160 Epoch 7/20 16/16 [==============================] - 1s 38ms/step - loss: 0.4107 - accuracy: 0.9 206 - val_loss: 0.9038 - val_accuracy: 0.8100 Epoch 8/20 16/16 [==============================] - 1s 37ms/step - loss: 0.3268 - accuracy: 0.9 343 - val_loss: 0.8954 - val_accuracy: 0.8040 Epoch 9/20 16/16 [==============================] - 1s 35ms/step - loss: 0.2674 - accuracy: 0.9 441 - val_loss: 0.9077 - val_accuracy: 0.8080 Epoch 10/20 16/16 [==============================] - 1s 39ms/step - loss: 0.2275 - accuracy: 0.9 504 - val_loss: 0.8904 - val_accuracy: 0.8220 Epoch 11/20 16/16 [==============================] - 1s 37ms/step - loss: 0.1932 - accuracy: 0.9 551 - val_loss: 0.8983 - val_accuracy: 0.8190 Epoch 12/20 16/16 [==============================] - 1s 37ms/step - loss: 0.1673 - accuracy: 0.9 572 - val_loss: 0.9229 - val_accuracy: 0.8190 Epoch 13/20 16/16 [==============================] - 1s 35ms/step - loss: 0.1513 - accuracy: 0.9 583 - val_loss: 0.9595 - val_accuracy: 0.8070 Epoch 14/20 16/16 [==============================] - 1s 35ms/step - loss: 0.1424 - accuracy: 0.9 579 - val_loss: 0.9638 - val_accuracy: 0.8150 Epoch 15/20 16/16 [==============================] - 1s 36ms/step - loss: 0.1248 - accuracy: 0.9 623 - val_loss: 0.9832 - val_accuracy: 0.8070 Epoch 16/20 16/16 [==============================] - 1s 36ms/step - loss: 0.1246 - accuracy: 0.9 571 - val_loss: 1.0030 - val_accuracy: 0.8120 Epoch 17/20 16/16 [==============================] - 1s 35ms/step - loss: 0.1177 - accuracy: 0.9 608 - val_loss: 1.0174 - val_accuracy: 0.8040 Epoch 18/20 16/16 [==============================] - 1s 36ms/step - loss: 0.1055 - accuracy: 0.9 625 - val_loss: 1.0484 - val_accuracy: 0.8100 Epoch 19/20 16/16 [==============================] - 1s 34ms/step - loss: 0.1068 - accuracy: 0.9 614 - val_loss: 1.0720 - val_accuracy: 0.8040 Epoch 20/20 16/16 [==============================] - 1s 37ms/step - loss: 0.1055 - accuracy: 0.9 583 - val_loss: 1.0762 - val_accuracy: 0.8000 epochs=20, batch_size=512, validation_data=(x_val, y_val)) In [15]: import matplotlib.pyplot as plt loss = history.history['loss'] val_loss = history.history['val_loss'] epochs = range(1, len(loss) + 1)
  • 4. plt.plot(epochs, loss, 'bo', label='Training loss') plt.plot(epochs, val_loss, 'b', label='Validation loss') plt.title('Training and validation loss') plt.xlabel('Epochs') plt.ylabel('Loss') plt.legend() plt.show() In [16]: plt.clf() # clears the figure acc = history.history['accuracy'] val_acc = history.history['val_accuracy'] plt.plot(epochs, acc, 'bo', label='Training acc') plt.plot(epochs, val_acc, 'b', label='Validation acc') plt.title('Training and validation accuracy') plt.xlabel('Epochs') plt.ylabel('Loss') plt.legend() plt.show() In [17]: model = models.Sequential() model.add(layers.Dense(64, activation='relu', input_shape=(10000,))) model.add(layers.Dense(64, activation='relu')) model.add(layers.Dense(46, activation='softmax')) model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) model.fit(partial_x_train, partial_y_train,
  • 5. Epoch 1/8 16/16 [==============================] - 3s 67ms/step - loss: 3.0656 - accuracy: 0.4 297 - val_loss: 1.6959 - val_accuracy: 0.6300 Epoch 2/8 16/16 [==============================] - 1s 32ms/step - loss: 1.5030 - accuracy: 0.6 813 - val_loss: 1.2944 - val_accuracy: 0.7150 Epoch 3/8 16/16 [==============================] - 1s 36ms/step - loss: 1.0861 - accuracy: 0.7 640 - val_loss: 1.1250 - val_accuracy: 0.7540 Epoch 4/8 16/16 [==============================] - 1s 39ms/step - loss: 0.8546 - accuracy: 0.8 190 - val_loss: 1.0358 - val_accuracy: 0.7760 Epoch 5/8 16/16 [==============================] - 1s 39ms/step - loss: 0.6699 - accuracy: 0.8 599 - val_loss: 0.9529 - val_accuracy: 0.7990 Epoch 6/8 16/16 [==============================] - 1s 37ms/step - loss: 0.5317 - accuracy: 0.8 909 - val_loss: 0.9138 - val_accuracy: 0.8120 Epoch 7/8 16/16 [==============================] - 1s 38ms/step - loss: 0.4173 - accuracy: 0.9 173 - val_loss: 0.9121 - val_accuracy: 0.8040 Epoch 8/8 16/16 [==============================] - 1s 38ms/step - loss: 0.3313 - accuracy: 0.9 337 - val_loss: 0.8866 - val_accuracy: 0.8190 71/71 [==============================] - 0s 3ms/step - loss: 0.9642 - accuracy: 0.78 63 [0.964229941368103, 0.7862867116928101] 0.18699910952804988 (46,) 1.0000001 3 epochs=8, batch_size=512, validation_data=(x_val, y_val)) results = model.evaluate(x_test, one_hot_test_labels) In [18]: results Out[18]: In [19]: import copy test_labels_copy = copy.copy(test_labels) np.random.shuffle(test_labels_copy) float(np.sum(np.array(test_labels) == np.array(test_labels_copy))) / len(test_labels Out[19]: In [20]: predictions = model.predict(x_test) In [21]: predictions[0].shape Out[21]: In [22]: np.sum(predictions[0]) Out[22]: In [23]: np.argmax(predictions[0]) Out[23]: In [24]: y_train = np.array(train_labels) y_test = np.array(test_labels) In [25]: model.compile(optimizer='rmsprop', loss='sparse_categorical_crossentropy', metrics=[ In [26]: model = models.Sequential()
  • 6. Epoch 1/20 63/63 [==============================] - 4s 32ms/step - loss: 3.4182 - accuracy: 0.1 167 - val_loss: 2.5418 - val_accuracy: 0.4070 Epoch 2/20 63/63 [==============================] - 1s 16ms/step - loss: 2.3245 - accuracy: 0.4 161 - val_loss: 2.0374 - val_accuracy: 0.4260 Epoch 3/20 63/63 [==============================] - 1s 16ms/step - loss: 1.8282 - accuracy: 0.4 539 - val_loss: 1.7261 - val_accuracy: 0.4410 Epoch 4/20 63/63 [==============================] - 1s 16ms/step - loss: 1.4547 - accuracy: 0.5 176 - val_loss: 1.4957 - val_accuracy: 0.6370 Epoch 5/20 63/63 [==============================] - 1s 17ms/step - loss: 1.2671 - accuracy: 0.6 758 - val_loss: 1.4441 - val_accuracy: 0.6600 Epoch 6/20 63/63 [==============================] - 1s 15ms/step - loss: 1.1477 - accuracy: 0.7 117 - val_loss: 1.4194 - val_accuracy: 0.6750 Epoch 7/20 63/63 [==============================] - 1s 21ms/step - loss: 1.0301 - accuracy: 0.7 430 - val_loss: 1.4107 - val_accuracy: 0.6880 Epoch 8/20 63/63 [==============================] - 1s 18ms/step - loss: 0.9645 - accuracy: 0.7 553 - val_loss: 1.4553 - val_accuracy: 0.6880 Epoch 9/20 63/63 [==============================] - 1s 17ms/step - loss: 0.9077 - accuracy: 0.7 690 - val_loss: 1.4827 - val_accuracy: 0.6780 Epoch 10/20 63/63 [==============================] - 1s 19ms/step - loss: 0.8553 - accuracy: 0.7 733 - val_loss: 1.4980 - val_accuracy: 0.6870 Epoch 11/20 63/63 [==============================] - 1s 19ms/step - loss: 0.8322 - accuracy: 0.7 800 - val_loss: 1.5350 - val_accuracy: 0.6820 Epoch 12/20 63/63 [==============================] - 1s 21ms/step - loss: 0.7728 - accuracy: 0.7 883 - val_loss: 1.5694 - val_accuracy: 0.6790 Epoch 13/20 63/63 [==============================] - 1s 17ms/step - loss: 0.7678 - accuracy: 0.7 847 - val_loss: 1.6703 - val_accuracy: 0.6820 Epoch 14/20 63/63 [==============================] - 1s 20ms/step - loss: 0.7472 - accuracy: 0.7 846 - val_loss: 1.7068 - val_accuracy: 0.6820 Epoch 15/20 63/63 [==============================] - 1s 22ms/step - loss: 0.7523 - accuracy: 0.7 822 - val_loss: 1.7743 - val_accuracy: 0.6810 Epoch 16/20 63/63 [==============================] - 1s 19ms/step - loss: 0.7087 - accuracy: 0.7 904 - val_loss: 1.8168 - val_accuracy: 0.6750 Epoch 17/20 63/63 [==============================] - 1s 14ms/step - loss: 0.7009 - accuracy: 0.7 919 - val_loss: 1.8658 - val_accuracy: 0.6870 Epoch 18/20 63/63 [==============================] - 1s 19ms/step - loss: 0.6559 - accuracy: 0.8 070 - val_loss: 1.9383 - val_accuracy: 0.6790 Epoch 19/20 63/63 [==============================] - 1s 15ms/step - loss: 0.6627 - accuracy: 0.8 041 - val_loss: 2.0031 - val_accuracy: 0.6810 model.add(layers.Dense(64, activation='relu', input_shape=(10000,))) model.add(layers.Dense(4, activation='relu')) model.add(layers.Dense(46, activation='softmax')) model.compile(optimizer='rmsprop', loss='categorical_crossentropy', metrics=['accuracy']) model.fit(partial_x_train, partial_y_train, epochs=20, batch_size=128, validation_data=(x_val, y_val))
  • 7. Epoch 20/20 63/63 [==============================] - 1s 14ms/step - loss: 0.6398 - accuracy: 0.8 039 - val_loss: 1.9840 - val_accuracy: 0.6790 <keras.callbacks.History at 0x1328abf6910> Out[26]: In [ ]: