Skip to content

Latest commit

 

History

History
53 lines (43 loc) · 1.4 KB

README.org

File metadata and controls

53 lines (43 loc) · 1.4 KB

Nx

t = Nx.broadcast(63, {10, 10}) Nx.to_heatmap(t)

t = Nx.iota({28,28}) Nx.to_heatmap(t)

t = Nx.tensor([ [1,2,3], [4,5,6 ] ]) Nx.reverse(t, axes: [0])

t = Nx.broadcast(0, {10, 10}) updates = Nx.tensor([[99, 88, 77], [77, 66, 88]]) t2 = Nx.put_slice(t, [1,2], updates) Nx.to_heatmap(t2)

t = Nx.iota({4,4})

Nx.slice(t, [0,0], [2, 2])

{x,y} = Nx.shape(t)

t1 = Nx.slice_along_axis(t, 0, x-1, axis: 0, strides: 2)

t2 = Nx.slice_along_axis(t1, 0, y-1, axis: 1, strides: 2)

Cross-Entropy Breakout

alias DeepGame.CrossEntropy.BreakoutTrainer, as: BT model = BT.build_model() {:done, trained_params} = BT.train_model(model)

alias DeepGame.CrossEntropy.BreakoutTrainer, as: BT model = BT.build_model() {init_fn, pred_fn} = Axon.build(model) params = init_fn.(Nx.template({1, 5}, :f32), %{})

alias DeepGame.CrossEntropy.BreakoutEnv, as: Env env = Env.reset() env = Env.move_ball_random(env) observations = Env.observations(env)

obs = [ [0.425, -0.575, 0.16, 0.62, 0.5], [0.425, -0.575, 0.20, 0.52, 0.4], [0.425, -0.575, 0.20, 0.30, 0.2] ] Enum.map(obs, fn ob -> BT.select_action(ob, model, params) end)

Gym

alias DeepGame.Game.Breakout, as: Game alias DeepGame.Gym.BreakoutGym, as: Gym game = Game.new() Gym.get_observation(game) |> Nx.to_heatmap()