Skip to content

Commit

Permalink
Reduce iterations
Browse files Browse the repository at this point in the history
  • Loading branch information
wizawu committed Nov 14, 2023
1 parent b0f5a1f commit 560fe3d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 47 deletions.
84 changes: 42 additions & 42 deletions roles/socks/files/model.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,64 @@
{
"weights": [
[
9.254154205322266,
3.226205825805664,
-0.10864460468292236,
-0.7786291241645813,
1.0749684572219849,
0.7949228882789612,
2.1225788593292236,
1.516159176826477
-1.601542592048645,
0.280438095331192,
-0.3370862603187561,
5.825273036956787,
-0.10501962155103683,
0.19559019804000854,
-2.3855350017547607,
-3.8312666416168213
],
[
-2.2315673828125,
-0.4349869191646576,
-0.9913473129272461,
5.486702919006348,
-2.222933292388916,
6.3236212730407715,
-2.160618305206299,
4.335207462310791
-82.07138061523438,
-1.832046389579773,
3.3260951042175293,
-0.04208007827401161,
0.2720280885696411,
-0.5344769358634949,
23.249326705932617,
-2.0852396488189697
],
[
3.649057626724243,
0.7811000347137451,
0.18399403989315033,
0.8720407485961914,
0.4192882180213928,
-1.1314951181411743,
1.2625271081924438,
-1.783936619758606
8.754728317260742,
-1.863292932510376,
0.6677490472793579,
-3.4426403045654297,
0.70823073387146,
-0.07435189932584763,
6.056069850921631,
-0.02483324147760868
],
[
-3.9054038524627686,
-3.3554959297180176,
1.6739517450332642,
2.4722161293029785,
-0.12326213717460632,
-1.036186695098877,
2.8382656574249268,
-2.441895008087158
16.52118492126465,
1.4305920600891113,
-0.8690280914306641,
-0.46929383277893066,
1.4635859727859497,
0.38055717945098877,
4.6355791091918945,
0.6447180509567261
]
],
"biases": [
-3.4684717655181885,
0.47295334935188293,
-2.953230619430542,
3.0617027282714844
-2.0559568405151367,
3.6629557609558105,
6.309120178222656,
-4.285314083099365
]
},
{
"weights": [
[
3.192861557006836,
1.744760274887085,
-0.8989359736442566,
-3.640486240386963
10.071906089782715,
-12.097213745117188,
-8.988085746765137,
12.723011016845703
]
],
"biases": [
-2.5797712802886963
5.716348171234131
]
}
],
Expand All @@ -85,7 +85,7 @@
},
"trainOpts": {
"activation": "sigmoid",
"iterations": 80000,
"iterations": 20000,
"errorThresh": 0.005,
"log": true,
"logPeriod": 1000,
Expand Down
2 changes: 1 addition & 1 deletion roles/socks/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"scripts": {
"build": "tsc main.ts",
"start": "npm run build && node main.js",
"write": "npm run build && node -e 'require(\"./train.js\").writeData(22); process.exit()'",
"write": "npm run build && node -e 'require(\"./train.js\").writeData(23); process.exit()'",
"train": "npm run build && rm -f model.json && node -e 'require(\"./train.js\").train(); process.exit()'"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion roles/socks/files/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const log = LoggerFactory.getLogger("\t\b\b\b\b\b\b\b")

let online = true
setInterval(() => {
const child = spawnSync("curl", "-I -L -m 3 http://223.5.5.5/".split(" "))
const child = spawnSync("curl", "-I -m 5 http://223.5.5.5/".split(" "))
online = child.status === 0
if (!online) {
log.warn("I am offline")
Expand Down
6 changes: 3 additions & 3 deletions roles/socks/files/train.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const log = LoggerFactory.getLogger("\t\b\b\b\b\b\b\b")
log.level = "debug"

const data = [
...JSON.parse(fs.readFileSync("./data.19.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.20.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.21.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.22.json", "utf-8")),
...JSON.parse(fs.readFileSync("./data.23.json", "utf-8")),
]

const net = new brain.NeuralNetwork()
Expand All @@ -35,7 +35,7 @@ export function train() {
output: [it.prefer],
})),
{
iterations: 80000,
iterations: 20000,
log: it => log.debug(it),
logPeriod: 1000,
learningRate: 0.1,
Expand Down Expand Up @@ -75,7 +75,7 @@ export function writeData(i: number): void {
if (whiteList.includes(site)) {
prefer = 0
} else if (blackList.includes(site)) {
prefer = 1
prefer = 9
}
buffer.push(JSON.stringify({ site, err0, err1, spd0, spd1, blk0, blk1, bw0, bw1, prefer }))
})
Expand Down

0 comments on commit 560fe3d

Please sign in to comment.