BrainJS / BrainJS/brain.js

Cannot read properties of undefined (reading 'rows')

Open
#889 1 comment 0 reactions 1 assignee Claimed by @robertleeplummerjr View on GitHub
bug
Dominant language
TypeScript
Stars
14.9k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

Im trying to make a chat bot but I keep getting an error when I try and start it so it will learn

Code:
```js
const fs = require('fs')
const readline = require('readline')
const brain = require('brain.js')
const net = new brain.recurrent.LSTM()

const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
})

const array = []

fs.readFile('learned.json', (err, data) => {
if(err) return console.log(err)

if(data.toString() === '') {
console.log('Network already trained.')
train()
} else {
net.fromJSON(JSON.parse(data.toString()))
boot()
}
})

const train = () => {
console.log('Training...')
const d = new Date()
fs.readFile('essay.txt', (err, data) => {
array = data.toString().split('.')
net.train(array, {
iterations: 20000,
log: true,
errorThresh: 0.01
})
fs.writeFile('learned.JSON', JSON.stringify(net.toJSON()))
console.log(`Training finished in ${(new Date() - d) / 1000} s`)
})
}

const boot = () => {
rl.question('Enter: ', (q) => {
console.log(net.run(q))
boot()
})
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.