Skip to main content

Imagenet Image Recognition Using Tensorflow, Keras

Imagenet Dataset and Image Recognition

 

import tensorflow as tf
from tensorflow import keras
from keras.models import Sequential
from keras.layers import Dense, Flatten, Conv2D, MaxPooling2D, Dropout
from tensorflow.keras import layers
from keras.utils import to_categorical
import numpy as np
import matplotlib.pyplot as plt
plt.style.use('fivethirtyeight')
 
from keras.datasets import cifar10
(x_train, y_train),(x_test, y_test) = cifar10.load_data()
 
plt.imshow(x_train[0])
 
y_train_one_hot = to_categorical(y_train)
y_test_one_hot = to_categorical(y_test)
x_train = x_train/255
x_test = x_test/255
 
model = Sequential()
model.add(Conv2D(32,(5,5),activation='relu', input_shape=(32,32,3)))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Conv2D(32,(5,5),activation='relu'))
model.add(MaxPooling2D(pool_size=(2,2)))
model.add(Flatten())
model.add(Dense(1000,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(500,activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(250,activation='relu'))
model.add(Dense(10,activation='softmax'))

model.compile(loss='categorical_crossentropy',
              optimizer='adam',
              metrics=['accuracy'])
 
hist = model.fit(x_train, y_train_one_hot,
                 batch_size=256,
                 epochs=10,
                 validation_split=0.2 )
 
model.evaluate(x_test, y_test_one_hot)[1]
 
plt.plot(hist.history['accuracy'])
plt.plot(hist.history['val_accuracy'])
plt.title('Model Accuracy')
plt.xlabel('epochs')
plt.ylabel('accuracy')
plt.legend(['Train''Val'],loc='upper right')
plt.show()
 
plt.plot(hist.history['loss'])
plt.plot(hist.history['val_loss'])
plt.title('Model Loss')
plt.xlabel('epochs')
plt.ylabel('loss')
plt.legend(['Train''Val'],loc='upper right')
plt.show()
 
Imagenet Colab Link: 
 
 
 
 
 
 
 
 

 

Comments

Popular posts from this blog

All India - Kedarnath, Kasi Viswanath, Badrinath, Jagnath, Dhuvaraga, Amristar, Madurai, Kancheepuram, Tirumalai,

Kanyakumari - Kothaiyar Dam, Thiruparappu Falls, Mathur, Kulachekaram, Marthandam, Nagerkovil

Labour Intensive Versus Capital Intensive - Balance

  1. Labour intensive and Capital intensive, Economic policies two ways. Our policy is Mixed, ie., Labour and Capital. Ex. LIC, BHEL, SBI stands testimony to this. This Mixed economy is Unique for our Nation.   2. Adaptation New technology in any organisation, leads to Job Cut. Machine sucks human blood at the back and black side. Hindustan Teleprinters Ltd, Telecom service provider closed operation, since market dynamics changed from Dialed-Wired to Mobile. Nokia 2G enjoyed HTL closure. Years after same HTL closure happens to Nokia by the invention of " Touch Technology" and Korean SamSung Galaxy picked the Lion-Share of Market. 3. AI, Cloud, ML, 5G growth, we have to pay the heavy PRICE for adaptation to NEW INVENTIONS. Labours of HTL, Labours of Nokia not at the age group of 50's but 30's.   4. 5G RISKS    4. Any MNC, moving to 5G at the cost of Labours Job first. Thatz they claim as Optimized to $100 million is saving by moving to CLOUD. Black-side ...