Skip to content

Commit

Permalink
renamed: percep.py -> sec2_exp1_perceptron.py
Browse files Browse the repository at this point in the history
	renamed:    ex1_raise_salary_perceptron.py -> sec2_hwk1_perceptron_salary-raise.py
	renamed:    multi_layer_percep.py -> sec3_exp1_ml-perceptron.py
	renamed:    ex2_credit_risk.py -> sec3_hwk1_ml-perceptron_credit_risk.py
	renamed:    iris_dataset.py -> sec4_exp1_iris_dataset
	renamed:    class_pybrain.py -> sec4_exp2_pybrain_classf.py
	renamed:    class2_pybrain.py -> sec4_exp3_pybrain_classf.py
	renamed:    sklearn-classification.py -> sec4_exp4_sklearn-classification.py
	renamed:    sklearn-regression.py -> sec4_exp5_sklearn-regression.py
	renamed:    neuralnet_tensorflow.py -> sec4_exp6_neuralnet_tensorflow.py
	renamed:    ex3_iris_pybrain.py -> sec4_hwk1_pybrain_iris-ds.py
	renamed:    ex4_sklearn-classification_wine.py -> sec4_hwk2_sklearn_wine-classf.py
	new file:   sec4_hwk3_tensorflow_image-classf.py
  • Loading branch information
cammneto committed Jun 17, 2022
1 parent 99cc1c9 commit 7f1245e
Show file tree
Hide file tree
Showing 13 changed files with 45 additions and 0 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions sec4_hwk3_tensorflow_image-classf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import tensorflow
import matplotlib.pyplot as plt
import numpy as np
from keras.models import Sequential
from keras.layers import Dense
from keras.utils import np_utils
from keras.datasets import fashion_mnist

(x_train, y_train), (x_test, y_test)= fashion_mnist.load_data()

#plt.imshow(x_train[0], cmap='gray')
#plt.title('Class: ' + str(y_train[0]))
#plt.show()

x_train = x_train.reshape(60000, 28*28)
x_test = x_test.reshape(10000, 28*28)

x_train = x_train.astype('float32')
x_test = x_test.astype('float32')

x_train = x_train/255
x_test = x_test/255

y_train = np_utils.to_categorical(y_train)

y_test = np_utils.to_categorical(y_test)

network = Sequential()
network.add(Dense(input_shape=(784,), units=397, activation='relu'))
network.add(Dense(units=397, activation='relu'))
network.add(Dense(units=10, activation='softmax'))
network.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])

history = network.fit(x_train, y_train, batch_size=128, epochs=60)

plt.plot(history.history['loss'])
plt.show()
plt.plot(history.history['accuracy'])
plt.show()
accuracy_test = network.evaluate(x_test, y_test)
predictions = network.predict(x_test)

plt.imshow(x_test[0].reshape(28,28), cmap='gray')
plt.title('Class: ' + str(y_test[0]))
plt.show()

0 comments on commit 7f1245e

Please sign in to comment.