250x250
Link
๋์ GitHub Contribution ๊ทธ๋ํ
Loading data ...
Notice
Recent Posts
Recent Comments
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- pandas
- ๋์ํ๋ณธ
- ๋น ๋ฐ์ดํฐ
- ๊ตฐ์งํ
- numpy
- ๋ฐ์ดํฐ๋ถ์
- LDA
- Python
- ๋ฐ์ดํฐ๋ถ์์ ๋ฌธ๊ฐ
- PCA
- ์ฃผ์ฑ๋ถ๋ถ์
- Lambda
- t-test
- ์ค๋ฒ์ํ๋ง
- dataframe
- iloc
- ADP
- ๋ฐ์ดํฐ๋ถ๊ท ํ
- ๋น ๋ฐ์ดํฐ๋ถ์๊ธฐ์ฌ
- ํ์ด์ฌ
- ํ ์คํธ๋ถ์
- ํฌ๋กค๋ง
- opencv
- ๋ฐ์ดํฐ๋ถ์์ค์ ๋ฌธ๊ฐ
- ADsP
- ์๋ํด๋ผ์ฐ๋
- DBSCAN
- datascience
- ๋ ๋ฆฝํ๋ณธ
- ์ธ๋์ํ๋ง
Archives
Data Science LAB
[Deep Learning] ๋ฅ๋ฌ๋์์ super().__init__ ์ฌ์ฉ (ํด๋์ค ์์) ๋ณธ๋ฌธ
๐ง Deep Learning
[Deep Learning] ๋ฅ๋ฌ๋์์ super().__init__ ์ฌ์ฉ (ํด๋์ค ์์)
ใ ใ ใ ใ 2022. 12. 7. 17:39728x90
1. ๋ฅ๋ฌ๋์์ ์์ฃผ ์ฐ์ด๋ ์ฝ๋
super().__init__()
super(ClassName, self).__init__()
super().__init__(**kwargs)
super(ClassName, self).__init__(**kwargs)
2. ์ฌ์ฉ ์์
class Parent():
def __init__(self):
print("Parent init")
self.parentHi = "๋ถ๋ชจ ํด๋์ค"
class Child(Parent):
def __init__(self):
super().__init__()
print("Child init")
self.childHi = "์์ ํด๋์ค"
child = Child()
print(child.childHi)
print(child.parentHi)
# Parent init
# Child init
# ์์ ํด๋์ค
# ๋ถ๋ชจ ํด๋์ค
1. ๋ถ๋ชจ ํด๋์ค (Parent) ์ ์ธ
2. ์์ ํด๋์ค์์ super.__init__(self) ์๋ฏธ : ๋ถ๋ชจ ํด๋์ค์ __init__๋ฉ์๋๋ฅผ ํธ์ถ
-> super()๋ฅผ ์ฌ์ฉํ์ง ์์ผ๋ฉด ๋ถ๋ชจ ํด๋์ค์ __init__() ๋ฉ์๋์ overriding(๋ฎ์ด์ฐ๊ธฐ) ๋จ
3. ์์ ํด๋์ค์ childHI ์ธ์คํด์ค ์ถ๊ฐ
- ๋ง์ฝ, ๋ถ๋ชจ class์ argument(ํจ์์ ๋ณ์์ ๊ฐ์ ์ง์ด๋ฃ์)์ด ์๋ค๋ฉด **kwargs๋ฅผ ์ถ๊ฐํด์ผํจ
class Parent():
def __init__(self,parentHi):
self.parentHi = parentHi
print('Parent init')
class Child(Parent):
def __init__(self,childHi,**kwargs):
super(Child, self).__init__(**kwargs)
self.childHi = childHi
print('Child init')
child = Child(parentHi='๋ถ๋ชจ', childHi='์์')
print(child.childHi)
print(child.parentHi)
# Parent init
# Child init
# ์์
# ๋ถ๋ชจ
**kwargs๊ฐ ์์ผ๋ฉด error ์ฃผ์
728x90
'๐ง Deep Learning' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Deep Learning] ํฉ์ฑ๊ณฑ ์ ๊ฒฝ๋ง CNN (Convolution Neural Network) ์ ๋ฆฌ (0) | 2022.12.10 |
---|---|
[Deep Learning] ๋ฐฐ์น ์ ๊ทํ (Batch Normalization, BN) (0) | 2022.12.09 |
[Deep Learning] Tensorflow์์ Sequential ๋ชจ๋ธ ์์ฑํ๋ ๋ฒ (0) | 2022.11.24 |
[Deep Learning] ์ถ๋ ฅ์ธต ์ค๊ณ (softmax, ํญ๋ฑ ํจ์) (0) | 2022.11.23 |
[Deep Learning] ํ์ฑํ ํจ์ ์ข ๋ฅ ๋ฐ ๋น๊ต ์ ๋ฆฌ (0) | 2022.11.21 |
Comments