홈>
기계 학습을 더 잘 이해하기 위해이 코드를 작성했지만 올바른 길을 가고 있는지 잘 모르겠습니다. 지금까지 파이썬 3.7을 사용하여 화면 전체에 무작위 구불 구불 한 선을 그립니다.
import turtle
import random
# Sets the Turtle main screen color
turtle.bgcolor("pink")
# Settings for bug sprite
bug = turtle.Turtle()
bug.penup()
bug.color("red")
bug_x = bug.setx(-150)
bug_y = bug.sety(12)
bug.pendown()
# Settings for food sprite
food = turtle.Turtle()
food.penup()
food.color("green")
food_x = food.setx(160)
food_y = food.sety(59)
food.pendown()
# Main Loop
while True:
# X and Y coordinate of Food
destination = [160,59]
# X and Y coordinate of Bug
x_1 = bug.xcor()
y_1 = bug.ycor()
origin = [x_1,y_1]
learn = .10
bias = 0
# Weights
wghts = [random.uniform(-1,1),random.uniform(-1,1),random.uniform(-1,1),
random.uniform(-1,1),random.uniform(-1,1),random.uniform(-1,1)]
#print(wghts)
# Output Neurons
output_1 = (wghts[0] * origin[0]) + (wghts[1] * origin[1]) + bias
output_2 = (wghts[2] * origin[0]) + (wghts[3] * origin[1]) + bias
output_3 = (wghts[4] * origin[0]) + (wghts[5] * origin[1]) + bias
#Relu Function
if output_1 >= 0.1:
output_1 = output_1
else:
output_1 = 0
if output_2 >= 0.1:
output_2 = output_2
else:
output_2 = 0
if output_3 >= 0.1:
output_3 = output_3
else:
output_3 = 0
# Compares food/destination X and Y with bug/origin X and Y.
# applies update ("learn") to all weights
if origin[0] != destination[0] and origin[1] != destination[1]:
wghts[0] = wghts[0] + learn
wghts[1] = wghts[1] + learn
wghts[2] = wghts[2] + learn
wghts[3] = wghts[3] + learn
wghts[4] = wghts[4] + learn
wghts[5] = wghts[5] + learn
else:
wghts[0] = wghts[0]
wghts[1] = wghts[1]
wghts[2] = wghts[2]
wghts[3] = wghts[3]
wghts[4] = wghts[4]
wghts[5] = wghts[5]
#print(wghts)
#print("\n")
# Creates a barrier for turtle
bug_1a = int(bug.xcor())
bug_2a = int(bug.ycor())
if bug_1a > 300 or bug_2a > 300:
bug.penup()
bug.setx(5)
bug.sety(5)
bug.pendown()
if bug_1a < -300 or bug_2a < -300:
bug.penup()
bug.setx(5)
bug.sety(5)
bug.pendown()
# Output values applied to turtle direction controls
bug.forward(output_1)
bug.right(output_2)
bug.left(output_3)
- 답변 # 1
관련 자료
- python - 신경망은 실제 2 인 동안 3 개의 클래스를 반환합니다
- tensorflow - 딥 러닝 (신경망) 챌린지 데이터
- python - google colab cpu의 신경망 교육 - 두 번째 시대는 시작되지 않는다
- r - 신경망 분석에 어떤 값을 사용해야합니까?
- python - 다중 입력 - 작은 데이터 세트에서 하나의 출력 신경망
- python - tensorflow-dataset으로 신경망을 훈련시키는 방법은 무엇입니까?
- python - convolutional neural network에 대한 고객 계층을 생성하지만 typeerror - float () 인수는 'dimension'이 아닌 문자열 또는 숫자 여야합니다
- python - Tensorflow Neural Network MSE 큰 불일치
- c - XOR 신경망은 약 05로 수렴하는 것 같습니다
- python - 두 개의 Y 변수를 출력하는 LSTM 신경망 생성
- python - 신경망 모델은 정확도를 향상시키지 않습니다 스케일링 문제 또는 모델 문제?
- python - 신경망의 입력으로 사용되는 팬더 데이터 프레임?
- machine learning - 시각적 입력을 사용하여 디아블로 2를 재생하도록 인공 신경망을 훈련시키는 방법은 무엇입니까?
- artificial intelligence - 신경망의 모든 뉴런이 항상 발사/활성화되는 것은 아닙니까?
- python - 내 신경망이 직선으로 X ^ 2에 가깝습니다
- python - openCV로 신경망 모델을 읽는 방법
- matrix - Tensorflow가 포함 된 AND 게이트 단일 레이어 신경망
- python - 간단한 단일 레이어 신경망
- tensorflow - GPU를 활용하여 Android에서 신경망 모델을 실행하는 방법은 무엇입니까?
- python - 첫 번째 반복 후 신경망이 이상하게 동작
귀하의 프로그램에서 볼 수있는 문제 :
와이즈 비즈 이전 반복에서 아무것도 배우지 않습니다. 루프를 통해 매번 무작위로 재설정됩니다.
와이즈 비즈
wghts
그리고output_1
새로 초기화 된output_2
에서 계산 따라서 다음과 같이 변경되었습니다 :는
wghts
에 반영되지 않습니다 변수.버그의 X 및 Y 좌표를 추가하고이를 회전 각도로 사용합니다. 두번. 그게 어떤 의미인지는 모르겠지만 신경망 인 것 같습니다.
다음 코드와 동기화되지 않도록 코드에서 장벽 검사를 너무 늦게 수행합니다. 버그가 움직이지 않으므로 미리 확인하십시오.
다음 코드 정리는 버그를 덜 무작위로 만들지 않습니다. 코드를보다 쉽게 사용할 수 있기를 바랍니다.
output_*