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

📄 javascript

📁 MATLAB,VB做成的神经网络计算程序
💻
📖 第 1 页 / 共 4 页
字号:
f = nen;
enx = nen;
Instantiate();
pos = 0; // reset.
// Make nen "seq" of its "pre" concept:
if (pre > 0) {
  for (i = t; i>midway; --i) {
    Psi[i].psiExam(); // float the "psi1" identifier.
    if (psi1 == pre) {
      Psi[i] = new psiNode(psi1,psi2,psi3,psi4,nen,psi6);
      break; // Moncur p. 100.
    } // end of inner if-clause 
    psi1 = 0; // reset for safety   
  } // end of backwards loop
} // end of outer if-clause
pre = nen; // So that the next "nen" has a "pre".
if (par > 3) par = 1;
act = 0;
} // end of newConcept()

// stringEffect() is called from Comparator() and
// passes activation from one engram to the next.
function stringEffect() {
  tse = (tdec + 1); // so as to advance one step in auditory memory
  audMemChan[tse].audRecall(); // fetch audEngram at t=tse.
 //   if (gram1.keyCode > 32) act = 8;
     gram2 = (gram2 + 8);
  audMemChan[tse] = new audEngram(gram1,gram2,gram3,gram4,gram5,gram6);
  act = 0; // reset for safety.
}

// Comparator() is called from STM()
// and matches input phonemes against memory,
// reporting back any found move-tag "mt".
// Comparator() only looks at activations,
// and lets stringEffect() change activations.
function Comparator() {
  act = 0; // 12feb2001 -- safety measure
  mt = 0;
  tdec = blankt; // Retro() provides but cannot change "tdec".
  tse = blankt;
  for (i=tdec; i>midway; i--) {
    audMemChan[i].audRecall(); // float the "gram1" phoneme.
    if (gram1 == pho) { // if the engram matches the input character
      act = gram2; // retrieve the currently stored act(ivation)
      if (gram4 == 1) { // if beg(inning) is true...
        act = (act + 8); // either impart or increase "act"
      } // end of if-clause checking for beg==1

      if (act > 0) { // if act(ivation) is positive

        // The next code makes the Comparator more sophisticated by
        // virtue of adding minor activation to sub-recognitions:
        if (gram6 > 0) { // upon sub-recognition of a morpheme
          for (j = tdec; j>midway; j--) { // loop backwards
            Psi[j].psiExam(); // examine each Psi node
              if (psi1 == gram6) {
                psi2 = (psi2 + 1); // add a minimal activation
                Psi[j] = new psiNode(psi1,psi2,psi3,psi4,psi5,psi6);
                psi2 = 0; // reset for safety
              } // end of if-clause testing for sub-rec concepts
          } // end of backwards loop looking for sub-rec Psi nodes
          if (gram5 == 0) { // if the "ctu" flag is set to false
            mt = gram6; // prepare to "move" the ultimate-tag
          } // end of if-clause looking for a non-continuation flag
        } // end of if-clause testing for a sub-rec utg

        stringEffect(); // to pass the "act" one step forward
        act = 0; // reset for safety
      } // end of if-clause looking for positive act(ivation)
    
    } // end of if-clause looking for a match
    tdec = (tdec - 1); // decrementing one unit per loop
  } // end of backwards loop.
} // end of Comparator()


// audRecall() is a method of audEngram()
// and provides access both to pho(nemes)
// stored in audition and their tags/flags.
function audRecall() {
  gram1 = this.pho;
  gram2 = this.act;
  gram3 = this.pov;
  gram4 = this.beg;
  gram5 = this.ctu;
  gram6 = this.utg;
}

// audEngram() is called from Short Term Memory "STM()"
// and other functions which need to create, activate,
// or deactivate an auditory memory engram ("audEngram").
function audEngram(pho,act,pov,beg,ctu,utg) {
  this.pho = pho; // phoneme
  this.act = act; // activation level
  this.pov = pov; // point-of-view: internal/external
  this.beg = beg; // beginning of a word?
  this.ctu = ctu; // continuation of a word?
  this.utg = utg; // ultimate-tag over to a concept
  this.audRecall = audRecall;
}


// STM() is called from Audition() +/- CR()
// and stands for "Short Term Memory":
function STM() {
if (attn > 1) {
Comparator();
}
tult = (t - 1); // the time "t-ultimate".
// See if previous engram was blank:
audMemChan[tult].audRecall();
// possibly use from Usenet: parseInt(act)+8
// after any blank, beg(inning) is primed to be true:
if (gram1 == 0) beg = 1;
audMemChan[t] = new audEngram(pho,0,pov,beg,ctu,utg);
return;
}

// Retro() is called from Audition().
function Retro() {
blankt = t; // since Retro() is called by ASCII blank "32".
tult = (t - 1); // the time "t-ultimate".
audMemChan[tult].audRecall(); // prepare to set "ctu" to zero:
audMemChan[tult] = new audEngram(gram1,gram2,gram3,gram4,0,gram6);
if (mt > 0) { // mt came from Comparator() -- i.e., from "utg"
  rv = onset;
  onset = 0; // reset for safety.
  audMemChan[tult].audRecall(); // Store the move-tag "mt":
  audMemChan[tult] = new audEngram(gram1,gram2,gram3,gram4,gram5,mt);
  oldConcept(); // create node of the recognized old concept "mt".
  mt = 0; // reset for safety
  rv = 0; // reset for safety
  }
else {
  if (len > 0) {
    rv = onset; // from Audition()
    newConcept();  // if word is not recognized, learn a new concept.
   audMemChan[tult].audRecall(); // store new concept ultimate-tag:
   audMemChan[tult] = new audEngram(gram1,gram2,gram3,gram4,gram5,nen);
  } // end of if-clause
} // end of else-clause
audDamp();
len = 0;
rv = 0;
if (eot == 13) par = 1; // reset the parse-flag.
// blankt = t; // 20feb2001 test; put back at start?
return;
}

// CR() is called by the INPUT FORM to
// blank out the INPUT area when the user
// finishes a sentence by pressing [ENTER].
// Code has been added here to create one
// blank audEngram whenever [ENTER] is pressed.
// This function may properly belong in STM().
function CR() {
conversing = false; // until set true again by Audition()
document.forms[0].elements[0].value = "";
if (trouble == true) Troubleshoot();
userline = inbuffer; // transfer, then reset:
inbuffer = ""; // reset for Transcribe()
++t; // Increment "t" before a blank audEngram.
blankt = t; // 20feb2001 test; reconsider/remove
// Use "tov" so as not to interfere with Audition() t.
tov = (t+1); // Update "tov" prior to fresh input.
audMemChan[t] = new audEngram(" ",0," "," "," "," ");
eot = 13; // for use in Audition() to indicate CR.
beg = 1; // no "if CR 13" is required within CR().
c = 32; // as if SPACE-BAR "32" were pressed
Retro(); // ... imitating Audition().
eot = 0;  // code from Mind.Forth Audition
pre = 0; // reset for safety.
attn = 2; // after being 3 during Audition() input.
Voice(); // to clear any Bootstrap message...
if (death == false) aLife();
else deadEnd();
} // end of carriage-return CR() function.


// Ignore() may be called from Audition() after a
// time-delay so as to ignore incomplete user input.
function Ignore() {
if (conversing == true) conversing = false;
// It may be necessary to call carriage-return CR()
// to deal with any partial input that has accrued.
} // end of Ignore().


// Audition() is called automatically when the user
// types a character into the FORM INPUT area, but
// should perhaps also be callable by Sensorium().
function Audition() {
  conversing = true; // a flag for cutOut() and Homunculus()
  attn = 3; // a keystroke automatically commands attention.
  pov = "#"; // symbol to display "external" point-of-view
  document.onkeypress = function (evt) {
    // The next code sets up a special condition
    // of attention where the AI will wait indefinitely for
    // further user input, terminated by a carriage-return CR-13.
    // Let three ("3") be the fullest state of attention,
    // where the AI stops and waits until the user presses [ENTER].
    // Later, code must be written to bypass overly long waits.
    attn = 3; 
    c = event.keyCode;
    if (c == 27) Shutdown(); // on [ESCAPE] key...
    // Let user input bring a dead AI back to life.
    if (c != 27) { // If a key other than [ESCAPE] is pressed...
if (death == true) { // ... and if the AI has been "killed"... 
death = false; // ... give the dead AI another chance to live.
message = ("<font color='navy'>" + "AI alive again." + "<\/font>");
      } // end of inner if-clause
    } // end of outer if-clause
    pho = String.fromCharCode(c);

if (hardcopy == true) { // if Transcript is checked "on"
  inbuffer += pho; // build up the line of user input.  
} // end of if-clause testing for Transcript mode.

  ++t; // immediate increment right now
  if (eot == 13) {
    beg = 1;
    c = 32; // as if SPACE-BAR "32" were pressed
    } // end of if-clause checking for carriage-return
  if (c == 32) Retro();
    beg = 1; // for default only.
    ctu = 1; // a default changed only by Retro().
  // Uppercase for convenience in comparisons:
  pho = pho.toUpperCase();
  onset = (blankt + 1);
  if (onset == t) beg = 1; // ...if a word is beginning...
  else beg = 0; // i.e., not a word-beginning
  // Only call STM if input is higher than SPACE-BAR 32:
  if (c > 32) {
    len = (len + 1); // keep track of length of word
    STM(); // which obtains "mt" from Comparator()
  } // end of if-clause checking for alphabet characters
  c = " "; // Reset for safety, e.g., blank audEngrams.
  pho = " "; // Reset for safety, e.g., blank audEngrams.
    return true;
  }  // test or removing semicolon; remove test
} // end of Audition()


// Sensorium() is being kept in reserve because
// currently the human user usurps the Sensorium()
// function by forcing a reaction to keyboard entry.
function Sensorium() {
//  message = "Sensorium is active.";
//  Voice(); // avoid slowdown
return;
} // end of Sensorium().


// Emotion() is called in sequence by aLife()
// and is stubbed in here for several reasons,
// including to show where it will belong when
// implemented as the impact of a physiological
// response (to whatever) upon a cognitive mind.
// [The AI could show emotion through colors.]
function Emotion() {
if (death == false) {
  document.forms[0].ear.focus(); // await input
  message = "Emotion -- waiting for user input.";
// Voice(); // ... to display the "message"
}
else {
  deadEnd(); // an extra security precaution
  } // end of else-clause
return;
} // end of Emotion()

// flushVector() is called
// by nounPhrase() or Predicate()
// to flush Psi concepts into language.
function flushVector() {
act = 0;
// 7feb2001 -- in the next code, we drop the start of
// the search back from t or (t+1) to time-of-voice "tov"
// so that only pre-existing engram nodes prior to
// current generation will govern the generation.
for (i = tov; i>midway; --i) {
  Psi[i].psiExam(); // inspect psi2 (act)ivation
  if (psi2 > 0) {
    act = psi2; // get the activation level and...
    enx = psi6; // ... the transfer-to-English flag.
    if (enx > 0) {
      // 9feb2001 -- "j" so as not to influence "i":
      for (j = (t + 1); j>midway; --j) {
        enLexicon[j].enExam(); // inspect English nodes
        if (en1 == enx) {
          if (act >= en2) { // Moncur p. 87.
            enLexicon[i] = new enNode(en1,act,en3,en4,en5,en6);
          } // end of fourth-deep if-clause
        } // end of third-deep if-clause
      } // end of inner backwards loop through Psi
      enx = 0;
      act = 0;
    } // end of second-deep if-clause
  } // end of outer if-clause
} // end of outer backwards loop through Psi
act = 0;
} // end of flushVector()


// reEntry() is called from Speech() so as
// to bypass the actual input keypresses that
// normally call the Audition() module.
function reEntry() {
// attn  3 is when human input has begun but not ended;
  attn = 2; // reEntry() has not yet finished;
// attn  1 is for when the AI is thinking.

⌨️ 快捷键说明

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