일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 3d
- FineGrained
- 머신러닝
- math
- nlp
- Front
- nerf
- clean code
- FGVC
- cs
- pytorch
- computervision
- Depth estimation
- CV
- web
- PRML
- 알고리즘
- SSL
- Meta Learning
- Torch
- GAN
- classification
- 자료구조
- ML
- Python
- REACT
- algorithm
- 딥러닝
- dl
- Vision
- Today
- Total
KalelPark's LAB
[ CLEAN CODE ] Clean Python, broadcast_to, linspace란? 본문
[ CLEAN CODE ] Clean Python, broadcast_to, linspace란?
kalelpark 2023. 1. 21. 21:39
broadcast_to란?
배열을 새로운 모양으로 broadcast합니다.

import numpy as np
x = np.array([1, 2, 3])
temp = np.broadcast_to(x, (3, 3))
>> array([[1, 2, 3],
[1, 2, 3],
[1, 2, 3]])
linspace란?
Python의 Numpy 모듈에 포함된 함수로서 1차원 배열 만들때 활용됩니다. (line spaced의 줄임말입니다.)
그래프 그리기에서 수평축의 간격 만들기 등에서 매우 편리하게 사용할 수 있는 함수입니다.
시작 값과 끝 값을 입력하고, 몇 개의 일정한 간격으로 요소를 만들 것인지를 나타내야 합니다.

import numpy as np
x = np.linspace(0, 10, 11)
print(x)
>> [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
참고
https://numpy.org/doc/stable/reference/generated/numpy.broadcast_to.html
numpy.broadcast_to — NumPy v1.24 Manual
If True, then sub-classes will be passed-through, otherwise the returned array will be forced to be a base-class array (default).
numpy.org
https://numpy.org/doc/stable/reference/generated/numpy.linspace.html
numpy.linspace — NumPy v1.24 Manual
Return evenly spaced numbers over a specified interval. Returns num evenly spaced samples, calculated over the interval [start, stop]. The endpoint of the interval can optionally be excluded. Changed in version 1.20.0: Values are rounded towards -inf inste
numpy.org
'Python > CLEAN CODE' 카테고리의 다른 글
[ CLEAN CODE ] Clean Python, *args, **kwargs? (0) | 2023.01.25 |
---|---|
[ CLEAN CODE ] Clean Python, Numpy with Linear Algebra (0) | 2023.01.21 |
[ CLEAN CODE ] Clean Python, YACS(Yet Another Configuration System)란? (0) | 2023.01.14 |
[ CLEAN CODE ] Clean Python, StaticMethod, ClassMethod란? (0) | 2023.01.13 |
[ CLEAN CODE ] Clean Python, Logging 활용하기 (0) | 2023.01.02 |