SlideShare una empresa de Scribd logo
1 de 10
Descargar para leer sin conexión
REDES NEURAIS
SOBRE ESTA REDE NEURAL
•Perceptron
•Apenas um nó (neuron)
•Usa regressão linear
O QUE ELA FAZ?
• Exemplo: Ir em uma viagem
Uma tupla é gerada conforme
as perguntas:
[ Tem amigos para ir junto?,
A passagem está cara?,
O meio de transporte é
seguro? ]
• input: [1, 0, 0]
oEsta pessoa Vai[1] com amigos,
oA passagem Não[0] está cara,
oO meio de transporte Não[0] é seguro
• output: [0]
oEsta pessoa Não[0] deve viajar
Esta rede neural responde com SIM[1] ou NÃO[0]
com base em 3 Entrada[inputs] e 3 Pesos.
INICIALIZAÇÃO
#Base de dados
inputs = [[0, 0, 1], [1, 0, 1], [1, 1, 1], [1, 1, 0]]
target = [1, 1, 0, 0]
#Inicialização das variaveis---#
peso = [0, 0, 0]
delta_peso = [0, 0, 0]
vies = 0
delta_vies = 0
lr = 0.1
voltas = 2
y_input = [0, 0, 0, 0]
Participantes = len(inputs)
#------------------------------#
REGRESSÃO LINEAR
#Somatoria de [input * peso]
def neuron(inputx):
z = 0
for i in range(len(inputx)):
x = inputx[i] * peso[i]
z += x
return z + vies
ATIVAÇÃO
#Retorna a resposta Sim[1] ou Não[0]
def ativacao(fi):
if(fi > 0):
return 1
elif (fi <= 0):
return 0
TREINAMENTO
#Treina a rede neural com loops
def treinamento(inputx, targetx, y_inputx):
global delta_vies, vies
for i in range(0, len(inputx)):
delta_peso[i] = lr * (targetx - y_inputx) * inputx[i]
peso[i] += delta_peso[i]
#Atualiza o vies
delta_vies = lr * (targetx - y_inputx) * 1
vies += delta_vies
TREINAMENTO
#Etapa de trinamento, se a rede neural errar, ela treina ate
acertar.
for i in range(voltas):
for j in range(participantes):
y_input[j] = ativacao(neuron(inputs[j]))
if (y_input[j] != target[j]):
treinamento(inputs[j], target[j], y_input[j])
j = 0
TESTE
#Novos dados para verificar se a rede neural esta pronta
[1, 0, 0] -> [Tem amigos, A passagem não esta cara, o Transporte não é seguro]
logo [0] Não vai
[0, 0, 1] -> [Não tem amigos, A passagem não esta cara, o Transporte é Seguro]
logo [1] Vai
[1, 1, 1] -> [Tem amigos, A passagem está cara, o Transporte é seguro]
logo [0] Não vai
print("n")
input_n = [[1, 0, 0], [0, 0, 1], [1, 1, 1]]
print(ativacao(neuron(input_n[0])))
print(ativacao(neuron(input_n[1])))
print(ativacao(neuron(input_n[2])))
OUTPUT

Más contenido relacionado

Destacado

ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationErica Santiago
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellSaba Software
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming LanguageSimplilearn
 
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...Palo Alto Software
 
9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free VacationWeekdone.com
 
I Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceEmpowered Presentations
 
How to Map Your Future
How to Map Your FutureHow to Map Your Future
How to Map Your FutureSlideShop.com
 

Destacado (20)

ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 
Barbie - Brand Strategy Presentation
Barbie - Brand Strategy PresentationBarbie - Brand Strategy Presentation
Barbie - Brand Strategy Presentation
 
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them wellGood Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
Good Stuff Happens in 1:1 Meetings: Why you need them and how to do them well
 
Introduction to C Programming Language
Introduction to C Programming LanguageIntroduction to C Programming Language
Introduction to C Programming Language
 
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
The Pixar Way: 37 Quotes on Developing and Maintaining a Creative Company (fr...
 
9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation9 Tips for a Work-free Vacation
9 Tips for a Work-free Vacation
 
I Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from PrinceI Rock Therefore I Am. 20 Legendary Quotes from Prince
I Rock Therefore I Am. 20 Legendary Quotes from Prince
 
How to Map Your Future
How to Map Your FutureHow to Map Your Future
How to Map Your Future
 

Redes neurais.pptx

  • 2. SOBRE ESTA REDE NEURAL •Perceptron •Apenas um nó (neuron) •Usa regressão linear
  • 3. O QUE ELA FAZ? • Exemplo: Ir em uma viagem Uma tupla é gerada conforme as perguntas: [ Tem amigos para ir junto?, A passagem está cara?, O meio de transporte é seguro? ] • input: [1, 0, 0] oEsta pessoa Vai[1] com amigos, oA passagem Não[0] está cara, oO meio de transporte Não[0] é seguro • output: [0] oEsta pessoa Não[0] deve viajar Esta rede neural responde com SIM[1] ou NÃO[0] com base em 3 Entrada[inputs] e 3 Pesos.
  • 4. INICIALIZAÇÃO #Base de dados inputs = [[0, 0, 1], [1, 0, 1], [1, 1, 1], [1, 1, 0]] target = [1, 1, 0, 0] #Inicialização das variaveis---# peso = [0, 0, 0] delta_peso = [0, 0, 0] vies = 0 delta_vies = 0 lr = 0.1 voltas = 2 y_input = [0, 0, 0, 0] Participantes = len(inputs) #------------------------------#
  • 5. REGRESSÃO LINEAR #Somatoria de [input * peso] def neuron(inputx): z = 0 for i in range(len(inputx)): x = inputx[i] * peso[i] z += x return z + vies
  • 6. ATIVAÇÃO #Retorna a resposta Sim[1] ou Não[0] def ativacao(fi): if(fi > 0): return 1 elif (fi <= 0): return 0
  • 7. TREINAMENTO #Treina a rede neural com loops def treinamento(inputx, targetx, y_inputx): global delta_vies, vies for i in range(0, len(inputx)): delta_peso[i] = lr * (targetx - y_inputx) * inputx[i] peso[i] += delta_peso[i] #Atualiza o vies delta_vies = lr * (targetx - y_inputx) * 1 vies += delta_vies
  • 8. TREINAMENTO #Etapa de trinamento, se a rede neural errar, ela treina ate acertar. for i in range(voltas): for j in range(participantes): y_input[j] = ativacao(neuron(inputs[j])) if (y_input[j] != target[j]): treinamento(inputs[j], target[j], y_input[j]) j = 0
  • 9. TESTE #Novos dados para verificar se a rede neural esta pronta [1, 0, 0] -> [Tem amigos, A passagem não esta cara, o Transporte não é seguro] logo [0] Não vai [0, 0, 1] -> [Não tem amigos, A passagem não esta cara, o Transporte é Seguro] logo [1] Vai [1, 1, 1] -> [Tem amigos, A passagem está cara, o Transporte é seguro] logo [0] Não vai print("n") input_n = [[1, 0, 0], [0, 0, 1], [1, 1, 1]] print(ativacao(neuron(input_n[0]))) print(ativacao(neuron(input_n[1]))) print(ativacao(neuron(input_n[2])))