Slide 7
Slide 7 text
͜Μͳײ͡ͰKeras෩ʹࢼͤ·͢
./*45σʔλͷಡΈࠐΈ
[x_train, y_train, x_test, y_test] = Jnnnx.MNIST.Dataset.load_data()
σʔλͷܗͱਖ਼نԽ
x_train =
x_train
|> Nx.reshape({60000, 28*28}, names: [:batch, :input])
|> Nx.divide(255)
x_test =
x_test
|> Nx.reshape({10000, 28*28}, names: [:batch, :input])
|> Nx.divide(255)
POFIPUFODPEJOH
y_train = y_train |> Jnnnx.Utils.to_categorical(10, names: [:batch, :output])
y_test = y_test |> Jnnnx.Utils.to_categorical(10, names: [:batch, :output])
τϨʔχϯάσʔλΛ༻ֶ͍ͯश
params = Jnnnx.fit(x_train, y_train, epoch: 5, batch_size: 50, learning_rate: 0.01)
ςετσʔλΛ༻͍ͯධՁ
score = Jnnnx.evaluate(params, x_test, y_test)
IO.puts("Accuracy: #{Nx.to_scalar(score)}")