반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- Anaconda
- pip install
- 파이썬
- Deep learning
- 가상환경구축
- torch.nn.Module
- torch.nn
- 파이썬문법
- __init__
- 딥러닝
- __call__
- ubuntu
- Torchvision
- LSTM
- vision transformer
- CNN
- 머신러닝
- DeepLearning
- objectdetection
- 가상환경
- AI
- docker
- pytorch
- wsl2
- python
- ViT
- tensorflow
- rnn
- pychram
- python 문법
Archives
- Today
- Total
인공지능을 좋아하는 곧미남
[python] functools.partial() 본문
간단히 설명하면 어느 하나의 함수에 전달되는 파라미터를 분기해서 전달할 수 있는 방법이다.
예를들어 a라는 함수에 b, c, d, e 파라미터가 전달받는다. 이때 functools.partial(함수명, 파라미터정의..)의 형태로 객체를 생성하면, 그 객체는 함수에 파라미터가 전달된 상태가 된다. 따라서, result 객체가 b, c 파라미터가 전달받은채로 사용할 수 있게 된다.
import functools
def a(b, c, d, e):
return b+c, d*e
result = functools.partial(a, b=1, c=2)
bcsum, deproduct = result(d=5, e=3)
print(bcsum)
print(deproduct)
반응형
'code_study > python world' 카테고리의 다른 글
[python] argparse Error: SystemExit: 2 (0) | 2024.12.02 |
---|---|
[python] 동일한 함수에서 출력을 다르게 하고 싶을때 문자열로 출력 파라미터를 정하는 방법! (0) | 2024.12.02 |
[python] OrderedDict는 딥러닝에서 어떻게 사용될까? (0) | 2022.02.08 |
[python] Packing, Unpacking (0) | 2022.01.17 |
[python] 내장함수 setattr()와 getattr() (0) | 2022.01.13 |
Comments