* ML | DL/python

getattr(object, name) / getattr(object, name, default) python docs Return the value of the named attribute of object. (name must be a string.) object의 name으로 불리는 attribute값을 반환한다. (이때 name은 문자열) If the string is the name of one of the object’s attributes, the result is the value of that attribute. For example, getattr(x, 'foobar') is equivalent to x.foobar. object의 attribute로 'name&#..


에러문구 RuntimeError: GET was unable to find an engine to execute this computation 문제 상황 데이터로더(collate_fn 추가), 모델을 수정하고 학습시키려고 보니 오류가 발생했다. 가설1. (모델을 수정하면서) backward 과정에 문제가 발생했다. (inplace 등으로 인해) ⇒ 에러문구 + loss 로 검색해보고, inplace 로도 구글링해봤는데 괜찮은 검색결과가 나오지 않았다. 그리고 모델 수정하면서 구조가 더 간단해진거라 이왜틀..? 모델 파라미터에 영향을 미치지 않는 input parameter를 추가했는데, 이걸 잘못추가한 원인인가도 싶었음. 가설2. (데이터로더를 수정하면서) 배치사이즈에 해당하는 0번째 dimension이..

PyTorch Docs torch.Tensor.repeat Repeats this tensor along the specified dimensions. 특정 dimension에 따라 텐서를 반복함. Parameters: sizes (torch.Size or int...) – The number of times to repeat this tensor along each dimension. 각 dimension에 따라 이 텐서를 반복하는 횟수. Example: x = torch.tensor([1, 2, 3]) # torch.Size([3]) x1 = x.repeat(4, 2) # torch.Size([4, 6]) x2 = x.repeat(4, 2, 1) # torch.Size([4, 2, 3]) x3 = x..

Person 클래스는 name 인스턴스 속성을 가지고, 생성자가 호출될 때 지정된다. introduce 메소드는 name 속성을 print 한다. class Person(): def __init__(self, name): self.name = name def introduce(self): print(f"Hello. My name is {self.name}.") sam = Person("sam") sam.introduce() # Hello. My name is sam. Person 클래스를 상속받는 자식 클래스 Student를 생성해보자. Student는 Person의 name 속성을 갖고, 새로운 studentID 속성을 가지는 클래스로 생성할 것이다. class Student(Person): def _..