javascript_你好它JavaScript

javascript

There are lots of programming languages, and of course, you can do anything in those languages. But javascript shares more value when it comes to popularity, flexibility, and easy to learn.

有很多编程语言,当然,您可以使用这些语言做任何事情。 但是,在普及性,灵活性和易学性方面,javascript具有更多的价值。

It is a language that browsers can understand and the only language for the WEB. It is lightweight and interpreted.

它是浏览器可以理解的语言,并且是WEB的唯一语言。 它是轻量级的并且可以解释。

Initially, javascript was supposed to run on the server but it gets more popularity when integrated to the browser. Now, it is again become a part of the server-side, thanks to some run time environments like NodeJS.

最初,javascript应该在服务器上运行,但是当集成到浏览器时,它会变得更加流行。 现在,由于某些运行时环境(例如NodeJS) ,它再次成为服务器端的一部分。

But its power not remain there. We can do many more things with Javascript. We can create large web applications, simple 2D graphs to the high-end 3D graphics, 3D games, artificial intelligence applications, just to point a few.

但是它的力量并不存在。 我们可以使用Javascript做更多的事情。 我们可以创建大型Web应用程序,用于高端3D图形的简单2D图形,3D游戏,人工智能应用程序,仅举几例。

Today we will create a simple neural network experiment by using a great neural network library Brain.js.

今天,我们将使用强大的神经网络库Brain.js创建一个简单的神经网络实验。

Brain.js

Brain.js

Brain.js is a GPU accelerated library of neural networks written in Javascript for browsers and run time environments. It learns the patterns and relationships between the data provided in order to make predictions.

Brain.js是GPU加速的神经网络库,用Javascript编写,适用于浏览器和运行时环境。 它学习提供的数据之间的模式和关系以进行预测。

Neural Network

神经网络

A neural network is a mathematical model that mimics the behavior of biological neural networks.

神经网络是模仿生物神经网络行为的数学模型。

Here we are not going in a deep understanding of the theoretical concepts of the AI or Javascript.

在这里,我们不会深入了解AI或Javascript的理论概念。

所以我们开始吧 (So let’s start)

Today we are building a simple neural network experiment that predicts the time when input meal is provided.

今天,我们正在构建一个简单的神经网络实验,该实验可以预测提供进餐的时间。

You just need to be familiar with javascript to follow this article:

您只需要熟悉javascript即可关注本文:

create NodeJS project

创建NodeJS项目

npm init

npm初始化

Provide all the information or you can skip those

提供所有信息,也可以跳过这些信息

Install Brain.js

安装Brain.js

npm install brain.js

npm安装brain.js

create index.js file

创建index.js文件

add the following code

添加以下代码

import the Brain.js library

导入Brain.js库

let brain = require(“brain.js”);

让大脑= require(“ brain.js”);

create a neural network

创建一个神经网络

let neuralNetwork = new brain.NeuralNetwork();

让NeuroNetwork =新大脑。NeuralNetwork();

Our sample data to train this is a network contains foods: milk, tea, bread, chapati, curd, rice, veggies, and there is four possible output: morning, afternoon, evening and night.

我们用来训练该网络的样本数据包含食物:牛奶,茶,面包,薄煎饼,凝乳,米饭,蔬菜,并且有四个可能的输出:上午,下午,晚上和晚上。

Here we are using only four sample inputs for training which is very less to get high accuracy, but you can add as many as you want. This is just to implement the concept. The value 1 means we have that and 0 means we haven’t, the output is the time. You can add as many samples as you want to improve the high accuracy.

在这里,我们仅使用四个样本输入进行训练,要获得高精度,这很少,但是您可以根据需要添加任意数量。 这仅仅是为了实现这个概念。 值1表示我们有,而值0表示我们没有,输出是时间。 您可以添加任意数量的样本以提高高精度。

Image for post
Training Data
训练数据

train the neural network

训练神经网络

neuralNetwork.train(trainingData);

neuroNetwork.train(trainingData);

Now our network is trained with the data. Let’s provide input for prediction.

现在,我们的网络已接受数据培训。 让我们提供预测的输入。

Image for post
run neural network
运行神经网络

The output is

输出是

Image for post
predicted output
预测输出

Here the most probable output is evening. The value is very low at accuracy because we have very little data for prediction. For demonstration purposes, it’s OK to have fewer data.

这里最可能的输出是傍晚。 该值的准确性非常低,因为我们只有很少的数据可以预测。 出于演示目的,可以减少数据量。

So we have just done with this experiment in javascript.

因此,我们刚刚使用javascript完成了此实验。

非常简单,对! (It’s very easy, Right!)

You just created an awesome and simple neural network experiment to predict the time based on the meal.

您刚刚创建了一个很棒的简单神经网络实验来根据用餐时间预测时间。

You can find the full source code on Github

您可以在Github上找到完整的源代码

I hope you enjoyed it.

我希望你喜欢它。

翻译自: https://medium.com/@hrp03/hello-its-javascript-d6236e7a3b8e

javascript

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值