본문 바로가기

machine learning17

pytorch의 forward 함수는 어떻게 실행될까 pytorch에서 nn.Module 을 기반으로 만들어진 모듈은 forward 함수를 호출 하지도 않았는데 모델 instance을 호출하는 것 만으로 forward가 실행된다. 왜 이럴까? python의 __init__ 은 모두가 알듯이 생성자 함수이다. 클래스의 instance가 생성되면 __init__가 호출된다. __call__은 호출자 함수인데 instance가 호출되면 __call__가 실행된다. python은 클래스 인스턴스도 함수 처럼 호출할 수 있다 class test_class(): def __init__(self, n1,n2,n3): print('called __init__') self.n1 = n1 self.n2 = n2 self.n3 = n3 print(n1, n2, n3) def .. 2022. 5. 9.
network visualization library https://towardsdatascience.com/visualizing-networks-in-python-d70f4cbeb259 Visualizing Networks in Python A practical guide to tools which helps you “see” the network. towardsdatascience.com small, interactive graph : pyvis visdcc 아니면 그냥 networkx https://towardsdatascience.com/large-graph-visualization-tools-and-approaches-2b8758a1cd59 Large Graph Visualization Tools and Approaches What to do, i.. 2021. 11. 9.
tensorflow 1 -> tensorflow 2 변환 기본적으로 tf2에서 tf1코드를 돌릴수 있음 import tensorflow.compat.v1 as tf tf.disable_v2_behavior() 하지만 이렇게 하면 tf2 의 기능들을 사용할수 없음 참고로 tf.keras 을 이용해 고수준의 코드를 짯으면 바꿀것도 없음 reference ) www.tensorflow.org/guide/migrate?hl=ko 텐서플로 1 코드를 텐서플로 2로 바꾸기 | TensorFlow Core Note: 이 문서는 텐서플로 커뮤니티에서 번역했습니다. 커뮤니티 번역 활동의 특성상 정확한 번역과 최신 내용을 반영하기 위해 노력함에도 불구하고 공식 영문 문서의 내용과 일치하지 않을 수 www.tensorflow.org 그냥 앞으로 무조건 tf.keras와 pytor.. 2020. 10. 30.
[pytorch] Variable -> tensor 로 통합 - 원래 Variable는 tensor의 warpper 였음. tensor는 history tracking 이 안되고 variable는 되었었는데 이제 tensor가 가능함 - linux 에서 돌아가던 code를 win10에서 돌리니 이런 에러발생 RuntimeError: Expected tensor for argument #1 ‘indices’ to have scalar type Long 선언된 Variable이 int.32 타입임 int.64로 바꿔줘야함. a= Variable(~~~) 이던것을 a = torch.tensor(~~~,dtype =torch.int64 ) 로 바꿔줌 2020. 8. 21.