<jupyter_start><jupyter_text>jupyter에서 matplot를 보려면, backend를 기본으로 놔두어야 하는 것같다.<jupyter_code>""" Softmax """

_scores = [3.0, 1.0, 0.2]
scores = []

for i in _scores:
    scores.append(i / 1)

print(scores)

import numpy as np

def softmax(x):
    """Compute softmax values for each sets of scores in x."""
    return np.exp(x) / np.sum(np.exp(x), axis=0)

print(softmax(scores))

# Plot softmax curves
#import matplotlib
#matplotlib.use('TkAgg')

import matplotlib.pyplot as plt
x = np.arange(-2.0, 6.0, 0.1)
scores = np.vstack([x, np.ones_like(x), 0.2 * np.ones_like(x)])

plt.plot(x, softmax(scores).T, linewidth=2)
plt.show()<jupyter_output>[3.0, 1.0, 0.2]
[0.8360188  0.11314284 0.05083836]
{'fraction_non_alphanumeric': 0.1712230215827338, 'fraction_numerical': 0.07050359712230216, 'mean_word_length': 4.2330827067669174, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '73467', 'license': 'MIT', 'n_tokens_mistral': 356, 'n_tokens_neox': 334, 'n_words': 70, 'path': 'tf/example/matplot.ipynb', 'repo_name': 'tolkien/misc', 'size': '695'}