<jupyter_start><jupyter_text>우선 fake data를 만듭니다.<jupyter_code># linspace(start, end, num) start와 end를 포함하고 그 사이를 균등하게 나누는 num개의 수를 반환 
x = torch.linspace(-5, 5, 200); print(type(x), x.shape)
x = Variable(x); print(type(x), x.shape) 
x_np = x.data.numpy(); print(type(x_np), x_np.shape)<jupyter_output><class 'torch.Tensor'> torch.Size([200])
<class 'torch.Tensor'> torch.Size([200])
<class 'numpy.ndarray'> (200,)<jupyter_text>대표적은 activation funtion을 구성하는 것을 따라 해 봅시다.<jupyter_code>y_relu = F.relu(x).data.numpy()
y_sigmoid = torch.sigmoid(x).data.numpy()
y_tanh = F.tanh(x).data.numpy()
y_softplus = F.softplus(x).data.numpy()<jupyter_output>/home/mbsiot/miniconda3/envs/drlnd/lib/python3.6/site-packages/torch/nn/functional.py:1698: UserWarning: nn.functional.tanh is deprecated. Use torch.tanh instead.
  warnings.warn("nn.functional.tanh is deprecated. Use torch.tanh instead.")<jupyter_text>위에서 정의한 activation function을 plt를 통해서 그려봅니다.<jupyter_code>%matplotlib inline
plt.figure(1, figsize=(8, 6))

plt.subplot(221)
plt.plot(x_np, y_relu, c = 'red', label = 'relu')
plt.ylim((-1, 5))
plt.legend(loc = 'best')

plt.subplot(222)
plt.plot(x_np, y_sigmoid, c = 'red', label = 'sigmoid')
plt.ylim((-0.2, 1.2))
plt.legend(loc = 'best')

plt.subplot(223)
plt.plot(x_np, y_tanh, c = 'red', label = 'tanh')
plt.ylim((-1.2, 1.2))
plt.legend(loc = 'best')

plt.subplot(224)
plt.plot(x_np, y_relu, c = 'red', label = 'softplus')
plt.ylim((-0.2, 6))
plt.legend(loc = 'best')

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1901921802518224, 'fraction_numerical': 0.032471835652750164, 'mean_word_length': 5.62280701754386, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '498919', 'license': 'MIT', 'n_tokens_mistral': 765, 'n_tokens_neox': 739, 'n_words': 121, 'path': 'my_hand/203_activation.ipynb', 'repo_name': 'gogunubuntu/PyTorch-Tutorial', 'size': '1509'}