티스토리 뷰
AI/Deep Learning
[Keras] tensorflow 1.4.0 + keras 2.2.4 사용시 tensorflow backend softmax 함수 오류 문제 해결
Arc Lab. 2018. 11. 21. 11:29[업데이트 2018.11.21 11:28]
keras 사용시 backend로 tensorflow를 쓰는데, softmax부분에서 tensorflow와 호환성 문제로 오류가 발생할 수 있습니다.
아래와 같이 tensorflow_backend.py를 수정 및 컴파일을 수행합니다.
Ubuntu 14.04, python 2.7 기준으로 작성하였습니다.
1. 아래의 위치로 이동합니다.
cd /usr/local/lib/python2.7/dist-packages/keras/backend/
2. tensorflow_backend.py 파일을 다음과 같이 수정합니다.
아래와 같이 return 부분을 axis=axis -> dim=axis로 수정
def softmax(x, axis=-1): """Softmax of a tensor. # Arguments x: A tensor or variable. axis: The dimension softmax would be performed on. The default is -1 which indicates the last dimension. # Returns A tensor. """ return tf.nn.softmax(x, dim=axis)
3. tensorflow_backend.py를 컴파일하여 tensorflow_backend.pyc 바이너리 파이썬 파일을 생성합니다.
sudo python -m py_compile tensorflow_backend.py
* 참고
[1] https://github.com/keras-team/keras/issues/9621
[2] https://github.com/tensorflow/docs/blob/r1.4/site/en/api_docs/api_docs/python/tf/nn/softmax.md
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- SSM
- ate
- Jekyll and Hyde
- #ApacheZeppelin
- aws #cloudfront
- Ragdoll
- #REST API
- Memorize
- docker
- OST
- belief
- Physical Simulation
- #ELK Stack
- some time ago
- English
- ILoop Engine
- GOD
- 2D Game
- Sea Bottom
- Library
- Game Engine
- Badge
- project
- sentence test
- #TensorFlow
- #ApacheSpark
- 도커
- Mask R-CNN
- Meow
- Worry
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함