0% found this document useful (0 votes)
70 views29 pages

Chat Bot

Uploaded by

swetharamasamy08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views29 pages

Chat Bot

Uploaded by

swetharamasamy08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 29

EDUCATIONAL CHATBOT USING CNN

SUBMITTED BY
PAVITHRA S (711721244065)
SHANKARI G (711721244068)
DEEPIKA S (711721244011)
SWETHA R (711721244059)
ARVIND M (711721244005)

Under the guidance of

Mrs. G. ELIZABETH RANI (M. Tech)


(Assistant Professor, Department of Computer Science and Business Systems)
In partial fulfillment for the award of the degree
Of
BACHELOR OF TECHNOLOGY
In
COMPUTER SCIENCE AND BUSINESS SYSTEMS

KGISL INSTITUTE OF TECHNOLOGY


(Affiliated to Anna University)
Saravanampatti, Coimbatore - 641035
Academic Year 2022-2023
KGISL INSTITUTE OF TECHNOLOGY
(AFFILIATAED TO ANNA UNIVERSITY)
Saravanampatti, Coimbatore – 641035

BONAFIDE CERTIFICATE

This is to certify that the Mini project titled “EDUCATIONAL CHATBOT


USING CNN” is a Bonafide record of the work done by PAVITHRA S
(21CB65), SHANKARI G (21CB68), SWETHA R (21CB59), DEEPIKA
S(21CB11), ARVIND M (21CB05) in partial fulfillment of the requirements
for the award of the degree of Bachelor of Technology in Computer Science
and Business Systems, during the academic year 2020-2021.

Mrs. G. ELIZABETHRANI Dr P. RAJKUMAR

Supervisor Professor and HOD

Assistant Professor/ CSBS Department of CSBS

Submitted for the University Viva-voce Examination held on …………………


ACKNOWLEDGEMENT

First and foremost, I wish to thank god for his grace to complete this “EDUCATIONAL
CHATBOT USING CNN” project successfully. I would also thank my special thanks to my
dear parents from the bottom of my heart for their support in making our project complete.
I express a deep sense of gratitude to Dr. Ashok Bakthavathsalam, Founder chairman, and a
special thanks to Dr. Shankar principal, and Dr. Suresh Kumar Vice Principal, and also a
special thanks to Dr. P. Rajkumar Professor& Head of the Department of Computer Science
and Business Systems, KGISL Institute for granting the permission and providing necessary
facilities to carry out project work.
I am highly indebted to KGISL Institute of Technology (KITE) and express my special and
sincere thanks to my passion project supervisor Mrs. G. ELIZABETH RANI Assistant
Professor, CSBS of KGISL Institute of Technology for her inspiring guidance, constant
encouragement with my work during all stages. I am feeling very glad to do the project under
her guidance, which truly practices and appreciates deep thinking. I will be forever indebted
to my guide for supporting me in difficult times, when started this project and during
compilation errors, she gave moral support and let this project move on.
CHAPTER NO TITLE PAGE NO

1 INTRODUCTION

2 LITERATURE SURVEY

3 EXISTING SYSTEM

4 PROPOSED SYSTEM

4.1 SYSTEM DESIGN

4.2 SYSTEM TESTING

5 SYSTEM ENVIRONMENT

5.1 SOFTWARE
REQUIREMENTS

5.2 HARDWARE
REQUIREMENTS

6 RESULTS AND
DISCUSSION

CONCLUSION AND
FUTURE ENHANCEMENT

REFERENCE

APPENDIX
ABSTRACT

The use of educational chatbots evolved rapidly in numerous fields in recent years,
including Marketing, Supporting Systems, Education, Health Care, Cultural Heritage, and
Entertainment. This paper presents a historical overview of the evolution of the international
community’s interest in chatbots. Next, we discuss the motivations that drive the use of
chatbots, and we clarify chatbots’ usefulness in a variety of areas. Moreover, we highlight the
impact of social stereotypes on chatbot design. After clarifying necessary technological
concepts, we move on to a chatbot classification based on various criteria, such as the area of
knowledge they refer to, the need they serve, and others. Furthermore, we present the general
architecture of modern chatbots while also mentioning the main platforms for their creation.
Our engagement with the subject so far, reassures us of the prospects of chatbots and
encourages us to study them to greater extent and depth.
A chatbot enables a user to simply ask questions in the same manner that they
would respond to humans. The most well-known chatbots currently are voice chatbots: SIRI
and Alexa. However, chatbots have been adopted and brought into daily application at a high
rate on the computer chat platform. NLP also allows computers and algorithms to understand
human interactions through various languages. Recent advances in machine learning have
greatly improved the accuracy and effectiveness of natural language processing, making
chatbots a viable option for many organizations. This improvement in NLP is firing a great
deal of additional research which should lead to continued improvement in the effectiveness
of chatbots in the years to come. A bot is trained on and according to the training, based on
some rules on which it is trained, it answers questions. It is called ruled based approach. The
language by which these bots can be created is Artificial Intelligence Markup Language
(AIML).
Chapter 1

INTRODUCTION

An educational chatbot is an application that has a database, it has an app l and APIs to
call other external administrations. However, bots cannot comprehend what the customer has
planned. It is a very much common problem that must be tackled. Bots are generally trained
according to the past information which is only available to them. So in most organizations,
chatbot maintains their logs of discussions so that they can understand their customer’s
behavior.

Developers utilize these logs to analyze what clients are trying to ask. Developers
coordinate with their client inquiries and reply with the best appropriate answer with the
blend of machine learning tools and models. Training a chatbot is much faster and on a large
scale compared to human beings. A customer support chatbot is filled with a very large
number of conversation logs which help the chatbot to understand what kinds of questions
should be asked and what answers should be given. While normal customer service
representatives are given manual instructions which they have to go through with. The
chatbots are based on three methods:

Pattern Matches: The pattern matches a group of texts utilized by the bots and so it produces
an appropriate response to the customers. The standard structured model used for the creation
of these patterns is “Artificial Intelligence Markup Language”.

Natural Language Understanding (NLU): Finding the way to convert the user’s speech or
text into structured data is called Natural Language Processing. It is used to get relevant
answers for the customers. To develop a chatbot one must be very clear about what one wants
from that chatbot. Often, they are developed for business platforms like Net Banking sites to
handle customer Q&A. Other types of chatbots that are widely developed and used are smart
assistants like Google Assistant, Siri, Alexa, Cortana, etc.
A chatbot is an AI program that copies human discussions including content and
communication in natural language utilizing artificial intelligence methods for example,
Natural Language Processing is a picture and video processing and voice analysis.
Chapter 2

LITERATURE SURVEY

According to the survey on Educational Chatbot Implementation in Customer Service


Industry through Deep Neural Networks, the strategies for creating rules for chatbots have
been advanced. strategy for creating chatbots has depended on hand-written rules and
templates. With the rise of deep learning, these models were quickly replaced by an end-to-
end neural network. More specifically DNN is a powerful generative-based model to take
care of conversational response generation problems. This paper led an inside and out review
of ongoing literature, examining more than 70 publications related to chatbots published in
the last 5 years. based on a literature survey, this examination compared chosen papers
according to the strategy adopted. This paper also introduced why current chatbot models fail
to take into account while generating responses and how this affects the quality of
conversation [1].

According to the research intent detection-based Lithuanian chatbot was created via an
Automatic DNN hyper-parameter. Optimization they handled a purpose recognition issue for
the Lithuanian language with real supervised data. The main principle of focus is on the
upgrade of the NL.

Understanding module, responsible for the comprehension of user questions. The NLU
model is prepared with an appropriately selected word vectorization type and a Deep Neural
Network classifier. During their experiment, they tentatively investigated fast text and Bert
embeddings [2-3].

Research on chatbot technologies and challenges gave an outline of the innovations


that drive chatbots including Information Extraction and deep learning. they have additionally
examined the contrasts between conversational and transactional chatbots. the former is
defined manually on free-form chat logs while the last is characterized physically to
accomplish a particular objective like booking a flight. they have likewise given an outline of
commercial tools and platforms that can help in creating and deploying chatbots. at last, they
have introduced the limitations and future work difficulties around here [4].
According to research, Accessible conversational user interfaces consideration for the
design scope of current guidance and flow direction, reports, exploration, and writing on an
open plan for various disability groups of incorporating clients with psychological well-being
issues, mental imbalance, medical issues, intellectual incapacities, dyslexia, or learning
challenges, and tangible, versatility or ability weaknesses. they grouped the component from
this assortment of directions that seem applicable to the plan of available CUIs, and cases
where direction presents less decisive issues, and require further investigation [5-7].

According to research Ensemble-based, deep reinforcement learning for chatbots


trainable chatbots that show familiar and human-like discussions remain a major challenge in
artificial intelligence. Deep Reinforcement Learning is promising for tending to this test,
however, its fruitful application remains an open inquiry. This article portrays a novel
ensemble-based methodology applied to esteem-based DRL chatbots which utilize limited
activity sets as a type of importance portrayal. In their methodology, while exchange
activities are obtained from sentence clustering, the training datasets in our ensemble are
obtained from discourse clustering. The latter plans to induce specific agents that figure out
how to communicate in a specific style [8].
Chapter 3

EXISTING SYSTEM

1. Dialog flow: Dialog flow is a chatbot development platform by Google that allows
developers to build and integrate conversational interfaces into mobile apps, web
applications, devices, and bots.

2. IBM Watson: IBM Watson is a cognitive computing system that uses natural
language processing and machine learning algorithms to understand human language
and provide intelligent responses to queries.

3. Microsoft Bot Framework: The Microsoft Bot Framework is a set of tools and
services for building and deploying intelligent bots on a variety of platforms including
Skype, Slack, Facebook Messenger, and other popular chat platforms.

4. Amazon Lex: Amazon Lex is a service that enables developers to build


conversational interfaces using voice and text that can be integrated with various
platforms including Amazon Alexa, mobile apps, and web applications.

5. Rasa: Rasa is an open-source framework for building conversational AI assistants. It


provides tools for natural language processing, dialogue management, and machine
learning.
Chapter 4

PROPOSED SYSTEM

Our project is based on Artificial Intelligence- powered Educational Chatbot. Python


is software that provides a user-friendly interface to make the connection easier and more
convenient with the internet providing valid and reliable web services. We've created a
sample chatbot using the same as Twitch as an online platform that provides a chatbot
platform to online clients. The web-based platform provides a vast intelligent base that can
help simulate problem-solving for humans. We can help if the user wants to have any queries
or he wants to enquire about something. Our methodology includes the API of the Chatbot
that will be developed with Cascading style sheet which covers all the styling parts and the
Javascript is used for functioning the chatbot Back end part will be done with Python
programming language.
Figure.1ProposedSystemArchitecture.[Source:https://www.researchgate.net/publication/
3102/AS:428161692377103@1479093110926/Proposed-System-Design-of-IoT-Chatbot-
System Figure 1 describes the proposed system architecture of the chatbot. How the chatbot
interacts with users over the network

4.1 SYSTEM DESIGN

There are seven steps to designing the Chatbot process they are scope and requirement,
identifying the inputs, understanding the UI elements, crafting the first interaction, building
conversation and finally testing.

Figure 2– Flow diagram of Chatbot. [Source:


https://www.elprocus.com/wp-content/uploads/chatbot-design-process]

Figure-2 describes the flow diagram of the chatbot which helps us to identify and easy to
understand.

The first step to designing the Chatbot is to know the scope and requirements like why
the chatbot, the platform to launch chatbots, and its limitations. The second step is to identify
the inputs from users in the form of queries through text, voice, or images, from devices, and
intelligence systems. The third step is to understand the User Interface (UI) elements, that we
can see in our applications. UI elements are of five types they are Command Line(CL),
Graphical User Interface(GUI), Menu-Driven Interface (MDI), Form-Based Interface (FBI),
and Natural Language Interface (NLI). After understanding user interface elements, the next
step is to craft the first interaction and build a conversation. The final step of the Chatbot
design process is testing, which is done on mobile and websites to know how it’s working.

Figure 3– System architecture of Chatbot. [Source: https://i.imgur.com/6cvbRET.png]

Figure-3 describes the system architecture of the chatbot to figure out the given program or
information.

WORKFLOW

 API Gateway passes on the incoming request from different clients to respective
services.
 The chatbot server takes in chat messages from different clients and responds.
 The NLU engine is responsible for predicting the intents and entities from a given
text.
 The Chatbot server also acts as an action server that calls external APIs to perform a
specific action.
 Chatlog service is responsible for logging all the messages in the system.
 Redis store is responsible for maintaining the state of the messages for each user.

Figure 4 – Workflow of Chatbot. [Source:


https://aritic.com/blog/aritic-pinpoint/wp-content/uploads/sites/3/2019/07/Chatbot_Scenario-
04]

Figure -4 describes the workflow of the chatbot which helps to reduce the testing steps and
can get accurate results.

4.2 SYSTEM TESTING

BrowserStack is a cloud-based website and mobile testing platform that offers 3000+ real
browsers and devices (desktop and mobile) for instant, on-demand testing.
 Login to BrowserStack. Launch Automate If you don’t have an account already, sign
up for free.
 The sample code is already available. Just modify and add your code.
 Once it is configured, set up the dependencies and desired capabilities to run the test.
 Follow the detailed instructions below if you are using Gradle or Maven to build your
Java project. Add the maven dependency to your pom.xml file or you can directly
configure your build path by adding the selenium jar file to your library to run the test
case.

Figure 5– Testing of Chatbot.

Figure-5 describes the testing method of the chatbot. How to server control the chatbot and
how the data are handled in the server.
Chapter 5

SYSTEM ENVIRONMENT

5.1 SOFTWARE REQUIREMENTS

1. Chatbot development platform.


2. Natural Language Processing (NLP) tools.
3. Machine learning frameworks.
4. Programming languages.
5. Databases.
6. API integration.
7. Hosting and deployment services.

5.2 HARDWARE REQUIREMENTS

The hardware requirements for a chatbot depend on the scale and complexity of the
chatbot application. Here are some general hardware requirements to consider :

1. Processor.
2. RAM.
3. Storage.
4. Networking.
5. Operating system.
6. Cloud infrastructure.
Chapter 6

RESULTS AND DISCUSSION

Figure.6 – Website of Chatbot.

Figure 6 describes the webpage of the chatbot which is named Dear Professor. Here the
students can enroll in their courses. The chatbot will help to collect their basic information.
Chatbots – also known as “conversational agents” – are software applications that mimic
written or spoken human speech to simulate a conversation or interaction with a real person.
There are two primary ways chatbots are offered to visitors: via web-based applications or
standalone apps.
Figure.7 – Chatbot structure.

Figure 7 describes the required chatbot, here we will be answering some queries regarding
our knowledge or we can know about the education information. Tech-savvy consumers of
today are always on the lookout for the best and most personalized customer experiences. It
can seem an impossible task to fulfill the onslaught of ever-evolving demands. However,
there is one solution primed to satisfy the modern customer, and that is a chatbot. With a
chatbot, your organization can easily offer high-quality support and conflict resolution any
time of day, and for a large quantity of customers simultaneously. According
to Microsoft, 90% of consumers expect an online portal for customer service. As a
significant aspect of business evolution, the need for AI-powered chatbots will only continue
to rise. Now is the time to deploy a chatbot solution so that your company doesn’t get left
behind.
Figure 8 – Design of Chatbot.

Figure 8 describes the chatbot design and here you can see the questions asked by the
penguin and we are answering their queries. From my perspective, chatbots or smart
assistants with artificial intelligence are dramatically changing businesses. There is a wide
range of chatbot-building platforms that are available for various enterprises, such as e-
commerce, retail, banking, leisure, travel, healthcare, and so on. Chatbots can reach out to a
large audience on messaging apps and be more effective than humans. They may develop
into a capable information-gathering tool shortly.
CONCLUSION

An Educational chatbot is one of the simple ways to transport data from a computer
without having to think of proper keywords to look up in a search or browse several web
pages to collect information; users can easily type their query in natural language and retrieve
information. In this paper, information about the design, and implementation of the chatbot
has been presented. From the survey above, it can be said that the development and
improvement of chatbot design grow at an unpredictable rate due to the variety of methods
and approaches used to design a chatbot. Chatbot is a great tool for quick interaction with the
user. They help us by providing entertainment, saving time, and answering questions that are
hard to find. The Chatbot must be simple and conversational. Since there are many designs
and approaches for creating a chatbot, it can be at odds with commercial considerations.
Researchers need to interact and must agree on a common approach for designing a Chatbot.
In this project, we looked into how Chatbots have developed and the applications of Chatbots
in various fields. In addition, the comparison has been made with other Chatbots. General
purpose Chatbot must be simple, user-friendly, must be easily understood and the knowledge
base must be compact. Although some commercial products have recently emerged,
improvements must be made to find a common approach for designing a Chatbot.

FUTURE ENHANCEMENT

Chatbots can provide buyers with a great experience across all devices, offering deep
insights about the buyer that businesses can use to make personalized offers. Chatbots help
people obtain the information they need and solve their problems.

A company's credibility and the quality of the customer experience are two essential
components of any company wishing to achieve a successful business model.

Many well-known companies are now using a to keep up with the changing world. The
technology sector has seen a massive increase in AI development, which has led to the
creation of chatbots that can help users easily find the information they need online.

Chatbots powered by artificial intelligence effectively create a strong brand image. They
will continue to evolve and play an important role in customer service for businesses.
REFERENCES

1. Abdolrahmani, A., Kuber, R., Branham, S.M.: “Siri Talks at You”: An Empirical
Investigation of Voice-Activated Personal Assistant (VAPA) Usage by Individuals
Who Are Blind. In: Proceedings of the 20th International ACM SIGACCESS
Conference on Computers and Accessibility, Galway, Ireland, October 2018. pp. 249–
258. Association for Computing Machinery, New York, NY, USA (2018). doi:
10.1145/3234695.3236344.

2. Baldauf, M., Bösch, R., Frei, C., Hautle, F., Jenny, M.: Exploring requirements and
opportunities of conversational user interfaces for the cognitively impaired. In:
Proceedings of the 20th International Conference on Human-Computer Interaction
with Mobile Devices and Services Adjunct, Barcelona, Spain, September 2018. pp.
119–126. Association for Computing Machinery, New York, NY, USA (2018). doi:
10.1145/3236112.3236128.

3. Beaunoyer, E., Dupéré, S., Guitton, M.J.: COVID-19 and digital inequalities:
Reciprocal impacts and mitigation strategies. Comput Human Behav. 111 (2020).
doi:10.1016/j.chb.2020.106424.

4. Bickmore, T.W., Picard, R.W.: Establishing and Maintaining Long-term Human-


computer Relationships. ACM Trans. Comput.-Hum. Interact. 12, 293–327 (2005).
https://doi.org/10.1145/1067860.1067867.

5. Bigham, J.P., Aller, M.B., Brudvik, J.T., Leung, J.O., Yazzolino, L.A., Ladner, R.E.:
Inspiring blind high school students to pursue computer science with instant
messaging chatbots. SIGCSE Bulletin. 40, 449–453 (2008). doi:
10.1145/1352322.1352287.

6. Boshoff, A.: Accessibility and chatbots: how to make your chatbot user-friendly for
everyone. Rogerwilco. https://www.rogerwilco.co.za/blog/accessibility-and-chatbots-
how-make-your-chatbot-user-friendly-everyone (2018) Accessed 17 December 2020

7. Brave, S., Nass, C., Hutchinson, K.: Computers that care: investigating the effects of
orientation of emotion exhibited by an embodied computer agent. International
Journal of Human-Computer Studies. 62, 161–178 (2005).
doi:10.1016/j.ijhcs.2004.11.002.

8. Brereton, E.: Universities Use AI Chatbots to Improve Student Services. EdTech


Magazine. https://edtechmagazine.com/higher/article/2019/10/universities-use-ai-
chatbots-improve-student-services (2019). Accessed 22 December 2020.

APPENDIX

SOURCE CODE

import nltk
nltk.download('popular')
from nltk.stem import WordNetLemmatizer
lemmatizer = WordNetLemmatizer()
import pickle
import numpy as np

from keras.models import load_model


model = load_model('model.h5')
import json
import random
intents = json.loads(open('data.json').read())
words = pickle.load(open('texts.pkl','rb'))
classes = pickle.load(open('labels.pkl','rb'))

def clean_up_sentence(sentence):
# tokenize the pattern - split words into array
sentence_words = nltk.word_tokenize(sentence)
# stem each word - create short form for word
sentence_words = [lemmatizer.lemmatize(word.lower()) for word in
sentence_words]
return sentence_words

# return bag of words array: 0 or 1 for each word in the bag that exists in the
sentence

def bow(sentence, words, show_details=True):


# tokenize the pattern
sentence_words = clean_up_sentence(sentence)
# bag of words - matrix of N words, vocabulary matrix
bag = [0]*len(words)
for s in sentence_words:
for i,w in enumerate(words):
if w == s:
# assign 1 if current word is in the vocabulary position
bag[i] = 1
if show_details:
print ("found in bag: %s" % w)
return(np.array(bag))

def predict_class(sentence, model):


# filter out predictions below a threshold
p = bow(sentence, words,show_details=False)
res = model.predict(np.array([p]))[0]
ERROR_THRESHOLD = 0.25
results = [[i,r] for i,r in enumerate(res) if r>ERROR_THRESHOLD]
# sort by strength of probability
results.sort(key=lambda x: x[1], reverse=True)
return_list = []
for r in results:
return_list.append({"intent": classes[r[0]], "probability": str(r[1])})
return return_list

def getResponse(ints, intents_json):


tag = ints[0]['intent']
list_of_intents = intents_json['intents']
for i in list_of_intents:
if(i['tag']== tag):
result = random.choice(i['responses'])
break
return result

def chatbot_response(msg):
ints = predict_class(msg, model)
res = getResponse(ints, intents)
return res

from flask import Flask, render_template, request

app = Flask(__name__)
app.static_folder = 'static'

@app.route("/")
def home():
return render_template("index.html")
@app.route("/get")
def get_bot_response():
userText = request.args.get('msg')
return chatbot_response(userText)

if __name__ == "__main__":
app.run()
Traning .py

mport nltk

nltk.download ()

from nltk.stem import WordNetLemmatizer

lemmatizer = WordNetLemmatizer()

import json

import pickle

import numpy as np

from keras.models import Sequential

from keras.layers import Dense, Activation, Dropout

from keras.optimizers import SGD

import random

import nltk

words=[]
classes = []

documents = []

ignore_words = ['?', '!']

data_file = open('data.json').read()

intents = json.loads(data_file)

for intent in intents['intents']:

for pattern in intent['patterns']:

#tokenize each word

w = nltk.word_tokenize(pattern)

words.extend(w)

#add documents in the corpus

documents.append((w, intent['tag']))

# add to our classes list

if intent['tag'] not in classes:

classes.append(intent['tag'])

# lemmaztize and lower each word and remove duplicates


words = [lemmatizer.lemmatize(w.lower()) for w in words if w not in
ignore_words]

words = sorted(list(set(words)))

# sort classes

classes = sorted(list(set(classes)))

# documents = combination between patterns and intents

print (len(documents), "documents")

# classes = intents

print (len(classes), "classes", classes)

# words = all words, vocabulary

print (len(words), "unique lemmatized words", words)

pickle.dump(words,open('texts.pkl','wb'))

pickle.dump(classes,open('labels.pkl','wb'))

# create our training data

training = []

# create an empty array for our output

output_empty = [0] * len(classes)

# training set, a bag of words for each sentence

for doc in documents:


# initialize our bag of words

bag = []

# List of tokenized words for the pattern

pattern_words = doc[0]

# lemmatize each word - create a base word, in an attempt to represent related


words

pattern_words = [lemmatizer.lemmatize(word.lower()) for word in


pattern_words]

# create our bag of words array with 1, if a word match is found in the current
pattern

for w in words:

bag.append(1) if w in pattern_words else bag.append(0)

# output is a '0' for each tag and '1' for the current tag (for each pattern)

output_row = list(output_empty)

output_row[classes.index(doc[1])] = 1

training.append([bag, output_row])

# shuffle our features and turn them into np. array

random.shuffle(training)

training = np.array(training)

# create train and test lists. X - patterns, Y - intents

train_x = list(training[:,0])
train_y = list(training[:,1])

print("Training data created")

# Create model - 3 layers. The first layer 128 neurons, the second layer has 64
neurons, and 3rd output layer contains a number of neurons

# equal to the number of intents to predict output intent with softmax

model = Sequential()

model.add(Dense(128, input_shape=(len(train_x[0]),), activation='relu'))

model.add(Dropout(0.5))

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

model.add(Dropout(0.5))

model.add(Dense(len(train_y[0]), activation='softmax'))

# Compile model. Stochastic gradient descent with Nesterov accelerated


gradient gives good results for this model

sgd = SGD(lr=0.01, decay=1e-6, momentum=0.9, nesterov=True)

model.compile(loss='categorical_crossentropy', optimizer=sgd,
metrics=['accuracy'])

#fitting and saving the model

hist = model.fit(np.array(train_x), np.array(train_y), epochs=200, batch_size=5,


verbose=1)
model.save('model.h5', hist)

print("model created")

You might also like