신경망: 상호작용 연습
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
아래의 대화형 연습을 통해 데이터 레이크의 내부 작동 방식을
학습합니다. 먼저, 매개변수와 초매개변수가 어떻게 변경되는지
네트워크의 예측에 영향을 줍니다. 그런 다음 배운 내용을 사용하여
신경망을 학습시킬 수 있습니다.
실습 1
다음 위젯은 다음과 같은 구성으로 신경망을 설정합니다.
- 값이
0.00
, 0.00
, 0.00
인 뉴런이 3개 있는 입력 레이어
- 뉴런이 4개 있는 히든 레이어
- 뉴런이 1개 있는 출력 레이어
- ReLU 활성화 함수가
모든 히든 레이어 노드와 출력 노드는
네트워크의 초기 설정을 검토합니다 (참고: 클릭하지 ▶️ 또는
>| 버튼)을 클릭한 다음 위젯 아래의 작업을 완료합니다.
작업 1
신경망 모델의 세 가지 입력 특성 값은 모두
0.00
네트워크의 각 노드를 클릭하여 초기화된 모든 노드를 확인합니다.
값으로 사용됩니다. 재생 (▶️) 버튼을 누르기 전에 다음 질문에 답하세요.
어떤 종류의 출력 값을
양성, 음성 또는 0 중 어떤 것이 생성될 것으로 예상하나요?
양수 출력 값
긍정적인 답변을 선택했습니다.
출력 값을 반환합니다. 아래의 안내를 따르세요.
입력 데이터에 대한 추론을 수행하고 맞는지 확인할 수 있습니다.
음수 출력 값
제외어를 선택했습니다.
출력 값을 반환합니다. 아래의 안내를 따르세요.
입력 데이터에 대한 추론을 수행하고 맞는지 확인할 수 있습니다.
출력 값 0
출력을 선택함
값 0으로 설정합니다. 아래의 안내를 따르세요.
입력 데이터에 대한 추론을 수행하고 맞는지 확인할 수 있습니다.
이제 네트워크 위에 있는 재생 (▶️) 버튼을 클릭하고 히든 레이어를 모두 시청해 보세요.
출력 노드 값이 채워집니다 위의 답변이 정확했나요?
설명을 보려면 여기를 클릭하세요.
얻을 수 있는 정확한 출력 값은 가중치와
편향 매개변수는 무작위로 초기화됩니다 하지만 각 뉴런은
값이 0이면 입력 레이어에서 가중치를
히든 레이어 노드 값은 모두 0으로 처리됩니다. 예를 들어 첫 번째
히든 레이어 노드 계산은 다음과 같습니다.
y = ReLU(w11* 0.00 + w21* 0.00 + w31* 0.00 + b)
y = ReLU(b)
따라서 각 히든 레이어 노드의 값은
편향 (b)로, b가 음수이면 0, b가 0이면 b 자체입니다.
긍정적입니다
그러면 출력 노드의 값은 다음과 같이 계산됩니다.
y = ReLU(w11* x11 + w21* x21)
+ w31* x31 + w41* x41 + b)
작업 2
신경망을 수정하기 전에 다음 질문에 답하세요.
히든 레이어를 추가하는 경우
신경망에 첫 번째 히든 레이어에 연결하고 이 새로운 레이어에 3개의 노드를 제공하여
입력 및 가중치/편향 매개변수는 동일하며, 계산
어떤 영향을 받게 되나요?
모든 노드
(입력 노드 제외)
선택한 모든
입력 노드를 제외한 네트워크의 노드입니다.
신경망을 업데이트하고
맞습니다.
단지 포드의 노드만
첫 번째 히든 레이어
선택한
노드 수로 구성됩니다. 아래의 안내를 따르세요.
신경망을 업데이트하고
정답을 확인할 수 있습니다
출력 노드만
선택한
출력 노드를 참조하세요. 아래 안내에 따라
정답인지 확인할 수 있습니다
이제 다음과 같이 신경망을 수정하여 노드가 3개인 새로운 히든 레이어를 추가합니다.
- 텍스트 히든 레이어 1개 왼쪽에 있는 + 버튼을 클릭하여 새 레이어를 추가합니다.
히든 레이어를 생성합니다
- 새 히든 레이어 위의 + 버튼을 두 번 클릭하여 노드를 2개 더 추가합니다.
레이어에 추가합니다
위의 답변이 정확했나요?
설명을 보려면 여기를 클릭하세요.
출력 노드만 변경됩니다. 이 신경망의 추론은
'feed-forward' (계산이 처음부터 끝까지 진행됨), 덧셈이
새 레이어가 추가된 이후의 노드에만 영향을 미칩니다
선행하는 레이어가 아니라 레이어에 있습니다
작업 3
네트워크의 첫 번째 히든 레이어에서 두 번째 노드 (상단) 클릭
그래프로 확인할 수 있습니다. 네트워크 구성을 변경하기 전에
다음 질문에 답하세요.
이
가중치 w12 (첫 번째 입력 노드 x1 아래에 표시됨),
어떤 다른 노드에도 일부 입력의 경우 계산에 영향을 미칠 수 있음
어떻게 해야 할까요?
없음
없음을 선택했습니다.
를 참고하세요. 아래 안내에 따라 신경망을 업데이트하고
정답인지 확인할 수 있습니다.
의 두 번째 노드는
첫 번째 히든 레이어, 두 번째 히든 레이어의 모든 노드, 그리고
출력 노드와 일치합니다
두 번째 항목을 선택했습니다.
첫 번째 히든 레이어의 노드, 두 번째 히든 레이어의 모든 노드,
출력 노드를 참조하세요. 아래의 안내를 따르세요.
신경망을 업데이트하고
정답을 확인할 수 있습니다
클러스터의 모든 노드는
첫 번째 히든 레이어, 두 번째 히든 레이어, 출력 레이어로 구성됩니다.
선택한 모든
첫 번째 히든 레이어, 두 번째 히든 레이어,
출력 레이어와는 다릅니다. 아래의 안내를 따르세요.
신경망을 업데이트하고
정답을 확인할 수 있습니다
이제 가중치 w12(
첫 번째 입력 노드 x1)의 값을 5.00
로 변경하고 Enter 키를 누릅니다.
그래프의 업데이트를 확인합니다.
답변이 정확했나요? 답변을 확인할 때는 주의해야 합니다. 노드가
값이 변경되지 않으면 기본 계산이 변경되지 않았다는 뜻인가요?
설명을 보려면 여기를 클릭하세요.
첫 번째 히든 레이어에서 영향을 받는 유일한 노드는 두 번째 노드(
)을 입력합니다. 첫 번째 노드의 다른 노드에 대한 값은
히든 레이어에는 w12가 매개변수로 포함되지 않으므로
있습니다. 두 번째 히든 레이어의 모든 노드가 영향을 받습니다.
첫 번째 노드의 두 번째 노드 값에 따라
히든 레이어입니다. 마찬가지로 출력 노드 값은
두 번째 히든 레이어의 노드 값에 따라 달라집니다.
답변이 '없음'이라고 생각하셨나요? 포드의 노드 값이
가중치 값을 변경했을 때 네트워크를 변경했다면 어떻게 해야 할까요? 참고: 기본
노드의 값을 변경하지 않아도 노드 계산이 변경될 수 있음
(예: ReLU(0)와 ReLU(–5)는 모두 0의 출력을 생성합니다.
단지 '네트워크'가 어떻게 영향을 받았는지
노드 값을 보고 계산 결과도 검토하세요
실습 2
특성 교차 실습에서
범주형 데이터 모듈
수동으로 특성 교차를 구성하여
비선형 데이터에 맞도록 했습니다.
이제 신경망을 빌드할 수 있는지 확인해 보겠습니다.
비선형 데이터를 맞추는 방법을 배웠습니다.
과제: 주황색 점과 주황색 점을 구분할 수 있는 신경망을 구성해 보세요.
두 데이터 포인트에서 0.2 미만의 손실을
학습 데이터와 테스트 데이터입니다.
안내:
아래의 대화형 위젯에서:
- 텍스트, 이미지, 오디오, 동영상 등
다음 구성 설정을 구성합니다.
<ph type="x-smartling-placeholder">
</ph>
- + 및 - 버튼을 클릭하여 히든 레이어를 추가하거나 삭제할 수 있습니다.
네트워크 다이어그램의 HIDDEN LAYERS 제목 왼쪽에 있습니다.
- + 및 - 기호를 클릭하여 히든 레이어에서 뉴런을 추가하거나 삭제합니다.
히든 레이어 열 위에 버튼이 있습니다.
- 학습률에서 새 값을 선택하여 학습률을 변경합니다.
드롭다운을 선택합니다.
- 다음에서 새 값을 선택하여 활성화 함수를 변경합니다.
활성화 드롭다운을 선택합니다.
- 다이어그램 위에 있는 재생 (▶️) 버튼을 클릭하여 신경망을 학습시킵니다.
모델을 학습시킵니다.
- 학습으로 데이터에 적합한 모델의 시각화 관찰
진행되며
테스트 손실 및
학습 손실 값이
Output(출력) 섹션을 확인합니다.
- 모델이 테스트 및 학습 데이터에서 0.2 미만의 손실을 달성하지 못하면
재설정을 클릭하고 다른 구성으로 1~3단계를 반복합니다.
설정을 변경할 수 있습니다. 원하는 결과를 얻을 때까지 이 과정을 반복합니다.
여기를 클릭하여 솔루션을 확인하세요
다음과 같은 방법으로 0.2 미만의 테스트 손실과 학습 손실을 모두 달성할 수 있었습니다.
- 뉴런 3개가 포함된 히든 레이어 1개를 추가합니다.
- 학습률 0.01 선택
- ReLU의 활성화 함수 선택
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2024-08-16(UTC)
[null,null,["최종 업데이트: 2024-08-16(UTC)"],[],[],null,["# Neural networks: Interactive exercises\n\nIn the interactive exercises below, you'll further explore the inner workings of\nneural networks. First, you'll see how parameter and hyperparameter changes\naffect the network's predictions. Then you'll use what you've learned to train a\nneural network to fit nonlinear data.\n\nExercise 1\n----------\n\nThe following widget sets up a neural network with the following configuration:\n\n- Input layer with 3 neurons containing the values `0.00`, `0.00`, and `0.00`\n- Hidden layer with 4 neurons\n- Output layer with 1 neuron\n- [**ReLU**](/machine-learning/glossary#ReLU) activation function applied to all hidden layer nodes and the output node\n\nReview the initial setup of the network (note: **do not** click the **▶️** or\n**\\\u003e\\|** buttons yet), and then complete the tasks below the widget.\n\n### Task 1\n\nThe values for the three input features to the neural network model are all\n`0.00`. Click each of the nodes in the network to see all the initialized\nvalues. Before hitting the Play (**▶️**) button, answer this question: \nWhat kind of output value do you think will be produced: positive, negative, or 0? \nPositive output value \nYou chose **positive\noutput value**. Follow the instructions below to perform inference on the input data and see if you're right. \nNegative output value \nYou chose **negative\noutput value**. Follow the instructions below to perform inference on the input data and see if you're right. \nOutput value of 0 \nYou chose **output\nvalue of 0**. Follow the instructions below to perform inference on the input data and see if you're right.\n\nNow click the Play (▶️) button above the network, and watch all the hidden-layer\nand output node values populate. Was your answer above correct? \n**Click here for an explanation**\n\nThe exact output value you get will vary based on how the weight\nand bias parameters are randomly initialized. However, since each neuron\nin the input layer has a value of 0, the weights used to calculate the\nhidden-layer node values will all be zeroed out. For example, the first\nhidden layer node calculation will be:\n\ny = ReLU(w~11~\\* 0.00 + w~21~\\* 0.00 + w~31~\\* 0.00 + b)\n\ny = ReLU(b)\n\nSo each hidden-layer node's value will be equal to the ReLU value of the\nbias (b), which will be 0 if b is negative and b itself if b is 0 or\npositive.\n\nThe value of the output node will then be calculated as follows:\n\ny = ReLU(w~11~\\* x~11~ + w~21~\\* x~21~\n+ w~31~\\* x~31~ + w~41~\\* x~41~ + b)\n\n### Task 2\n\nBefore modifying the neural network, answer the following question: \nIf you add another hidden layer to the neural network after the first hidden layer, and give this new layer 3 nodes, keeping all input and weight/bias parameters the same, which other nodes' calculations will be affected? \nAll the nodes in the network, except the input nodes \nYou chose **all the\nnodes in the network, except the input nodes**. Follow the instructions below to update the neural network and see if you're correct. \nJust the nodes in the first hidden layer \nYou chose **just the\nnodes in the first hidden layer**. Follow the instructions below to update the neural network and see if you're correct. \nJust the output node \nYou chose **just the\noutput node**. Follow the instructions below to update the neural network and see if you're correct.\n\nNow modify the neural network to add a new hidden layer with 3 nodes as follows:\n\n1. Click the **+** button to the left of the text **1 hidden layer** to add a new hidden layer before the output layer.\n2. Click the **+** button above the new hidden layer twice to add 2 more nodes to the layer.\n\nWas your answer above correct? \n**Click here for an explanation**\n\nOnly the output node changes. Because inference for this neural network\nis \"feed-forward\" (calculations progress from start to finish), the addition\nof a new layer to the network will only affect nodes *after* the new\nlayer, not those that precede it.\n\n### Task 3\n\nClick the second node (from the top) in the first hidden layer of the network\ngraph. Before making any changes to the network configuration, answer the\nfollowing question: \nIf you change the value of the weight w~12~ (displayed below the first input node, x~1~), which other nodes' calculations *could* be affected for some input values? \nNone \nYou chose **none**. Follow the instructions below to update the neural network and see if you're correct. \nThe second node in the first hidden layer, all the nodes in the second hidden layer, and the output node. \nYou chose **the second\nnode in the first hidden layer, all the nodes in the second hidden layer,\nand the output node**. Follow the instructions below to update the neural network and see if you're correct. \nAll the nodes in the first hidden layer, the second hidden layer, and the output layer. \nYou chose **all the\nnodes in the first hidden layer, the second hidden layer, and the\noutput layer**. Follow the instructions below to update the neural network and see if you're correct.\n\nNow, click in the text field for the weight w~12~ (displayed below the\nfirst input node, x~1~), change its value to `5.00`, and hit Enter.\nObserve the updates to the graph.\n\nWas your answer correct? Be careful when verifying your answer: if a node\nvalue doesn't change, does that mean the underlying calculation didn't change? \n**Click here for an explanation**\n\nThe only node affected in the first hidden layer is the second node (the\none you clicked). The value calculations for the other nodes in the first\nhidden layer do not contain w~12~ as a parameter, so they are not\naffected. All the nodes in the second hidden layer are affected, as their\ncalculations depend on the value of the second node in the first\nhidden layer. Similarly, the output node value is affected because its\ncalculations depend on the values of the nodes in the second hidden layer.\n\nDid you think the answer was \"none\" because none of the node values in the\nnetwork changed when you changed the weight value? Note that an underlying\ncalculation for a node may change without changing the node's value\n(e.g., ReLU(0) and ReLU(--5) both produce an output of 0).\nDon't make assumptions about how the network was affected just by\nlooking at the node values; make sure to review the calculations as well.\n\nExercise 2\n----------\n\nIn the [Feature cross exercises](/machine-learning/crash-course/categorical-data/feature-cross-exercises)\nin the [Categorical data module](/machine-learning/crash-course/categorical-data),\nyou manually constructed feature crosses to fit nonlinear data.\nNow, you'll see if you can build a neural network that can automatically learn\nhow to fit nonlinear data during training.\n\n**Your task:** configure a neural network that can separate the orange dots from\nthe blue dots in the diagram below, achieving a loss of less than 0.2 on both\nthe training and test data.\n\n**Instructions:**\n\nIn the interactive widget below:\n\n1. Modify the neural network hyperparameters by experimenting with some of the following config settings:\n - Add or remove hidden layers by clicking the **+** and **-** buttons to the left of the **HIDDEN LAYERS** heading in the network diagram.\n - Add or remove neurons from a hidden layer by clicking the **+** and **-** buttons above a hidden-layer column.\n - Change the learning rate by choosing a new value from the **Learning rate** drop-down above the diagram.\n - Change the activation function by choosing a new value from the **Activation** drop-down above the diagram.\n2. Click the Play (▶️) button above the diagram to train the neural network model using the specified parameters.\n3. Observe the visualization of the model fitting the data as training progresses, as well as the [**Test loss**](/machine-learning/glossary#test-loss) and [**Training loss**](/machine-learning/glossary#training-loss) values in the **Output** section.\n4. If the model does not achieve loss below 0.2 on the test and training data, click reset, and repeat steps 1--3 with a different set of configuration settings. Repeat this process until you achieve the preferred results.\n\n**Click here for our solution**\n\nWe were able to achieve both test and training loss below 0.2 by:\n\n- Adding 1 hidden layer containing 3 neurons.\n- Choosing a learning rate of 0.01.\n- Choosing an activation function of ReLU. \n| **Key terms:**\n|\n| - [Test loss](/machine-learning/glossary#test-loss)\n- [Training loss](/machine-learning/glossary#training-loss) \n[Help Center](https://support.google.com/machinelearningeducation)"]]