使用brain.js神经网络进行文本分析 [英] Use brain.js neural network to do text analysis

查看:137
本文介绍了使用brain.js神经网络进行文本分析的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试进行一些文本分析,以确定给定的字符串是否正在谈论政治.我在想可以创建一个神经网络,其中输入是字符串还是单词列表(排序可能很重要?),输出是字符串是否与政治有关.

I'm trying to do some text analysis to determine if a given string is... talking about politics. I'm thinking I could create a neural network where the input is either a string or a list of words (ordering might matter?) and the output is whether the string is about politics.

但是brain.js库仅接受0到1之间的数字或0到1之间的数字数组的输入.如何以可以完成任务的方式强制数据?

However the brain.js library only takes inputs of a number between 0 and 1 or an array of numbers between 0 and 1. How can I coerce my data in such a way that I can achieve the task?

推荐答案

new brain.recurrent.LSTM(); 

这可以帮到你.

示例

var brain = require('brain.js')
var net = new brain.recurrent.LSTM();
net.train([
  {input: "my unit-tests failed.", output: "software"},
  {input: "tried the program, but it was buggy.", output: "software"},
  {input: "i need a new power supply.", output: "hardware"},
  {input: "the drive has a 2TB capacity.", output: "hardware"},
  {input: "unit-tests", output: "software"},
  {input: "program", output: "software"},
  {input: "power supply", output: "hardware"},
  {input: "drive", output: "hardware"},
]);

console.log("output = "+net.run("drive"));


output = hardware

请参阅此链接=> https://github.com/BrainJS/brain. js/issues/65 这对brain.recurrent.LSTM()有明确的解释和用法

refer to this link=> https://github.com/BrainJS/brain.js/issues/65 this has clear explanation and usage of brain.recurrent.LSTM()

这篇关于使用brain.js神经网络进行文本分析的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆