⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pattern.java

📁 The Hopfield model is a distributed model of an associative memory. Neurons are pixels and can take
💻 JAVA
字号:
import java.applet.*;import java.awt.*;import java.lang.*;class Pattern{  int length,blocksize,xsize,ysize;  int pattern[];  public Pattern clone_it()  {    Pattern tmp = new Pattern();    int x;    tmp.pattern = new int[this.length];    for(x=0;x<this.length;x++)    {      tmp.pattern[x] = this.pattern[x];    }    tmp.length = this.length;    tmp.blocksize = this.blocksize;    tmp.xsize = this.xsize;    tmp.ysize = this.ysize;    return(tmp);  }  public void init()  {    int x;    for(x=0;x<length;x++)    {      this.pattern[x] = -1;    }  }  public void init(Pattern pat)  {    this.length = pat.length;    this.blocksize = pat.blocksize;    pattern = new int[length];    this.init();  }  public void init(int xs, int ys)  {    xsize   = xs/blocksize;    ysize   = ys/blocksize;    length  = (int)(xs/blocksize) * (int)(ys/blocksize);    pattern = new int[length];    this.init();  }  public void toggle(int loc)  {    if (loc<length) pattern[loc] = pattern[loc] * -1;  }  public Pattern normalize()  {    int x;    for(x=0;x<this.length;x++)    {      if (this.pattern[x] != 0)      {	this.pattern[x] = (int)(this.pattern[x]/Math.abs(this.pattern[x]));      }    }    return(this);  }  public void randomize()  {    int x;    int y;    for(x=0;x<length;x++)    {      pattern[x] = (int)(2*Math.round(Math.random())-1);    }  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -