Cannot read properties of undefined (reading 'rows')
- 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
Assessment
This issue has not been assessed yet.