Code Monkey home page Code Monkey logo

Comments (4)

dnddnjs avatar dnddnjs commented on June 9, 2024

혹시 케라스와 텐서플로우 버전이 어떻게 되나요? 저희가 이 책 예제를 만들 때 썼던 버전이 있는데 최근 버전을 사용하면 문제가 생길 수도 있지 않을까 싶어요.

from reinforcement-learning-kr.

xxxibran avatar xxxibran commented on June 9, 2024

혹시 케라스와 텐서플로우 버전이 어떻게 되나요? 저희가 이 책 예제를 만들 때 썼던 버전이 있는데 최근 버전을 사용하면 문제가 생길 수도 있지 않을까 싶어요.

답변 감사합니다. 일단 명시되어 있는 버전까지는 다운그레이드 하면 안돌아가서 버전을 낮추긴 했는데, 잘 안되네요. 그래서 제가 직접 짜보고 있는데 궁금한게 있어서 몇 가지 여쭈어 보려고 합니다. 가능하시면 답변 주시면 정말 감사해요.

if name == "main":
# 환경과 에이전트의 생성
env = Env()
agent = ReinforceAgent()

global_step = 0
scores, episodes = [], []

for e in range(EPISODES):
    done = False
    score = 0
    # env 초기화
    state = env.reset()
    state = np.reshape(state, [1, 15])

    while not done:
        global_step += 1
        # 현재 상태에 대한 행동 선택
        action = agent.get_action(state)

여기 메인에서 보면 action = agent.get_action(state)가 있고 이거 관련된 부분이 아래 함수인데,

정책신경망으로 행동 선택

def get_action(self, state):
    policy = self.model.predict(state)[0]
    return np.random.choice(self.action_size, 1, p=policy)[0]

에피소드가 첫 번째라 하면 아무것도 훈련(train) 된게 없는데 어떻게 predict를 할 수가 있는건가요?

초기 선언 보면

def __init__(self):
    self.load_model = False
    # 가능한 모든 행동 정의
    self.action_space = [0, 1, 2, 3, 4]
    # 상태와 행동의 크기 정의
    self.action_size = len(self.action_space)
    self.state_size = 15
    self.discount_factor = 0.99
    self.learning_rate = 0.001

    self.model = self.build_model()
    self.optimizer = self.optimizer()
    self.states, self.actions, self.rewards = [], [], []

    if self.load_model:
        self.model.load_weights('./save_model/reinforce_trained.h5')

마지막 줄에 load_weight를 불러오는데 이미 훈련된 모델을 불러온 상태이기 때문에 predict를 할 수 있는건가요? 제가 이해를 제대로 한건지 궁금합니다 ㅜ

from reinforcement-learning-kr.

dnddnjs avatar dnddnjs commented on June 9, 2024

뉴럴네트워크를 만들었으니까 predict를 할 수 있어요. 학습 여부와는 상관없어요.

from reinforcement-learning-kr.

xxxibran avatar xxxibran commented on June 9, 2024

뉴럴네트워크를 만들었으니까 predict를 할 수 있어요. 학습 여부와는 상관없어요.

친절한 답변 감사합니다!

from reinforcement-learning-kr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.