Open Cinofe opened 3 years ago
버전이 업데이트되면서 get_updates 함수 옵션 순서와 갯수가 바뀌었습니다. 다음과 같이 해야 합니다.
updates = optimizer.get_updates(loss, self.model.trainable_weights)
감사합니다!
2021년 11월 30일 (화) 오후 2:32, swkim01 @.***>님이 작성:
버전이 업데이트되면서 get_updates 함수 옵션 순서와 갯수가 바뀌었습니다. 다음과 같이 해야 합니다. updates = optimizer.get_updates(loss, self.model.trainable_weights)
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/rlcode/reinforcement-learning-kr/issues/59#issuecomment-982300580, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2A6LBILSBVPFBG3MOR7KDUOROWNANCNFSM5BTQUDMA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
안녕하세요, 저도 기존 질문과 같은 에러가 있어서 말씀하신대로
updates = optimizer.get_updates(loss, self.model.trainable_weights)
위 코드로 변환하였습니다.
그랬더니,
TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
위와 같은 에러가 발생하는데.. numpy 최신버전으로 설치해도 동일한 에러가 발생합니다.
혹시 get_updates 뿐만 아니라 다른 코드들도 수정해줘야하나요?
============================================= 1/17
from tensorflow.python.framework.ops import disable_eager_execution
disable_eager_execution()
위 코드 입력하니까
TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
에러는 사라졌는데, 이제는 get_update 코드 아래 줄
train = K.function([self.model.input, action, discounted_rewards], [], updates = updates)
위 코드가 문제입니다..
안녕하세요, 저도 기존 질문과 같은 에러가 있어서 말씀하신대로
updates = optimizer.get_updates(loss, self.model.trainable_weights)
위 코드로 변환하였습니다.
그랬더니,
TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
위와 같은 에러가 발생하는데.. numpy 최신버전으로 설치해도 동일한 에러가 발생합니다.
혹시 get_updates 뿐만 아니라 다른 코드들도 수정해줘야하나요?
============================================= 1/17
from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution()
위 코드 입력하니까
TypeError: Cannot convert a symbolic Keras input/output to a numpy array. This error may indicate that you're trying to pass a symbolic value to a NumPy call, which is not supported. Or, you may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model.
에러는 사라졌는데, 이제는 get_update 코드 아래 줄
train = K.function([self.model.input, action, discounted_rewards], [], updates = updates)
위 코드가 문제입니다..
다음과 같이 수정해 보시기 바랍니다.
train = K.function([self.model.input, action, discounted_rewards], [loss], updates = updates)
또, 아래 정책신경망_ 업데이트 함수 _trainmodel 에서 다음과 같이 수정해야 할 겁니다.
self.optimizer([np.array(self.states), np.array(self.actions), np.array(discounted_rewards)])
에러 내용 : 예외가 발생했습니다. TypeError get_updates() takes 3 positional arguments but 4 were given File "D:\seungwan\Desktop\AI_Study\AI_Reference\reinforcement-learning-kr-master\1-grid-world\7-reinforce\reinforce_agent.py", line 52, in optimizer updates = optimizer.get_updates(self.model.trainable_weights, [], loss) File "D:\seungwan\Desktop\AI_Study\AI_Reference\reinforcement-learning-kr-master\1-grid-world\7-reinforce\reinforce_agent.py", line 25, in init self.optimizer = self.optimizer() File "D:\seungwan\Desktop\AI_Study\AI_Reference\reinforcement-learning-kr-master\1-grid-world\7-reinforce\reinforce_agent.py", line 92, in
agent = ReinforceAgent()