반면 매개변수는 가중치 및 편향과 같이 모델 자체에 속하는 변수입니다. 즉, 초매개변수는 사용자가 제어하는 값이고 매개변수는 모델이 학습 중에 계산하는 값입니다.
학습률
학습률은 모델이 수렴하는 속도에 영향을 미치는 부동 소수점 숫자입니다. 학습률이 너무 낮으면 모델이 수렴하는 데 시간이 오래 걸릴 수 있습니다. 하지만 학습률이 너무 높으면 모델이 수렴하지 않고 손실을 최소화하는 가중치와 편향을 중심으로 바운스합니다. 목표는 모델이 빠르게 수렴할 수 있도록 너무 높지도 너무 낮지도 않은 학습률을 선택하는 것입니다.
학습률은 경사하강법 프로세스의 각 단계에서 가중치와 편향에 적용할 변경사항의 크기를 결정합니다. 모델은 경사에 학습률을 곱하여 다음 반복의 모델 매개변수 (가중치 및 편향 값)를 결정합니다. 경사 하강법의 세 번째 단계에서 음의 기울기 방향으로 이동하는 '소량'은 학습률을 의미합니다.
이전 모델 매개변수와 새 모델 매개변수의 차이는 손실 함수의 기울기에 비례합니다. 예를 들어 경사가 크면 모델이 큰 단계를 취합니다. 작은 경우 작은 단계를 취합니다. 예를 들어 그라데이션의 크기가 2.5이고 학습률이 0.01이면 모델은 매개변수를 0.025만큼 변경합니다.
이상적인 학습률은 모델이 적절한 수의 반복 내에 수렴하도록 지원합니다. 그림 20에서 손실 곡선은 모델이 처음 20번의 반복 동안 크게 개선된 후 수렴하기 시작하는 것을 보여줍니다.
그림 20. 학습률이 빠르게 수렴되도록 학습된 모델을 보여주는 손실 그래프
반대로 학습률이 너무 작으면 수렴하는 데 너무 많은 반복이 필요할 수 있습니다. 그림 21에서 손실 곡선은 모델이 각 반복 후 약간만 개선됨을 보여줍니다.
그림 21. 작은 학습률로 학습된 모델을 보여주는 손실 그래프
학습률이 너무 크면 각 반복으로 인해 손실이 튀거나 계속 증가하므로 수렴되지 않습니다. 그림 22에서 손실 곡선은 각 반복 후 모델의 손실이 감소했다가 증가하는 것을 보여주고, 그림 23에서는 후반 반복에서 손실이 증가합니다.
그림 22. 학습률이 너무 커서 학습된 모델을 보여주는 손실 그래프로, 반복이 증가함에 따라 손실 곡선이 위아래로 크게 변동합니다.
그림 23. 학습률이 너무 커서 학습된 모델을 보여주는 손실 그래프로, 후반 반복에서 손실 곡선이 급격히 증가합니다.
연습: 학습 내용 점검하기
이상적인 학습률은 무엇인가요?
이상적인 학습률은 문제에 따라 다릅니다.
각 모델과 데이터 세트에는 이상적인 학습률이 있습니다.
0.01
1.0
배치 크기
배치 크기는 모델이 가중치와 편향을 업데이트하기 전에 처리하는 예의 수를 나타내는 하이퍼파라미터입니다. 가중치와 편향을 업데이트하기 전에 데이터 세트의 모든 예에 대한 손실을 모델이 계산해야 한다고 생각할 수 있습니다. 하지만 데이터 세트에 수십만 또는 수백만 개의 예가 포함된 경우 전체 배치를 사용하는 것은 실용적이지 않습니다.
가중치와 편향을 업데이트하기 전에 데이터 세트의 모든 예시를 살펴보지 않고도 평균에 적합한 기울기를 얻는 두 가지 일반적인 기법은 확률적 경사 하강법과 미니 배치 확률적 경사 하강법입니다.
확률적 경사하강법 (SGD): 확률적 경사하강법은 반복당 하나의 예 (배치 크기 1)만 사용합니다. 반복 횟수가 충분하면 SGD가 작동하지만 노이즈가 매우 많습니다. '노이즈'는 반복 중에 손실이 감소하지 않고 증가하도록 하는 학습 중 변동을 의미합니다. '확률적'이라는 용어는 각 배치로 구성된 하나의 예가 무작위로 선택됨을 나타냅니다.
다음 이미지에서 모델이 SGD를 사용하여 가중치와 편향을 업데이트할 때 손실이 약간 변동되어 손실 그래프에 노이즈가 발생할 수 있습니다.
그림 24. 손실 곡선에 노이즈가 표시된 확률적 경사하강법 (SGD)으로 학습된 모델
확률적 경사 하강법을 사용하면 수렴 근처뿐만 아니라 전체 손실 곡선에 걸쳐 노이즈가 발생할 수 있습니다.
미니 배치 확률적 경사하강법 (미니 배치 SGD): 미니 배치 확률적 경사하강법은 전체 배치와 SGD의 절충안입니다. $ N $ 개의 데이터 포인트의 경우 배치 크기는 1보다 크고 $ N $보다 작은 숫자일 수 있습니다. 모델은 각 배치에 포함된 예시를 무작위로 선택하고, 경사를 평균화한 다음, 반복당 한 번씩 가중치와 편향을 업데이트합니다.
각 배치에 대한 예시 수는 데이터 세트와 사용 가능한 컴퓨팅 리소스에 따라 달라집니다. 일반적으로 배치 크기가 작으면 SGD와 유사하게 작동하고 배치 크기가 크면 전체 배치 경사 하강법과 유사하게 작동합니다.
그림 25. 미니 배치 SGD로 학습된 모델
모델을 학습할 때 노이즈는 제거해야 하는 바람직하지 않은 특성이라고 생각할 수 있습니다. 하지만 어느 정도의 노이즈는 좋은 것일 수 있습니다. 후반 모듈에서는 노이즈가 모델의 일반화를 개선하고 신경망에서 최적의 가중치와 편향을 찾는 데 어떻게 도움이 되는지 알아봅니다.
에포크
학습 중에 에포크는 모델이 학습 세트의 모든 예시를 한 번 처리했음을 의미합니다. 예를 들어 1,000개의 예시가 있는 학습 세트와 100개의 예시가 있는 미니 배치 크기가 주어지면 모델이 한 에포크를 완료하는 데 10개의 반복이 필요합니다.
학습에는 일반적으로 많은 에포크가 필요합니다. 즉, 시스템은 학습 세트의 모든 예시를 여러 번 처리해야 합니다.
에포크 수는 모델이 학습을 시작하기 전에 설정하는 하이퍼파라미터입니다. 모델이 수렴하는 데 필요한 에포크 수를 실험해야 하는 경우가 많습니다. 일반적으로 에포크 수가 많을수록 모델이 더 좋아지지만 학습 시간도 더 오래 걸립니다.
그림 26. 전체 배치와 미니 배치
다음 표에서는 배치 크기와 에포크가 모델이 매개변수를 업데이트하는 횟수와 어떤 관련이 있는지 설명합니다.
일괄 유형
가중치 및 편향 업데이트가 발생하는 경우
전체 배치
모델이 데이터 세트의 모든 예시를 살펴본 후 예를 들어 데이터 세트에 1,000개의 예가 포함되어 있고 모델이 20번의 에포크 동안 학습하는 경우 모델은 에포크당 한 번씩 가중치와 편향을 20번 업데이트합니다.
확률적 경사하강법
모델이 데이터 세트의 단일 예시를 살펴본 후 예를 들어 데이터 세트에 1,000개의 예가 포함되어 있고 20에포크 동안 학습하는 경우 모델은 가중치와 편향을 20,000번 업데이트합니다.
미니 배치 확률적 경사하강법
모델이 각 배치에 있는 예시를 살펴본 후 예를 들어 데이터 세트에 1,000개의 예시가 있고 배치 크기가 100이며 모델이 20에포크 동안 학습하는 경우 모델은 가중치와 편향을 200회 업데이트합니다.
연습: 학습 내용 점검하기
1. 미니 배치 SGD를 사용할 때 가장 적합한 배치 크기는 무엇인가요?
경우에 따라 다름
이상적인 배치 크기는 데이터 세트와 사용 가능한 컴퓨팅 리소스에 따라 다릅니다.
배치당 10개 예시
배치당 100개의 예
2. 다음 중 참인 설명은 무엇인가요?
이상치가 많은 데이터에는 더 큰 배치 크기가 적합하지 않습니다.
거짓입니다. 더 많은 그라데이션을 평균화하면 배치 크기가 클수록 데이터에 이상치가 있는 부정적인 영향을 줄일 수 있습니다.
학습률을 두 배로 늘리면 학습 속도가 느려질 수 있습니다.
이 문장은 참입니다. 학습률을 두 배로 늘리면 학습률이 너무 커져 가중치가 '바운스'되어 수렴하는 데 필요한 시간이 늘어날 수 있습니다. 항상 그렇듯이 최적의 하이퍼파라미터는 데이터 세트와 사용 가능한 컴퓨팅 리소스에 따라 달라집니다.
[[["이해하기 쉬움","easyToUnderstand","thumb-up"],["문제가 해결됨","solvedMyProblem","thumb-up"],["기타","otherUp","thumb-up"]],[["필요한 정보가 없음","missingTheInformationINeed","thumb-down"],["너무 복잡함/단계 수가 너무 많음","tooComplicatedTooManySteps","thumb-down"],["오래됨","outOfDate","thumb-down"],["번역 문제","translationIssue","thumb-down"],["샘플/코드 문제","samplesCodeIssue","thumb-down"],["기타","otherDown","thumb-down"]],["최종 업데이트: 2025-08-17(UTC)"],[[["\u003cp\u003eHyperparameters, such as learning rate, batch size, and epochs, are external configurations that influence the training process of a machine learning model.\u003c/p\u003e\n"],["\u003cp\u003eThe learning rate determines the step size during model training, impacting the speed and stability of convergence.\u003c/p\u003e\n"],["\u003cp\u003eBatch size dictates the number of training examples processed before updating model parameters, influencing training speed and noise.\u003c/p\u003e\n"],["\u003cp\u003eEpochs represent the number of times the entire training dataset is used during training, affecting model performance and training time.\u003c/p\u003e\n"],["\u003cp\u003eChoosing appropriate hyperparameters is crucial for optimizing model training and achieving desired results.\u003c/p\u003e\n"]]],[],null,["[**Hyperparameters**](/machine-learning/glossary#hyperparameter) are variables\nthat control different aspects of training. Three common hyperparameters are:\n\n- [**Learning rate**](/machine-learning/glossary#learning-rate)\n- [**Batch size**](/machine-learning/glossary#batch-size)\n- [**Epochs**](/machine-learning/glossary#epoch)\n\nIn contrast, [**parameters**](/machine-learning/glossary#parameter) are the\nvariables, like the weights and bias, that are part of the model itself. In\nother words, hyperparameters are values that you control; parameters are values\nthat the model calculates during training.\n\nLearning rate\n\n[**Learning rate**](/machine-learning/glossary#learning-rate) is a\nfloating point number you set that influences how quickly the\nmodel converges. If the learning rate is too low, the model can take a long time\nto converge. However, if the learning rate is too high, the model never\nconverges, but instead bounces around the weights and bias that minimize the\nloss. The goal is to pick a learning rate that's not too high nor too low so\nthat the model converges quickly.\n\nThe learning rate determines the magnitude of the changes to make to the weights\nand bias during each step of the gradient descent process. The model multiplies\nthe gradient by the learning rate to determine the model's parameters (weight\nand bias values) for the next iteration. In the third step of [gradient\ndescent](/machine-learning/crash-course/linear-regression/gradient-descent), the \"small amount\" to move in the direction\nof negative slope refers to the learning rate.\n\nThe difference between the old model parameters and the new model parameters is\nproportional to the slope of the loss function. For example, if the slope is\nlarge, the model takes a large step. If small, it takes a small step. For\nexample, if the gradient's magnitude is 2.5 and the learning rate is 0.01, then\nthe model will change the parameter by 0.025.\n\nThe ideal learning rate helps the model to converge within a reasonable number\nof iterations. In Figure 21, the loss curve shows the model significantly\nimproving during the first 20 iterations before beginning to converge:\n\n**Figure 21**. Loss graph showing a model trained with a learning rate that\nconverges quickly.\n\nIn contrast, a learning rate that's too small can take too many iterations to\nconverge. In Figure 22, the loss curve shows the model making only minor\nimprovements after each iteration:\n\n**Figure 22**. Loss graph showing a model trained with a small learning rate.\n\nA learning rate that's too large never converges because each iteration either\ncauses the loss to bounce around or continually increase. In Figure 23, the loss\ncurve shows the model decreasing and then increasing loss after each iteration,\nand in Figure 24 the loss increases at later iterations:\n\n**Figure 23**. Loss graph showing a model trained with a learning rate that's\ntoo big, where the loss curve fluctuates wildly, going up and down as the\niterations increase.\n\n**Figure 24**. Loss graph showing a model trained with a learning rate that's\ntoo big, where the loss curve drastically increases in later iterations.\n\nExercise: Check your understanding \nWhat is the ideal learning rate? \nThe ideal learning rate is problem-dependent. \nEach model and dataset will have its own ideal learning rate. \n0.01 \n1.0 \n\nBatch size\n\n[**Batch size**](/machine-learning/glossary#batch-size) is a hyperparameter that\nrefers to the number of [**examples**](/machine-learning/glossary#example)\nthe model processes before updating its weights\nand bias. You might think that the model should calculate the loss for *every*\nexample in the dataset before updating the weights and bias. However, when a\ndataset contains hundreds of thousands or even millions of examples, using the\nfull batch isn't practical.\n\nTwo common techniques to get the right gradient on *average* without needing to\nlook at every example in the dataset before updating the weights and bias are\n[**stochastic gradient descent**](/machine-learning/glossary#SGD) and\n[**mini-batch stochastic gradient\ndescent**](/machine-learning/glossary#mini-batch-stochastic-gradient-descent):\n\n- **Stochastic gradient descent (SGD)**: Stochastic gradient descent uses only\n a single example (a batch size of one) per iteration. Given enough\n iterations, SGD works but is very noisy. \"Noise\" refers to variations during\n training that cause the loss to increase rather than decrease during an\n iteration. The term \"stochastic\" indicates that the one example comprising\n each batch is chosen at random.\n\n Notice in the following image how loss slightly fluctuates as the model\n updates its weights and bias using SGD, which can lead to noise in the loss\n graph:\n\n **Figure 25**. Model trained with stochastic gradient descent (SGD) showing\n noise in the loss curve.\n\n Note that using stochastic gradient descent can produce noise throughout the\n entire loss curve, not just near convergence.\n- **Mini-batch stochastic gradient descent (mini-batch SGD)**: Mini-batch\n stochastic gradient descent is a compromise between full-batch and SGD. For\n $ N $ number of data points, the batch size can be any number greater than 1\n and less than $ N $. The model chooses the examples included in each batch\n at random, averages their gradients, and then updates the weights and bias\n once per iteration.\n\n Determining the number of examples for each batch depends on the dataset and\n the available compute resources. In general, small batch sizes behaves like\n SGD, and larger batch sizes behaves like full-batch gradient descent.\n\n **Figure 26**. Model trained with mini-batch SGD.\n\nWhen training a model, you might think that noise is an undesirable\ncharacteristic that should be eliminated. However, a certain amount of noise can\nbe a good thing. In later modules, you'll learn how noise can help a model\n[**generalize**](/machine-learning/glossary#generalization) better and find the\noptimal weights and bias in a [**neural\nnetwork**](/machine-learning/glossary#neural-network).\n\nEpochs\n\nDuring training, an [**epoch**](/machine-learning/glossary#epoch) means that the\nmodel has processed every example in the training set *once* . For example, given\na training set with 1,000 examples and a mini-batch size of 100 examples, it\nwill take the model 10 [**iterations**](/machine-learning/glossary#iteration) to\ncomplete one epoch.\n\nTraining typically requires many epochs. That is, the system needs to process\nevery example in the training set multiple times.\n\nThe number of epochs is a hyperparameter you set before the model begins\ntraining. In many cases, you'll need to experiment with how many epochs it takes\nfor the model to converge. In general, more epochs produces a better model, but\nalso takes more time to train.\n\n**Figure 27**. Full batch versus mini batch.\n\nThe following table describes how batch size and epochs relate to the number of\ntimes a model updates its parameters.\n\n| Batch type | When weights and bias updates occur |\n|----------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Full batch | After the model looks at all the examples in the dataset. For instance, if a dataset contains 1,000 examples and the model trains for 20 epochs, the model updates the weights and bias 20 times, once per epoch. |\n| Stochastic gradient descent | After the model looks at a single example from the dataset. For instance, if a dataset contains 1,000 examples and trains for 20 epochs, the model updates the weights and bias 20,000 times. |\n| Mini-batch stochastic gradient descent | After the model looks at the examples in each batch. For instance, if a dataset contains 1,000 examples, and the batch size is 100, and the model trains for 20 epochs, the model updates the weights and bias 200 times. |\n\nExercise: Check your understanding \n1. What's the best batch size when using mini-batch SGD? \nIt depends \nThe ideal batch size depends on the dataset and the available compute resources \n10 examples per batch \n100 examples per batch \n2. Which of the following statements is true? \nLarger batches are unsuitable for data with many outliers. \nThis statement is false. By averaging more gradients together, larger batch sizes can help reduce the negative effects of having outliers in the data. \nDoubling the learning rate can slow down training. \nThis statement is true. Doubling the learning rate can result in a learning rate that is too large, and therefore cause the weights to \"bounce around,\" increasing the amount of time needed to converge. As always, the best hyperparameters depend on your dataset and available compute resources.\n| **Key terms:**\n|\n| - [Batch size](/machine-learning/glossary#batch-size)\n| - [Epoch](/machine-learning/glossary#epoch)\n| - [Generalize](/machine-learning/glossary#generalization)\n| - [Hyperparameter](/machine-learning/glossary#hyperparameter)\n| - [Iteration](/machine-learning/glossary#iteration)\n| - [Learning rate](/machine-learning/glossary#learning-rate)\n| - [Mini-batch](/machine-learning/glossary#mini-batch)\n| - [Mini-batch stochastic gradient descent](/machine-learning/glossary#mini-batch-stochastic-gradient-descent)\n| - [Neural network](/machine-learning/glossary#neural-network)\n| - [Parameter](/machine-learning/glossary#parameter)\n- [Stochastic gradient descent](/machine-learning/glossary#stochastic-gradient-descent-sgd) \n[Help Center](https://support.google.com/machinelearningeducation)"]]