Created
October 30, 2019 17:56
-
-
Save grohith327/3ff5da311fe03e0a8cc615bf7435ae83 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tensorflow as tf | |
from tensorflow.keras.layers import Dense, Flatten, Conv2D, MaxPool2D, Dropout | |
# Create training and testing datasets from tensors | |
train_ds = tf.data.Dataset.from_tensor_slices((X_train, y_train)).batch(1) | |
test_ds = tf.data.Dataset.from_tensor_slices((X_test, y_test)).batch(1) | |
# CNN Model | |
class Command(Model): | |
def __init__(self): | |
super(Command,self).__init__() | |
self.conv1= Conv2D(32,3,padding='same',activation='relu') | |
self.poo11 = MaxPooling2D((2,2)) | |
self.conv2= Conv2D(64,3,padding='same',activation='relu') | |
self.pool2 = MaxPooling2D((2,2)) | |
self.conv3= Conv2D(128,3,padding='same',activation='relu') | |
self.flatten = Flatten() | |
self.fc1=Dense(256, activation='relu') | |
self.fc2=Dropout(0.4) | |
self.fc3=Dense(100, activation='relu') | |
self.fc4=Dropout(0.4) | |
self.fc5=Dense(5, activation='softmax') | |
def call(self,x): | |
x=self.conv1(x) | |
x=self.pool1(x) | |
x=self.conv2(x) | |
x=self.pool2(x) | |
x=self.conv3(x) | |
x=self.flatten(x) | |
x=self.fc1(x) | |
x=self.fc2(x) | |
x=self.fc3(x) | |
x=self.fc4(x) | |
x=self.fc5(x) | |
return x |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment