Chapter IV

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

CHAPTER IV

SYSTEM DESIGN

System Design is the process of defining the architecture, components, modules,

and data of a system to satisfy the specified requirements. It can be considered as the

intermediate stage between System Analysis and Product Development where the

analyses that have been made in the previous chapter are now visualized in detail. The

application comprises of four sections: user interface design, physical design, data

design, and class diagram.

4.1 User Interface Design

User interface design is one of the important components of any application, be it

a desktop or a web application. The user interface will allow users to use the application

easily. As the developed program is a neural network agent that is trained to play Atari

games, no user interface is created in this study. The result of the training will be shown

through the video created during the training session.

4.2 Physical Design

Physical Design defines the minimum requirements of software and hardware

used in development process to ensure that the created application runs without problems.

Table

40
41

4.1 and 4.2 below show respectively the software and hardware requirements to runs this

application.

Table 4.1 Software Requirements

No Field Description
1 Operating System Windows 10 Education
2 Programming Language Python
3 Program Development JetBrains PyCharm Professional 2019.2.1
Google Colaboratory
4 Documentation Microsoft Word 2019

Table 4.2 Hardware Requirements

No Field Description
1 Processor Minimum requirement: Intel Core i series
2 Memory Minimum requirement: 12GB of RAM
3 Monitor Minimum requirement: Resolution 1280x720
4 Hard Drive Minimum requirement: Free space of 100 MB

4.3 Data Design

Database is not needed in this application as the application purpose is only to

train the agent to be excel in a specific game environment. Two checkpoint (.h5) data are

generated, one is to save the training weights for every iteration and the other is created

when highest average score is calculated. The last two data generated by the system are

the
42

preprocessed environment file, which is an image format file (.png), and a video file of the

game episode. Table 4.3 below depict the data design for the application.

Table 4.3 The Data Design

No Filename Content Description


The training checkpoint for a defined
1 checkpoint.h5
number of iterations
The [high_avg_score] is filled with the
2 [high_avg_score]_best.h5
actual high score that the agent received
3 preprocessed.png The preprocessed environment data
The video file generated by the open ai
4 openaigym.video.mp4
gym library

4.4 Class Diagram

A class diagram, as specified in UML, is a static diagram that describes the

classes of a system. Classes here are classes in Object Oriented Programming context

which displayed with its attributes, methods, and relations with other classes. Class

diagram of this application is shown in figure 4.1.


43

Figure 4.1 The Class Diagram

Two classes, DQ_Network and Agent, are used in this application. The further

explanation of each class will be explained below:

a. DQ_Network Class

The DQ_Network Class main purpose is to build a Convolutional Neural Network

for the agent. There exist nine properties to define this class which are:

o total_action

The total_action stands for a number of actions that the agent could take in the

specific environment.
44

o learning_rate

The learning_rate is a variable which hold a floating-point value from 0 to 1

that defines the learning speed of the agent.

o batch_size

The batch_size is a variable whichhold an integer number defining the batch

size in the Keras’s fit function.

o discount_factor

The discount_factor is a variable which hold a floating-point value from 0 to 1

that defines the agent’s behavior in considering long-term or short-term

reward of the agent.

o input_dimension

The input_dimension is a variable which hold a three-dimensional array (row,

column, channel) that defines the game’s frame size. It will be utilized as an

input for the neural network.

o load_path

The load_path is a variable which hold a string that contains the checkpoint’s

file path.

o checkpoint

The checkpoint holds the Keras’s checkpoint function to save the agent’s

training result per epoch.


45

o model

The model holds the main neural network model that is initialized by

build_network() function.

o target_model

The model holds the target neural network model that is initialized by

build_network() function.

Four methods of the DQ_Network class are explained below:

o init

The init method overwrite the class’s default initializer. It is utilized to

initialize the class’s properties.

o build_network

The build_network method is the core method of this class where the neural

network is configured.

o train

The train method holds the main algorithm of the Deep Q Network with

Experience Replay.

o predict

The predict method returns the prediction result of the neural network.
46

b. Agent Class

The Agent Class represent the agent with the neural networks. Agent stores the

main algorithm parameters included the experiences memory. The mechanism of

memory storing, action choosing, sampling experience, updating epsilon, and

learning is defined in this function. There exist eleven properties that is created

for the Agent Class which are:

o total_action

The total_action stands for a number of actions that the agent could take in the

specific environment.

o learning_rate

The learning_rate is a variable which hold a floating-point value from 0 to 1

that defines the learning speed of the agent.

o input_dimension

The input_dimension is a variable which hold a three-dimensional array (row,

column, channel) that defines the game’s frame size. It will be utilized as an

input for the neural network.

o discount_factor

The discount_factor is a variable which hold a floating-point value from 0 to 1

that defines the agent’s behavior in considering long-term or short-term

reward of the agent.


47

o epsilon

The epsilon stores a floating-point value between 0 and 1 to determine the agent

characteristics to either explore or exploit the taken action.

o epsilon_decay

The epsilon_decay stores a floating-point value to control the epsilon’s value in

by decreasing the epsilon over the gameplay session.

o load_path

The load_path is a variable which hold a string that contains the checkpoint’s

file path.

o batch_size

The batch_size is a variable whichhold an integer number defining the batch

size in the Keras’s fit function.

o memory_size

The memory_size defines the memory size that the agent could hold.

o memory

The memory stored the gameplay experience in an array.

o training_count

The training _count is a counter to track the training progression.

Six methods in the Agent Class are explained below:


48

o init

The init method overwrite the class’s default initializer. It is utilized

to initialize the class’s properties.

o store_transition

The store_transition method is utilized to save the taken action result in the

agent’ memory.

o choose_action

The choose_action method is used to determine whether the agent should

explore or exploit the environment.

o update_epsilon

The update_epsilon method is used to handle the epsilon decay overtime

mechanism.

o sample_exp_batch

The sample_exp_batch method randomly samples a number of stored

experiences from the agent’s memory that will be feeds into the neural

network.

o max_q

The max_q method is utilized to get the maximum q value for testing purposes.

o learn

The learn method is the method where the network will be run and the Q-

values will be updated.


49

You might also like