(IA) Perceptron . . .

Iniciado por **Aincrad**, 3 Octubre 2017, 21:27 PM

0 Miembros y 1 Visitante están viendo este tema.

**Aincrad**

hola a todos, abro este tema para al que le interese.  ;D
[youtube=0,0]https://www.youtube.com/watch?v=3Llu1qGJF1I[/youtube]
bueno empecemos.

que es un (AI)?

Inteligencia artificial, o AI. La inteligencia artificial (Artificial Intelligence, o AI) es la simulación de procesos de inteligencia humana por parte de máquinas, especialmente sistemas informáticos.

que es Perceptron?

El perceptrón multicapa es una red neuronal artificial (RNA) formada por múltiples capas, esto le permite resolver problemas que no son linealmente separables, lo cual es la principal limitación del perceptrón (también llamado perceptrón simple). El perceptrón multicapa puede ser totalmente o localmente conectado.

En pocas palabras el perceptron es la simulación de una neurona humana.



EN ESTE ESQUEMA DE PERCEPTOM SIMPLI SE PUEDE APRECIAR . QUE SE INCLUYE LA PARTE SENSORIAL.

con esta parte podemos apreciar que el desarrollo de una IA nunca estara completa si no tiene como sentir.  ya que muchos Psicólogos  han demostrado que por medio de las experiencias sensiorales el cerebro aprende.

ejemplo de perceptron :  

bach

Código (bash) [Seleccionar]
@echo off
rem Perceptron en batch
rem por S4L
rem 14/04/12
color a
setlocal EnableDelayedExpansion
setlocal EnableExtensions
set me=%0
cscript.exe //H:cscript
:::::::::::::::::::::::::::::::::::
set Fgh=fghijklmnopqrstuvwxz
set T=0.5
set Alpha=0.1
set iNn=3
set oNut=1
set TSName="NAND Gate"
set TxSet=4
set TySet=4
set TSet.1=1,0,0,1
set TSet.2=1,0,1,1
set TSet.3=1,1,0,1
set TSet.4=1,1,1,0
set WxSet=1
set WySet=3
set WSet.1=0
set WSet.2=0
set WSet.3=0
:::::::::::::::::::::::::::::::::::

echo Randomize>eval.vbs
echo set objArgs = WScript.Arguments>>eval.vbs
echo wscript.echo eval(objArgs(0))>>eval.vbs
set Run=True
rem for /l %%a in (1,1,%WySet%) do (
rem call:SetEv WSet.%%a Rnd
rem )
set /a Tf=2+%iNn%+%oNut%
set vfIn=%%%%g
for /l %%a in (2,1,%iNn%) do (
set vfIn=!vfIn!,%%%%!Fgh:~%%a,1!
)
set /a vfOut_ini=1+%iNn%
set /a fOut=%vfOut_ini%-%oNut%
set vfOut=%%%%!Fgh:~%vfOut_ini%,1!
for /l %%a in (%vfOut_ini%,1,%fOut%) do (
set vfOut=!vfout!,%%%%!Fgh:~%%a,1!
)
set str=Fo
find "%str%r1"<%me%>stFor.bat
echo set In.%%%%f=%vfIn%>>stFor.bat
echo set Out.%%%%f=%vfOut%>>stFor.bat
echo ^)>>stFor.bat
call stFor
echo --Training Started--
:train
set Run=False
for /l %%a in (1,1,%TySet%) do (
echo.
(set/p av=Training.)<nul
call:pre_Sum %%a
call:UpdateW %%a
)
if %Run%==True goto:train
:test
echo.
echo --%TSName% network succesfully trained!--
echo --Testing--
for /l %%a in (1,1,%iNn%) do (
set /p iNn%%a=Input %%a ^(1/0^)?
)
call:PSum
echo Network output=%out%
set /p cnt=Continue testing ^(y/n^)?
if %cnt%'==y' goto:test
if %cnt%'==Y' goto:test
goto:eof

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

:UpdateW
set /a error=!Out.%1!-%out%
if not %error%==0 set Run=True
call:SetEv C %error%*%Alpha%
(set/p av=.)<nul
(set/p av="  E=%error% W1=%WSet.1% W2=%WSet.2% W3=%WSet.3%")<nul
for /l %%b in (1,1,%WySet%) do (
call:SetEv WSet.%%b !WSet.%%b!+!iNn%%b!*!C!
)
goto:eof

:pre_Sum
set str2=I
set In.>In.
find "%str2%n.%1"<In.>aIn.
find "%str%r2"<%me%>stFor_In.bat
for /l %%a in (1,1,%iNn%) do (
echo set iNn%%a=%%%%!Fgh:~%%a,1!>>stFor_In.bat
(set/p av=.)<nul
)
(set/p av=.)<nul
echo ^)>>stFor_In.bat
call stFor_In
call:PSum %1
goto:eof

:PSum
set sum=0
for /l %%a in (1,1,%iNn%) do (
call:SetEv sum !sum!+!iNn%%a!*!WSet.%%a!
)
if /I %sum% gtr %T% (
set out=1
) else (
set out=0
)
goto:eof

:SetEv
for /f %%i in ('eval //nologo "%2"') do set %1=%%i
goto:eof

for /f "tokens=2-%Tf% delims=.,=" %%f in ('set TSet.') do ( %For1%
for /f "tokens=2-%Tf% delims=.,=" %%f in (aIn.) do ( %For2%


para los de c++ les dejo el link:

https://www.facebook.com/TutorialesKatana/?sk=app_190322544333196

http://www.mundoprogramacion.com/colabora/puntoNET/jlopezi_RedNeuronal.htm


 si se preguntan todavía que finalidad tiene este tema. ni yo mismo lo se . jajaja.

bueno abrí este tema para los que esten desarrollando alguna AI O los quieran desarrollar.
                       
COMENTEN sus aporte sobre IA un este tema




<Trocutor>


**Aincrad**

Interesante . bueno en python encontre este chatbot . en idioma ingles. se supone que aprende las palabras mientras tu hablas con el .

code:

Código (python) [Seleccionar]
import re
import sqlite3
from collections import Counter
from string import punctuation
from math import sqrt

# initialize the connection to the database
connection = sqlite3.connect('chatbot.sqlite')
cursor = connection.cursor()

# create the tables needed by the program
create_table_request_list = [
    'CREATE TABLE words(word TEXT UNIQUE)',
    'CREATE TABLE sentences(sentence TEXT UNIQUE, used INT NOT NULL DEFAULT 0)',
    'CREATE TABLE associations (word_id INT NOT NULL, sentence_id INT NOT NULL, weight REAL NOT NULL)',
]
for create_table_request in create_table_request_list:
    try:
        cursor.execute(create_table_request)
    except:
        pass

def get_id(entityName, text):
    """Retrieve an entity's unique ID from the database, given its associated text.
    If the row is not already present, it is inserted.
    The entity can either be a sentence or a word."""
    tableName = entityName + 's'
    columnName = entityName
    cursor.execute('SELECT rowid FROM ' + tableName + ' WHERE ' + columnName + ' = ?', (text,))
    row = cursor.fetchone()
    if row:
        return row[0]
    else:
        cursor.execute('INSERT INTO ' + tableName + ' (' + columnName + ') VALUES (?)', (text,))
        return cursor.lastrowid

def get_words(text):
    """Retrieve the words present in a given string of text.
    The return value is a list of tuples where the first member is a lowercase word,
    and the second member the number of time it is present in the text."""
    wordsRegexpString = '(?:\w+|[' + re.escape(punctuation) + ']+)'
    wordsRegexp = re.compile(wordsRegexpString)
    wordsList = wordsRegexp.findall(text.lower())
    return Counter(wordsList).items()


B = 'Hello!'
while True:
    # output bot's message
    print('B: ' + B)
    # ask for user input; if blank line, exit the loop
    H = raw_input('H: ').strip()
    if H == '':
        break
    # store the association between the bot's message words and the user's response
    words = get_words(B)
    words_length = sum([n * len(word) for word, n in words])
    sentence_id = get_id('sentence', H)
    for word, n in words:
        word_id = get_id('word', word)
        weight = sqrt(n / float(words_length))
        cursor.execute('INSERT INTO associations VALUES (?, ?, ?)', (word_id, sentence_id, weight))
    connection.commit()
    # retrieve the most likely answer from the database
    cursor.execute('CREATE TEMPORARY TABLE results(sentence_id INT, sentence TEXT, weight REAL)')
    words = get_words(H)
    words_length = sum([n * len(word) for word, n in words])
    for word, n in words:
        weight = sqrt(n / float(words_length))
        cursor.execute('INSERT INTO results SELECT associations.sentence_id, sentences.sentence, ?*associations.weight/(4+sentences.used) FROM words INNER JOIN associations ON associations.word_id=words.rowid INNER JOIN sentences ON sentences.rowid=associations.sentence_id WHERE words.word=?', (weight, word,))
    # if matches were found, give the best one
    cursor.execute('SELECT sentence_id, sentence, SUM(weight) AS sum_weight FROM results GROUP BY sentence_id ORDER BY sum_weight DESC LIMIT 1')
    row = cursor.fetchone()
    cursor.execute('DROP TABLE results')
    # otherwise, just randomly pick one of the least used sentences
    if row is None:
        cursor.execute('SELECT rowid, sentence FROM sentences WHERE used = (SELECT MIN(used) FROM sentences) ORDER BY RANDOM() LIMIT 1')
        row = cursor.fetchone()
    # tell the database the sentence has been used once more, and prepare the sentence
    B = row[1]
    cursor.execute('UPDATE sentences SET used=used+1 WHERE rowid=?', (row[0],))




bajo0123