Source Code for Me (s-c.me)

Allows you to paste souce code to blogs! Adapted for Twitter! Here is Search Form in case you missed your code.
Code:
Selected Language:
Show Linenumbers:
Short link for Twitter:
HTML:

HTML view:

Copy Source | Copy HTML
  1. import TPerceptron
  2. # создаем класс двумерного персептрона
  3. perceptron = TPerceptron.TPerceptron(2)
  4. la =  0.1 # константа обучения
  5. # создаем примеры
  6. T = list()
  7. T.append([[2,1], 1])
  8. T.append([[3,2], 1])
  9. T.append([[4,1], 1])
  10. T.append([[1,2], -1])
  11. T.append([[2,3], -1])
  12. T.append([[5,7], -1])
  13. perceptron.learning(la, T) # обучение персептрона
  14. print(perceptron.w) # печатаем веса
  15. # проверим работу на тестовых примерах
  16. print(perceptron.sign([1.5, 2]))
  17. print(perceptron.sign([3, 1.5]))
  18. print(perceptron.sign([5,1]))
  19. print(perceptron.sign([5,10]))




Based on Manoli.Net's CodeFormatter. Made by Topbot (c) 2008-2018