-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
48 lines (43 loc) · 1.09 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import cors from 'cors'
import express from 'express'
import morgan from 'morgan'
import Agent from './d3ql/agent.js'
import routes from './routes.js'
const agentSettings = {
epsilon: 1, // Exploration rate
epsilonDecay: 0.00005, // Exploration decay
epsilonMin: 0.01, // Exploration minimum
gamma: 0.95, // Discount factor
tau: 1000, // Update of target network
memory: {
batchSize: 64,
cer: true, // Combined experience replay
size: 100000
},
network: {
alpha: 0.00025, // Learning rate
inputSize: 5,
layers: [
// Hidden layers
{ activation: 'relu', units: 64 },
{ activation: 'relu', units: 64 }
],
outputSize: 3
}
}
const app = express()
app.set('agent', new Agent({ settings: agentSettings }))
app.use(cors())
app.use(express.json())
if (app.get('env') === 'development') {
app.use(
morgan('dev', {
skip: (request, response) => response.statusCode === 200
})
)
}
app.use('/', routes)
app.use((request, response) => response.sendStatus(404))
const port = 5000
app.listen(port)
console.log(`Agent listening on port ${port}`)