AJMC2002 commited on
Commit
f4ccc2a
1 Parent(s): 75688f9

Upload lab1.livemd

Browse files
Files changed (1) hide show
  1. public-apps/lab1.livemd +1726 -0
public-apps/lab1.livemd ADDED
@@ -0,0 +1,1726 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- livebook:{"persist_outputs":true} -->
2
+
3
+ # Cleaned vs Dirty V2
4
+
5
+ ```elixir
6
+ Mix.install(
7
+ [
8
+ {:stb_image, "~> 0.5.2"},
9
+ {:axon, "~> 0.5"},
10
+ {:polaris, "~> 0.1"},
11
+ {:exla, "~> 0.5"},
12
+ {:explorer, "~> 0.8.0"},
13
+ {:nx, "~> 0.5"},
14
+ {:kino_ripmd, github: "clm-a/kino_ripmd"},
15
+ {:kino_explorer, "~> 0.1.0"},
16
+ {:kino_vega_lite, "~> 0.1.0"},
17
+ {:kino, "~> 0.10.0"},
18
+ {:csv, "~> 3.2"}
19
+ ],
20
+ config: [
21
+ nx: [
22
+ default_backend: EXLA.Backend,
23
+ default_defn_options: [compiler: EXLA]
24
+ ],
25
+ exla: [
26
+ default_client: :cuda,
27
+ clients: [
28
+ cuda: [platform: :cuda],
29
+ rocm: [platform: :rocm],
30
+ tpu: [platform: :tpu],
31
+ host: [platform: :host]
32
+ ],
33
+ memory_fraction: 0.9,
34
+ preallocate: false
35
+ ]
36
+ ],
37
+ system_env: [
38
+ XLA_TARGET: "cuda120"
39
+ ]
40
+ )
41
+ ```
42
+
43
+ ## Goal
44
+
45
+ _Hi! It is boring to wash the dishes. Luckily, half of them are already clean. Train a classifier to determine clean ones to save time for the new machine learning course ;)_
46
+
47
+ _It is a few shot learning competition. We have a dataset of 20 clean and 20 dirty plates in train and hundreds of plates in test. Good luck!_
48
+
49
+ Igor.Slinko. (2019). Cleaned vs Dirty V2. Kaggle. https://kaggle.com/competitions/platesv2
50
+
51
+ ## Setting up the model
52
+
53
+ ```elixir
54
+ alias Axon.Loop.State
55
+ import Nx.Defn
56
+
57
+ directories =
58
+ "/home/le-moski/Documents/FEFU/7S/AI/lab1-dirtyplates/platesv2/plates/train/{cleaned,dirty}/*.jpg"
59
+
60
+ batch_size = 8
61
+ image_channels = 3
62
+ image_w = 256
63
+ image_h = 256
64
+ channel_value_max = 255
65
+
66
+ cleaned_class = Nx.tensor([1, 0], type: {:u, 8})
67
+ dirty_class = Nx.tensor([0, 1], type: {:u, 8})
68
+ ```
69
+
70
+ <!-- livebook:{"output":true} -->
71
+
72
+ ```
73
+ #Nx.Tensor<
74
+ u8[2]
75
+ EXLA.Backend<cuda:0, 0.463371035.4063887383.206028>
76
+ [0, 1]
77
+ >
78
+ ```
79
+
80
+ ```elixir
81
+ parse_img = fn filename ->
82
+ class =
83
+ if Path.dirname(filename)
84
+ |> String.split("/")
85
+ |> List.last() == "cleaned" do
86
+ cleaned_class
87
+ else
88
+ dirty_class
89
+ end
90
+
91
+ {:ok, img} = StbImage.read_file(filename)
92
+
93
+ img = StbImage.resize(img, image_h, image_w)
94
+
95
+ {StbImage.to_nx(img), class}
96
+ end
97
+ ```
98
+
99
+ <!-- livebook:{"output":true} -->
100
+
101
+ ```
102
+ #Function<42.39164016/1 in :erl_eval.expr/6>
103
+ ```
104
+
105
+ ```elixir
106
+ data =
107
+ Path.wildcard(directories)
108
+ |> Enum.shuffle()
109
+ |> Stream.chunk_every(batch_size, batch_size)
110
+ |> Task.async_stream(fn batch ->
111
+ {imgs, classes} = batch |> Enum.map(&parse_img.(&1)) |> Enum.unzip()
112
+ {Nx.stack(imgs), Nx.stack(classes)}
113
+ end)
114
+ |> Stream.map(fn {:ok, {imgs, classes}} -> {imgs |> Nx.divide(channel_value_max), classes} end)
115
+ ```
116
+
117
+ <!-- livebook:{"output":true} -->
118
+
119
+ ```
120
+ #Stream<[
121
+ enum: #Function<3.112894672/2 in Task.build_stream/3>,
122
+ funs: [#Function<50.38948127/1 in Stream.map/2>]
123
+ ]>
124
+ ```
125
+
126
+ ```elixir
127
+ model =
128
+ Axon.input("input", shape: {nil, image_w, image_h, image_channels})
129
+ |> Axon.conv(64, kernel_size: {3, 3})
130
+ |> Axon.batch_norm()
131
+ |> Axon.relu()
132
+ |> Axon.max_pool(kernel_size: {2, 2})
133
+ |> Axon.conv(128, kernel_size: {3, 3})
134
+ |> Axon.batch_norm()
135
+ |> Axon.relu()
136
+ |> Axon.max_pool(kernel_size: {2, 2})
137
+ |> Axon.flatten()
138
+ |> Axon.dense(256, activation: :relu)
139
+ |> Axon.dropout()
140
+ |> Axon.dense(2, activation: :softmax)
141
+ ```
142
+
143
+ <!-- livebook:{"output":true} -->
144
+
145
+ ```
146
+ #Axon<
147
+ inputs: %{"input" => {nil, 256, 256, 3}}
148
+ outputs: "softmax_0"
149
+ nodes: 15
150
+ >
151
+ ```
152
+
153
+ ```elixir
154
+ optimizer = Polaris.Optimizers.adam(learning_rate: 1.0e-3)
155
+ centralized_optimizer = Polaris.Updates.compose(Polaris.Updates.centralize(), optimizer)
156
+ epochs = 4
157
+
158
+ model_state =
159
+ model
160
+ |> Axon.Loop.trainer(:binary_cross_entropy, centralized_optimizer, log: 1)
161
+ |> Axon.Loop.metric(:accuracy)
162
+ |> Axon.Loop.run(data, %{}, epochs: epochs, iterations: 30, compiler: EXLA)
163
+ ```
164
+
165
+ <!-- livebook:{"output":true} -->
166
+
167
+ ```
168
+
169
+ 08:12:25.650 [debug] Forwarding options: [compiler: EXLA] to JIT compiler
170
+
171
+ 08:12:37.790 [warning] Allocator (GPU_0_bfc) ran out of memory trying to allocate 480.50MiB (rounded to 503840768)requested by op
172
+
173
+ 08:12:37.791 [info] BFCAllocator dump for GPU_0_bfc
174
+
175
+ 08:12:37.791 [info] Bin (256): Total Chunks: 102, Chunks in use: 102. 25.5KiB allocated for chunks. 25.5KiB in use in bin. 11.5KiB client-requested in use in bin.
176
+
177
+ 08:12:37.791 [info] Bin (512): Total Chunks: 20, Chunks in use: 20. 10.0KiB allocated for chunks. 10.0KiB in use in bin. 10.0KiB client-requested in use in bin.
178
+
179
+ 08:12:37.792 [info] Bin (1024): Total Chunks: 4, Chunks in use: 4. 4.0KiB allocated for chunks. 4.0KiB in use in bin. 4.0KiB client-requested in use in bin.
180
+
181
+ 08:12:37.792 [info] Bin (2048): Total Chunks: 16, Chunks in use: 16. 44.0KiB allocated for chunks. 44.0KiB in use in bin. 43.0KiB client-requested in use in bin.
182
+
183
+ 08:12:37.793 [info] Bin (4096): Total Chunks: 4, Chunks in use: 4. 16.0KiB allocated for chunks. 16.0KiB in use in bin. 16.0KiB client-requested in use in bin.
184
+
185
+ 08:12:37.793 [info] Bin (8192): Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
186
+
187
+ 08:12:37.795 [info] Bin (16384): Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
188
+
189
+ 08:12:37.795 [info] Bin (32768): Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
190
+
191
+ 08:12:37.796 [info] Bin (65536): Total Chunks: 8, Chunks in use: 8. 624.5KiB allocated for chunks. 624.5KiB in use in bin. 576.0KiB client-requested in use in bin.
192
+
193
+ 08:12:37.797 [info] Bin (131072): Total Chunks: 8, Chunks in use: 8. 1.20MiB allocated for chunks. 1.20MiB in use in bin. 1.12MiB client-requested in use in bin.
194
+
195
+ 08:12:37.797 [info] Bin (262144): Total Chunks: 4, Chunks in use: 4. 1.12MiB allocated for chunks. 1.12MiB in use in bin. 1.12MiB client-requested in use in bin.
196
+
197
+ 08:12:37.797 [info] Bin (524288): Total Chunks: 2, Chunks in use: 0. 1.54MiB allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
198
+
199
+ 08:12:37.798 [info] Bin (1048576): Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
200
+
201
+ 08:12:37.798 [info] Bin (2097152): Total Chunks: 4, Chunks in use: 1. 9.57MiB allocated for chunks. 2.50MiB in use in bin. 2.50MiB client-requested in use in bin.
202
+
203
+ 08:12:37.798 [info] Bin (4194304): Total Chunks: 2, Chunks in use: 1. 11.25MiB allocated for chunks. 6.00MiB in use in bin. 6.00MiB client-requested in use in bin.
204
+
205
+ ```
206
+
207
+ <!-- livebook:{"output":true} -->
208
+
209
+ ```
210
+
211
+ 08:12:37.798 [info] Bin (8388608): Total Chunks: 1, Chunks in use: 0. 10.49MiB allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
212
+
213
+ 08:12:37.799 [info] Bin (16777216): Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
214
+
215
+ 08:12:37.799 [info] Bin (33554432): Total Chunks: 4, Chunks in use: 4. 133.00MiB allocated for chunks. 133.00MiB in use in bin. 133.00MiB client-requested in use in bin.
216
+
217
+ 08:12:37.800 [info] Bin (67108864): Total Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
218
+
219
+ 08:12:37.800 [info] Bin (134217728): Total Chunks: 6, Chunks in use: 4. 994.80MiB allocated for chunks. 600.00MiB in use in bin. 600.00MiB client-requested in use in bin.
220
+
221
+ 08:12:37.801 [info] Bin (268435456): Total Chunks: 2, Chunks in use: 0. 629.22MiB allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.
222
+
223
+ 08:12:37.801 [info] Bin for 480.50MiB was 256.00MiB, Chunk State:
224
+
225
+ 08:12:37.801 [info] Size: 295.97MiB | Requested Size: 153.12MiB | in_use: 0 | bin_num: 20, prev: Size: 223.5KiB | Requested Size: 144.0KiB | in_use: 1 | bin_num: -1, next: Size: 144.0KiB | Requested Size: 144.0KiB | in_use: 1 | bin_num: -1
226
+
227
+ 08:12:37.803 [info] Size: 333.25MiB | Requested Size: 153.12MiB | in_use: 0 | bin_num: 20, prev: Size: 33.25MiB | Requested Size: 33.25MiB | in_use: 1 | bin_num: -1
228
+
229
+ 08:12:37.804 [info] Next region of size 1880004864
230
+
231
+ 08:12:37.804 [info] Free at 736310000000 of size 2575616 next 65
232
+
233
+ 08:12:37.806 [info] InUse at 736310274d00 of size 256 next 1947
234
+
235
+ 08:12:37.806 [info] InUse at 736310274e00 of size 73728 next 438
236
+
237
+ 08:12:37.807 [info] InUse at 736310286e00 of size 73728 next 1507
238
+
239
+ 08:12:37.807 [info] InUse at 736310298e00 of size 115712 next 1943
240
+
241
+ 08:12:37.807 [info] InUse at 7363102b5200 of size 256 next 420
242
+
243
+ 08:12:37.808 [info] Free at 7363102b5300 of size 786688 next 238
244
+
245
+ 08:12:37.808 [info] InUse at 736310375400 of size 256 next 259
246
+
247
+ 08:12:37.809 [info] Free at 736310375500 of size 10996736 next 3677
248
+
249
+ 08:12:37.809 [info] InUse at 736310df2100 of size 2618880 next 1580
250
+
251
+ 08:12:37.810 [info] Free at 736311071700 of size 2671872 next 291
252
+
253
+ 08:12:37.810 [info] InUse at 7363112fdc00 of size 147456 next 1912
254
+
255
+ 08:12:37.810 [info] InUse at 736311321c00 of size 147456 next 386
256
+
257
+ 08:12:37.811 [info] InUse at 736311345c00 of size 148736 next 39
258
+
259
+ 08:12:37.811 [info] Free at 73631136a100 of size 5500672 next 1277
260
+
261
+ 08:12:37.811 [info] InUse at 7363118a9000 of size 294912 next 3916
262
+
263
+ 08:12:37.811 [info] InUse at 7363118f1000 of size 294912 next 3549
264
+
265
+ 08:12:37.812 [info] InUse at 736311939000 of size 294912 next 1748
266
+
267
+ 08:12:37.812 [info] InUse at 736311981000 of size 294912 next 1904
268
+
269
+ 08:12:37.812 [info] InUse at 7363119c9000 of size 73728 next 1575
270
+
271
+ 08:12:37.812 [info] InUse at 7363119db000 of size 3584 next 1797
272
+
273
+ 08:12:37.812 [info] InUse at 7363119dbe00 of size 3584 next 1919
274
+
275
+ 08:12:37.813 [info] InUse at 7363119dcc00 of size 3584 next 230
276
+
277
+ 08:12:37.813 [info] InUse at 7363119dda00 of size 3584 next 1730
278
+
279
+ 08:12:37.813 [info] InUse at 7363119de800 of size 2048 next 1774
280
+
281
+ 08:12:37.813 [info] InUse at 7363119df000 of size 2048 next 1639
282
+
283
+ 08:12:37.813 [info] InUse at 7363119df800 of size 2048 next 1728
284
+
285
+ 08:12:37.814 [info] InUse at 7363119e0000 of size 2048 next 1531
286
+
287
+ 08:12:37.814 [info] InUse at 7363119e0800 of size 1024 next 1504
288
+
289
+ 08:12:37.814 [info] InUse at 7363119e0c00 of size 1024 next 1498
290
+
291
+ 08:12:37.815 [info] InUse at 7363119e1000 of size 1024 next 1636
292
+
293
+ 08:12:37.815 [info] InUse at 7363119e1400 of size 1024 next 1742
294
+
295
+ 08:12:37.815 [info] InUse at 7363119e1800 of size 512 next 1855
296
+
297
+ 08:12:37.815 [info] InUse at 7363119e1a00 of size 512 next 2919
298
+
299
+ 08:12:37.816 [info] InUse at 7363119e1c00 of size 512 next 342
300
+
301
+ 08:12:37.816 [info] InUse at 7363119e1e00 of size 512 next 1903
302
+
303
+ 08:12:37.816 [info] InUse at 7363119e2000 of size 512 next 3877
304
+
305
+ 08:12:37.816 [info] InUse at 7363119e2200 of size 512 next 1808
306
+
307
+ 08:12:37.816 [info] InUse at 7363119e2400 of size 512 next 1749
308
+
309
+ 08:12:37.817 [info] InUse at 7363119e2600 of size 512 next 3830
310
+
311
+ 08:12:37.817 [info] InUse at 7363119e2800 of size 512 next 1832
312
+
313
+ 08:12:37.817 [info] InUse at 7363119e2a00 of size 512 next 1656
314
+
315
+ 08:12:37.817 [info] InUse at 7363119e2c00 of size 512 next 1491
316
+
317
+ 08:12:37.817 [info] InUse at 7363119e2e00 of size 512 next 3251
318
+
319
+ 08:12:37.818 [info] InUse at 7363119e3000 of size 512 next 3922
320
+
321
+ 08:12:37.818 [info] InUse at 7363119e3200 of size 512 next 3914
322
+
323
+ 08:12:37.818 [info] InUse at 7363119e3400 of size 512 next 3755
324
+
325
+ 08:12:37.818 [info] InUse at 7363119e3600 of size 512 next 1768
326
+
327
+ 08:12:37.818 [info] InUse at 7363119e3800 of size 512 next 1488
328
+
329
+ 08:12:37.819 [info] InUse at 7363119e3a00 of size 512 next 1831
330
+
331
+ 08:12:37.819 [info] InUse at 7363119e3c00 of size 512 next 1689
332
+
333
+ 08:12:37.819 [info] InUse at 7363119e3e00 of size 512 next 1846
334
+
335
+ 08:12:37.819 [info] InUse at 7363119e4000 of size 256 next 1861
336
+
337
+ 08:12:37.821 [info] InUse at 7363119e4100 of size 256 next 1708
338
+
339
+ 08:12:37.821 [info] InUse at 7363119e4200 of size 256 next 3907
340
+
341
+ 08:12:37.821 [info] InUse at 7363119e4300 of size 256 next 1828
342
+
343
+ 08:12:37.822 [info] InUse at 7363119e4400 of size 256 next 1892
344
+
345
+ 08:12:37.822 [info] InUse at 7363119e4500 of size 256 next 1759
346
+
347
+ 08:12:37.822 [info] InUse at 7363119e4600 of size 256 next 310
348
+
349
+ 08:12:37.822 [info] InUse at 7363119e4700 of size 256 next 1670
350
+
351
+ 08:12:37.823 [info] InUse at 7363119e4800 of size 256 next 1758
352
+
353
+ 08:12:37.823 [info] InUse at 7363119e4900 of size 256 next 3781
354
+
355
+ 08:12:37.823 [info] InUse at 7363119e4a00 of size 256 next 1851
356
+
357
+ 08:12:37.823 [info] InUse at 7363119e4b00 of size 256 next 1741
358
+
359
+ 08:12:37.823 [info] InUse at 7363119e4c00 of size 256 next 1674
360
+
361
+ 08:12:37.823 [info] InUse at 7363119e4d00 of size 256 next 274
362
+
363
+ 08:12:37.824 [info] InUse at 7363119e4e00 of size 256 next 1666
364
+
365
+ 08:12:37.824 [info] InUse at 7363119e4f00 of size 256 next 1879
366
+
367
+ 08:12:37.824 [info] InUse at 7363119e5000 of size 256 next 1744
368
+
369
+ 08:12:37.824 [info] InUse at 7363119e5100 of size 256 next 72
370
+
371
+ 08:12:37.824 [info] InUse at 7363119e5200 of size 256 next 1755
372
+
373
+ 08:12:37.824 [info] InUse at 7363119e5300 of size 256 next 426
374
+
375
+ 08:12:37.825 [info] InUse at 7363119e5400 of size 256 next 1702
376
+
377
+ 08:12:37.825 [info] InUse at 7363119e5500 of size 256 next 1785
378
+
379
+ 08:12:37.825 [info] InUse at 7363119e5600 of size 256 next 1553
380
+
381
+ 08:12:37.825 [info] InUse at 7363119e5700 of size 256 next 1517
382
+
383
+ 08:12:37.825 [info] InUse at 7363119e5800 of size 256 next 1733
384
+
385
+ 08:12:37.825 [info] InUse at 7363119e5900 of size 256 next 3883
386
+
387
+ 08:12:37.825 [info] InUse at 7363119e5a00 of size 256 next 146
388
+
389
+ 08:12:37.826 [info] InUse at 7363119e5b00 of size 256 next 1726
390
+
391
+ 08:12:37.826 [info] InUse at 7363119e5c00 of size 256 next 1678
392
+
393
+ 08:12:37.826 [info] InUse at 7363119e5d00 of size 256 next 3708
394
+
395
+ 08:12:37.826 [info] InUse at 7363119e5e00 of size 256 next 1539
396
+
397
+ 08:12:37.826 [info] InUse at 7363119e5f00 of size 256 next 1684
398
+
399
+ 08:12:37.826 [info] InUse at 7363119e6000 of size 256 next 1751
400
+
401
+ 08:12:37.827 [info] InUse at 7363119e6100 of size 256 next 1552
402
+
403
+ 08:12:37.827 [info] InUse at 7363119e6200 of size 256 next 1736
404
+
405
+ 08:12:37.827 [info] InUse at 7363119e6300 of size 256 next 1543
406
+
407
+ 08:12:37.827 [info] InUse at 7363119e6400 of size 256 next 1723
408
+
409
+ 08:12:37.827 [info] InUse at 7363119e6500 of size 256 next 325
410
+
411
+ 08:12:37.827 [info] InUse at 7363119e6600 of size 256 next 1880
412
+
413
+ 08:12:37.827 [info] InUse at 7363119e6700 of size 256 next 1685
414
+
415
+ 08:12:37.827 [info] InUse at 7363119e6800 of size 256 next 200
416
+
417
+ 08:12:37.827 [info] InUse at 7363119e6900 of size 256 next 1900
418
+
419
+ 08:12:37.828 [info] InUse at 7363119e6a00 of size 256 next 1677
420
+
421
+ 08:12:37.828 [info] InUse at 7363119e6b00 of size 256 next 8
422
+
423
+ 08:12:37.828 [info] InUse at 7363119e6c00 of size 256 next 1767
424
+
425
+ 08:12:37.828 [info] InUse at 7363119e6d00 of size 256 next 1794
426
+
427
+ 08:12:37.828 [info] InUse at 7363119e6e00 of size 256 next 1790
428
+
429
+ 08:12:37.828 [info] InUse at 7363119e6f00 of size 256 next 1776
430
+
431
+ 08:12:37.828 [info] InUse at 7363119e7000 of size 256 next 1579
432
+
433
+ 08:12:37.828 [info] InUse at 7363119e7100 of size 256 next 1550
434
+
435
+ 08:12:37.829 [info] InUse at 7363119e7200 of size 256 next 1698
436
+
437
+ 08:12:37.829 [info] InUse at 7363119e7300 of size 256 next 1683
438
+
439
+ 08:12:37.829 [info] InUse at 7363119e7400 of size 256 next 1839
440
+
441
+ 08:12:37.829 [info] InUse at 7363119e7500 of size 256 next 1556
442
+
443
+ 08:12:37.829 [info] InUse at 7363119e7600 of size 256 next 56
444
+
445
+ 08:12:37.830 [info] InUse at 7363119e7700 of size 256 next 1893
446
+
447
+ 08:12:37.830 [info] InUse at 7363119e7800 of size 256 next 3837
448
+
449
+ 08:12:37.830 [info] Free at 7363119e7900 of size 2173440 next 2023
450
+
451
+ 08:12:37.830 [info] InUse at 736311bfa300 of size 147456 next 3854
452
+
453
+ 08:12:37.831 [info] InUse at 736311c1e300 of size 147456 next 3887
454
+
455
+ 08:12:37.831 [info] InUse at 736311c42300 of size 228864 next 3908
456
+
457
+ 08:12:37.831 [info] Free at 736311c7a100 of size 310345216 next 347
458
+
459
+ 08:12:37.832 [info] InUse at 736324471f00 of size 147456 next 199
460
+
461
+ 08:12:37.832 [info] InUse at 736324495f00 of size 147456 next 447
462
+
463
+ 08:12:37.832 [info] InUse at 7363244b9f00 of size 73728 next 3843
464
+
465
+ 08:12:37.833 [info] InUse at 7363244cbf00 of size 73728 next 7
466
+
467
+ 08:12:37.833 [info] InUse at 7363244ddf00 of size 81408 next 256
468
+
469
+ 08:12:37.833 [info] InUse at 7363244f1d00 of size 256 next 1657
470
+
471
+ 08:12:37.833 [info] InUse at 7363244f1e00 of size 256 next 233
472
+
473
+ 08:12:37.833 [info] Free at 7363244f1f00 of size 832512 next 3910
474
+
475
+ 08:12:37.834 [info] InUse at 7363245bd300 of size 73728 next 257
476
+
477
+ 08:12:37.834 [info] InUse at 7363245cf300 of size 4096 next 3790
478
+
479
+ 08:12:37.834 [info] InUse at 7363245d0300 of size 4096 next 128
480
+
481
+ 08:12:37.834 [info] InUse at 7363245d1300 of size 4096 next 335
482
+
483
+ 08:12:37.834 [info] InUse at 7363245d2300 of size 4096 next 1908
484
+
485
+ 08:12:37.834 [info] InUse at 7363245d3300 of size 3584 next 116
486
+
487
+ 08:12:37.834 [info] InUse at 7363245d4100 of size 3584 next 410
488
+
489
+ 08:12:37.834 [info] InUse at 7363245d4f00 of size 3584 next 307
490
+
491
+ 08:12:37.834 [info] InUse at 7363245d5d00 of size 3584 next 139
492
+
493
+ 08:12:37.835 [info] InUse at 7363245d6b00 of size 2048 next 1817
494
+
495
+ 08:12:37.835 [info] InUse at 7363245d7300 of size 2048 next 1917
496
+
497
+ 08:12:37.835 [info] InUse at 7363245d7b00 of size 2048 next 297
498
+
499
+ 08:12:37.835 [info] InUse at 7363245d8300 of size 2048 next 1791
500
+
501
+ 08:12:37.835 [info] InUse at 7363245d8b00 of size 256 next 1801
502
+
503
+ 08:12:37.835 [info] InUse at 7363245d8c00 of size 256 next 348
504
+
505
+ 08:12:37.835 [info] InUse at 7363245d8d00 of size 256 next 3741
506
+
507
+ 08:12:37.835 [info] InUse at 7363245d8e00 of size 256 next 264
508
+
509
+ 08:12:37.835 [info] InUse at 7363245d8f00 of size 256 next 324
510
+
511
+ 08:12:37.835 [info] InUse at 7363245d9000 of size 256 next 1806
512
+
513
+ 08:12:37.836 [info] InUse at 7363245d9100 of size 256 next 3713
514
+
515
+ 08:12:37.836 [info] InUse at 7363245d9200 of size 256 next 117
516
+
517
+ 08:12:37.836 [info] InUse at 7363245d9300 of size 256 next 1859
518
+
519
+ 08:12:37.836 [info] InUse at 7363245d9400 of size 256 next 3745
520
+
521
+ 08:12:37.836 [info] InUse at 7363245d9500 of size 256 next 20
522
+
523
+ 08:12:37.836 [info] InUse at 7363245d9600 of size 256 next 3702
524
+
525
+ 08:12:37.837 [info] InUse at 7363245d9700 of size 256 next 3879
526
+
527
+ 08:12:37.837 [info] InUse at 7363245d9800 of size 256 next 226
528
+
529
+ 08:12:37.837 [info] InUse at 7363245d9900 of size 256 next 1910
530
+
531
+ 08:12:37.837 [info] InUse at 7363245d9a00 of size 256 next 237
532
+
533
+ 08:12:37.837 [info] InUse at 7363245d9b00 of size 256 next 229
534
+
535
+ 08:12:37.837 [info] InUse at 7363245d9c00 of size 256 next 136
536
+
537
+ 08:12:37.837 [info] InUse at 7363245d9d00 of size 256 next 448
538
+
539
+ 08:12:37.837 [info] InUse at 7363245d9e00 of size 256 next 286
540
+
541
+ 08:12:37.837 [info] InUse at 7363245d9f00 of size 256 next 213
542
+
543
+ 08:12:37.837 [info] InUse at 7363245da000 of size 256 next 37
544
+
545
+ 08:12:37.837 [info] InUse at 7363245da100 of size 256 next 346
546
+
547
+ 08:12:37.838 [info] InUse at 7363245da200 of size 256 next 165
548
+
549
+ 08:12:37.838 [info] InUse at 7363245da300 of size 256 next 318
550
+
551
+ 08:12:37.838 [info] InUse at 7363245da400 of size 256 next 372
552
+
553
+ 08:12:37.838 [info] InUse at 7363245da500 of size 256 next 443
554
+
555
+ 08:12:37.838 [info] InUse at 7363245da600 of size 256 next 193
556
+
557
+ 08:12:37.838 [info] InUse at 7363245da700 of size 256 next 127
558
+
559
+ 08:12:37.838 [info] InUse at 7363245da800 of size 256 next 43
560
+
561
+ 08:12:37.838 [info] InUse at 7363245da900 of size 256 next 550
562
+
563
+ 08:12:37.838 [info] InUse at 7363245daa00 of size 256 next 376
564
+
565
+ 08:12:37.838 [info] InUse at 7363245dab00 of size 256 next 467
566
+
567
+ 08:12:37.839 [info] InUse at 7363245dac00 of size 256 next 47
568
+
569
+ 08:12:37.839 [info] InUse at 7363245dad00 of size 256 next 207
570
+
571
+ 08:12:37.839 [info] InUse at 7363245dae00 of size 256 next 540
572
+
573
+ 08:12:37.839 [info] InUse at 7363245daf00 of size 256 next 408
574
+
575
+ 08:12:37.839 [info] InUse at 7363245db000 of size 256 next 279
576
+
577
+ 08:12:37.839 [info] InUse at 7363245db100 of size 256 next 76
578
+
579
+ 08:12:37.839 [info] InUse at 7363245db200 of size 256 next 532
580
+
581
+ 08:12:37.839 [info] InUse at 7363245db300 of size 6291456 next 2880
582
+
583
+ 08:12:37.840 [info] Free at 736324bdb300 of size 150994944 next 151
584
+
585
+ 08:12:37.840 [info] InUse at 73632dbdb300 of size 157286400 next 1816
586
+
587
+ 08:12:37.840 [info] InUse at 7363371db300 of size 157286400 next 1783
588
+
589
+ 08:12:37.840 [info] InUse at 7363407db300 of size 157286400 next 3758
590
+
591
+ 08:12:37.840 [info] InUse at 736349ddb300 of size 157286400 next 1731
592
+
593
+ 08:12:37.840 [info] Free at 7363533db300 of size 262984704 next 48
594
+
595
+ 08:12:37.840 [info] InUse at 736362ea8700 of size 34865152 next 319
596
+
597
+ 08:12:37.840 [info] InUse at 736364fe8700 of size 34865152 next 321
598
+
599
+ 08:12:37.840 [info] InUse at 736367128700 of size 34865152 next 221
600
+
601
+ 08:12:37.840 [info] InUse at 736369268700 of size 34865152 next 419
602
+
603
+ 08:12:37.840 [info] Free at 73636b3a8700 of size 349442560 next 18446744073709551615
604
+
605
+ 08:12:37.840 [info] Summary of in-use Chunks by size:
606
+
607
+ 08:12:37.841 [info] 102 Chunks of size 256 totalling 25.5KiB
608
+
609
+ 08:12:37.841 [info] 20 Chunks of size 512 totalling 10.0KiB
610
+
611
+ 08:12:37.841 [info] 4 Chunks of size 1024 totalling 4.0KiB
612
+
613
+ 08:12:37.841 [info] 8 Chunks of size 2048 totalling 16.0KiB
614
+
615
+ 08:12:37.841 [info] 8 Chunks of size 3584 totalling 28.0KiB
616
+
617
+ 08:12:37.841 [info] 4 Chunks of size 4096 totalling 16.0KiB
618
+
619
+ 08:12:37.841 [info] 6 Chunks of size 73728 totalling 432.0KiB
620
+
621
+ 08:12:37.841 [info] 1 Chunks of size 81408 totalling 79.5KiB
622
+
623
+ 08:12:37.842 [info] 1 Chunks of size 115712 totalling 113.0KiB
624
+
625
+ 08:12:37.842 [info] 6 Chunks of size 147456 totalling 864.0KiB
626
+
627
+ 08:12:37.842 [info] 1 Chunks of size 148736 totalling 145.2KiB
628
+
629
+ 08:12:37.842 [info] 1 Chunks of size 228864 totalling 223.5KiB
630
+
631
+ 08:12:37.842 [info] 4 Chunks of size 294912 totalling 1.12MiB
632
+
633
+ 08:12:37.842 [info] 1 Chunks of size 2618880 totalling 2.50MiB
634
+
635
+ 08:12:37.842 [info] 1 Chunks of size 6291456 totalling 6.00MiB
636
+
637
+ 08:12:37.842 [info] 4 Chunks of size 34865152 totalling 133.00MiB
638
+
639
+ 08:12:37.842 [info] 4 Chunks of size 157286400 totalling 600.00MiB
640
+
641
+ 08:12:37.842 [info] Sum Total of in-use chunks: 744.53MiB
642
+
643
+ 08:12:37.843 [info] Total bytes in pool: 1880004864 memory_limit_: 1880005017 available bytes: 153 curr_region_allocation_bytes_: 3760010240
644
+
645
+ 08:12:37.843 [info] Stats:
646
+ Limit: 1880005017
647
+ InUse: 780699904
648
+ MaxInUse: 1871703296
649
+ NumAllocs: 97350
650
+ MaxAllocSize: 1152347648
651
+ Reserved: 0
652
+ PeakReserved: 0
653
+ LargestFreeBlock: 0
654
+
655
+
656
+ 08:12:37.843 [warning] **________________*_______***********************************____________*********__________________
657
+
658
+ 08:12:37.843 [error] Execution of replica 0 failed: RESOURCE_EXHAUSTED: Out of memory while trying to allocate 503840768 bytes.
659
+ BufferAssignment OOM Debugging.
660
+ BufferAssignment stats:
661
+ parameter allocation: 0B
662
+ constant allocation: 273B
663
+ maybe_live_out allocation: 1.88GiB
664
+ preallocated temp allocation: 7.5KiB
665
+ preallocated temp fragmentation: 1.2KiB (16.09%)
666
+ total allocation: 1.88GiB
667
+ total fragmentation: 7.8KiB (0.00%)
668
+ Peak buffers:
669
+ Buffer 1:
670
+ Size: 480.50MiB
671
+ XLA Label: fusion
672
+ Shape: f32[492032,256]
673
+ ==========================
674
+
675
+ Buffer 2:
676
+ Size: 480.50MiB
677
+ XLA Label: fusion
678
+ Shape: f32[492032,256]
679
+ ==========================
680
+
681
+ Buffer 3:
682
+ Size: 480.50MiB
683
+ XLA Label: fusion
684
+ Shape: f32[125960192]
685
+ ==========================
686
+
687
+ Buffer 4:
688
+ Size: 480.50MiB
689
+ XLA Label: fusion
690
+ Shape: f32[492032,256]
691
+ ==========================
692
+
693
+ Buffer 5:
694
+ Size: 288.0KiB
695
+ XLA Label: fusion
696
+ Shape: f32[3,3,64,128]
697
+ ==========================
698
+
699
+ Buffer 6:
700
+ Size: 288.0KiB
701
+ XLA Label: fusion
702
+ Shape: f32[3,3,64,128]
703
+ ==========================
704
+
705
+ Buffer 7:
706
+ Size: 288.0KiB
707
+ XLA Label: fusion
708
+ Shape: f32[73728]
709
+ ==========================
710
+
711
+ Buffer 8:
712
+ Size: 288.0KiB
713
+ XLA Label: fusion
714
+ Shape: f32[3,3,64,128]
715
+ ==========================
716
+
717
+ Buffer 9:
718
+ Size: 6.8KiB
719
+ XLA Label: fusion
720
+ Shape: f32[3,3,3,64]
721
+ ==========================
722
+
723
+ Buffer 10:
724
+ Size: 6.8KiB
725
+ XLA Label: fusion
726
+ Shape: f32[3,3,3,64]
727
+ ==========================
728
+
729
+ Buffer 11:
730
+ Size: 6.8KiB
731
+ XLA Label: fusion
732
+ Shape: f32[1728]
733
+ ==========================
734
+
735
+ Buffer 12:
736
+ Size: 6.8KiB
737
+ XLA Label: fusion
738
+ Shape: f32[3,3,3,64]
739
+ ==========================
740
+
741
+ Buffer 13:
742
+ Size: 2.0KiB
743
+ XLA Label: fusion
744
+ Shape: f32[256,2]
745
+ ==========================
746
+
747
+ Buffer 14:
748
+ Size: 2.0KiB
749
+ XLA Label: fusion
750
+ Shape: f32[512]
751
+ ==========================
752
+
753
+ Buffer 15:
754
+ Size: 2.0KiB
755
+ XLA Label: fusion
756
+ Shape: f32[256,2]
757
+ ==========================
758
+
759
+
760
+
761
+ ```
762
+
763
+ ## Testing
764
+
765
+ ```elixir
766
+ test_directory = "/home/le-moski/Documents/FEFU/7S/AI/lab1-dirtyplates/platesv2/plates/test/*.jpg"
767
+
768
+ test_filenames =
769
+ Path.wildcard(test_directory)
770
+ |> Stream.chunk_every(batch_size, batch_size)
771
+
772
+ test_data_raw =
773
+ test_filenames
774
+ |> Task.async_stream(fn batch ->
775
+ batch
776
+ |> Enum.map(fn filename ->
777
+ {:ok, img} = StbImage.read_file(filename, channels: image_channels)
778
+ StbImage.resize(img, image_h, image_w) |> StbImage.to_nx()
779
+ end)
780
+ |> Nx.stack()
781
+ end)
782
+
783
+ test_data =
784
+ test_data_raw
785
+ |> Stream.map(fn {:ok, batch} -> batch |> Nx.divide(channel_value_max) end)
786
+ ```
787
+
788
+ <!-- livebook:{"output":true} -->
789
+
790
+ ```
791
+ #Stream<[
792
+ enum: #Function<3.112894672/2 in Task.build_stream/3>,
793
+ funs: [#Function<50.38948127/1 in Stream.map/2>]
794
+ ]>
795
+ ```
796
+
797
+ ```elixir
798
+ predictions =
799
+ test_data
800
+ |> Stream.map(fn batch ->
801
+ Axon.predict(model, model_state, batch)
802
+ end)
803
+
804
+ prediction_labels =
805
+ predictions
806
+ |> Stream.map(fn batch ->
807
+ batch
808
+ |> Nx.to_list()
809
+ |> Enum.map(
810
+ &if &1 |> Enum.at(0) >= &1 |> Enum.at(1) do
811
+ "Cleaned"
812
+ else
813
+ "Dirty"
814
+ end
815
+ )
816
+ end)
817
+ ```
818
+
819
+ <!-- livebook:{"output":true} -->
820
+
821
+ ```
822
+ #Stream<[
823
+ enum: #Function<3.112894672/2 in Task.build_stream/3>,
824
+ funs: [#Function<50.38948127/1 in Stream.map/2>, #Function<50.38948127/1 in Stream.map/2>,
825
+ #Function<50.38948127/1 in Stream.map/2>]
826
+ ]>
827
+ ```
828
+
829
+ ```elixir
830
+ predictions |> Enum.to_list()
831
+ ```
832
+
833
+ <!-- livebook:{"output":true} -->
834
+
835
+ ```
836
+ [
837
+ #Nx.Tensor<
838
+ f32[20][2]
839
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98827>
840
+ [
841
+ [NaN, NaN],
842
+ [NaN, NaN],
843
+ [NaN, NaN],
844
+ [NaN, NaN],
845
+ [NaN, NaN],
846
+ [NaN, NaN],
847
+ [NaN, NaN],
848
+ [NaN, NaN],
849
+ [NaN, NaN],
850
+ [NaN, NaN],
851
+ [NaN, NaN],
852
+ [NaN, NaN],
853
+ [NaN, NaN],
854
+ [NaN, NaN],
855
+ [NaN, NaN],
856
+ [NaN, NaN],
857
+ [NaN, NaN],
858
+ [NaN, NaN],
859
+ [NaN, NaN],
860
+ [NaN, NaN]
861
+ ]
862
+ >,
863
+ #Nx.Tensor<
864
+ f32[20][2]
865
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98830>
866
+ [
867
+ [NaN, NaN],
868
+ [NaN, NaN],
869
+ [NaN, NaN],
870
+ [NaN, NaN],
871
+ [NaN, NaN],
872
+ [NaN, NaN],
873
+ [NaN, NaN],
874
+ [NaN, NaN],
875
+ [NaN, NaN],
876
+ [NaN, NaN],
877
+ [NaN, NaN],
878
+ [NaN, NaN],
879
+ [NaN, NaN],
880
+ [NaN, NaN],
881
+ [NaN, NaN],
882
+ [NaN, NaN],
883
+ [NaN, NaN],
884
+ [NaN, NaN],
885
+ [NaN, NaN],
886
+ [NaN, NaN]
887
+ ]
888
+ >,
889
+ #Nx.Tensor<
890
+ f32[20][2]
891
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98833>
892
+ [
893
+ [NaN, NaN],
894
+ [NaN, NaN],
895
+ [NaN, NaN],
896
+ [NaN, NaN],
897
+ [NaN, NaN],
898
+ [NaN, NaN],
899
+ [NaN, NaN],
900
+ [NaN, NaN],
901
+ [NaN, NaN],
902
+ [NaN, NaN],
903
+ [NaN, NaN],
904
+ [NaN, NaN],
905
+ [NaN, NaN],
906
+ [NaN, NaN],
907
+ [NaN, NaN],
908
+ [NaN, NaN],
909
+ [NaN, NaN],
910
+ [NaN, NaN],
911
+ [NaN, NaN],
912
+ [NaN, NaN]
913
+ ]
914
+ >,
915
+ #Nx.Tensor<
916
+ f32[20][2]
917
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98836>
918
+ [
919
+ [NaN, NaN],
920
+ [NaN, NaN],
921
+ [NaN, NaN],
922
+ [NaN, NaN],
923
+ [NaN, NaN],
924
+ [NaN, NaN],
925
+ [NaN, NaN],
926
+ [NaN, NaN],
927
+ [NaN, NaN],
928
+ [NaN, NaN],
929
+ [NaN, NaN],
930
+ [NaN, NaN],
931
+ [NaN, NaN],
932
+ [NaN, NaN],
933
+ [NaN, NaN],
934
+ [NaN, NaN],
935
+ [NaN, NaN],
936
+ [NaN, NaN],
937
+ [NaN, NaN],
938
+ [NaN, NaN]
939
+ ]
940
+ >,
941
+ #Nx.Tensor<
942
+ f32[20][2]
943
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94801>
944
+ [
945
+ [NaN, NaN],
946
+ [NaN, NaN],
947
+ [NaN, NaN],
948
+ [NaN, NaN],
949
+ [NaN, NaN],
950
+ [NaN, NaN],
951
+ [NaN, NaN],
952
+ [NaN, NaN],
953
+ [NaN, NaN],
954
+ [NaN, NaN],
955
+ [NaN, NaN],
956
+ [NaN, NaN],
957
+ [NaN, NaN],
958
+ [NaN, NaN],
959
+ [NaN, NaN],
960
+ [NaN, NaN],
961
+ [NaN, NaN],
962
+ [NaN, NaN],
963
+ [NaN, NaN],
964
+ [NaN, NaN]
965
+ ]
966
+ >,
967
+ #Nx.Tensor<
968
+ f32[20][2]
969
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94804>
970
+ [
971
+ [NaN, NaN],
972
+ [NaN, NaN],
973
+ [NaN, NaN],
974
+ [NaN, NaN],
975
+ [NaN, NaN],
976
+ [NaN, NaN],
977
+ [NaN, NaN],
978
+ [NaN, NaN],
979
+ [NaN, NaN],
980
+ [NaN, NaN],
981
+ [NaN, NaN],
982
+ [NaN, NaN],
983
+ [NaN, NaN],
984
+ [NaN, NaN],
985
+ [NaN, NaN],
986
+ [NaN, NaN],
987
+ [NaN, NaN],
988
+ [NaN, NaN],
989
+ [NaN, NaN],
990
+ [NaN, NaN]
991
+ ]
992
+ >,
993
+ #Nx.Tensor<
994
+ f32[20][2]
995
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94807>
996
+ [
997
+ [NaN, NaN],
998
+ [NaN, NaN],
999
+ [NaN, NaN],
1000
+ [NaN, NaN],
1001
+ [NaN, NaN],
1002
+ [NaN, NaN],
1003
+ [NaN, NaN],
1004
+ [NaN, NaN],
1005
+ [NaN, NaN],
1006
+ [NaN, NaN],
1007
+ [NaN, NaN],
1008
+ [NaN, NaN],
1009
+ [NaN, NaN],
1010
+ [NaN, NaN],
1011
+ [NaN, NaN],
1012
+ [NaN, NaN],
1013
+ [NaN, NaN],
1014
+ [NaN, NaN],
1015
+ [NaN, NaN],
1016
+ [NaN, NaN]
1017
+ ]
1018
+ >,
1019
+ #Nx.Tensor<
1020
+ f32[20][2]
1021
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94810>
1022
+ [
1023
+ [NaN, NaN],
1024
+ [NaN, NaN],
1025
+ [NaN, NaN],
1026
+ [NaN, NaN],
1027
+ [NaN, NaN],
1028
+ [NaN, NaN],
1029
+ [NaN, NaN],
1030
+ [NaN, NaN],
1031
+ [NaN, NaN],
1032
+ [NaN, NaN],
1033
+ [NaN, NaN],
1034
+ [NaN, NaN],
1035
+ [NaN, NaN],
1036
+ [NaN, NaN],
1037
+ [NaN, NaN],
1038
+ [NaN, NaN],
1039
+ [NaN, NaN],
1040
+ [NaN, NaN],
1041
+ [NaN, NaN],
1042
+ [NaN, NaN]
1043
+ ]
1044
+ >,
1045
+ #Nx.Tensor<
1046
+ f32[20][2]
1047
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94813>
1048
+ [
1049
+ [NaN, NaN],
1050
+ [NaN, NaN],
1051
+ [NaN, NaN],
1052
+ [NaN, NaN],
1053
+ [NaN, NaN],
1054
+ [NaN, NaN],
1055
+ [NaN, NaN],
1056
+ [NaN, NaN],
1057
+ [NaN, NaN],
1058
+ [NaN, NaN],
1059
+ [NaN, NaN],
1060
+ [NaN, NaN],
1061
+ [NaN, NaN],
1062
+ [NaN, NaN],
1063
+ [NaN, NaN],
1064
+ [NaN, NaN],
1065
+ [NaN, NaN],
1066
+ [NaN, NaN],
1067
+ [NaN, NaN],
1068
+ [NaN, NaN]
1069
+ ]
1070
+ >,
1071
+ #Nx.Tensor<
1072
+ f32[20][2]
1073
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98846>
1074
+ [
1075
+ [NaN, NaN],
1076
+ [NaN, NaN],
1077
+ [NaN, NaN],
1078
+ [NaN, NaN],
1079
+ [NaN, NaN],
1080
+ [NaN, NaN],
1081
+ [NaN, NaN],
1082
+ [NaN, NaN],
1083
+ [NaN, NaN],
1084
+ [NaN, NaN],
1085
+ [NaN, NaN],
1086
+ [NaN, NaN],
1087
+ [NaN, NaN],
1088
+ [NaN, NaN],
1089
+ [NaN, NaN],
1090
+ [NaN, NaN],
1091
+ [NaN, NaN],
1092
+ [NaN, NaN],
1093
+ [NaN, NaN],
1094
+ [NaN, NaN]
1095
+ ]
1096
+ >,
1097
+ #Nx.Tensor<
1098
+ f32[20][2]
1099
+ EXLA.Backend<cuda:0, 0.691480651.217186321.95355>
1100
+ [
1101
+ [NaN, NaN],
1102
+ [NaN, NaN],
1103
+ [NaN, NaN],
1104
+ [NaN, NaN],
1105
+ [NaN, NaN],
1106
+ [NaN, NaN],
1107
+ [NaN, NaN],
1108
+ [NaN, NaN],
1109
+ [NaN, NaN],
1110
+ [NaN, NaN],
1111
+ [NaN, NaN],
1112
+ [NaN, NaN],
1113
+ [NaN, NaN],
1114
+ [NaN, NaN],
1115
+ [NaN, NaN],
1116
+ [NaN, NaN],
1117
+ [NaN, NaN],
1118
+ [NaN, NaN],
1119
+ [NaN, NaN],
1120
+ [NaN, ...]
1121
+ ]
1122
+ >,
1123
+ #Nx.Tensor<
1124
+ f32[20][2]
1125
+ EXLA.Backend<cuda:0, 0.691480651.217186321.95357>
1126
+ [
1127
+ [NaN, NaN],
1128
+ [NaN, NaN],
1129
+ [NaN, NaN],
1130
+ [NaN, NaN],
1131
+ [NaN, NaN],
1132
+ [NaN, NaN],
1133
+ [NaN, NaN],
1134
+ [NaN, NaN],
1135
+ [NaN, NaN],
1136
+ [NaN, NaN],
1137
+ [NaN, NaN],
1138
+ [NaN, NaN],
1139
+ [NaN, NaN],
1140
+ [NaN, NaN],
1141
+ [NaN, NaN],
1142
+ [NaN, NaN],
1143
+ [NaN, NaN],
1144
+ [NaN, NaN],
1145
+ [NaN, NaN],
1146
+ ...
1147
+ ]
1148
+ >,
1149
+ #Nx.Tensor<
1150
+ f32[20][2]
1151
+ EXLA.Backend<cuda:0, 0.691480651.217186322.99151>
1152
+ [
1153
+ [NaN, NaN],
1154
+ [NaN, NaN],
1155
+ [NaN, NaN],
1156
+ [NaN, NaN],
1157
+ [NaN, NaN],
1158
+ [NaN, NaN],
1159
+ [NaN, NaN],
1160
+ [NaN, NaN],
1161
+ [NaN, NaN],
1162
+ [NaN, NaN],
1163
+ [NaN, NaN],
1164
+ [NaN, NaN],
1165
+ [NaN, NaN],
1166
+ [NaN, NaN],
1167
+ [NaN, NaN],
1168
+ [NaN, NaN],
1169
+ [NaN, NaN],
1170
+ [NaN, NaN],
1171
+ [NaN, ...],
1172
+ ...
1173
+ ]
1174
+ >,
1175
+ #Nx.Tensor<
1176
+ f32[20][2]
1177
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98858>
1178
+ [
1179
+ [NaN, NaN],
1180
+ [NaN, NaN],
1181
+ [NaN, NaN],
1182
+ [NaN, NaN],
1183
+ [NaN, NaN],
1184
+ [NaN, NaN],
1185
+ [NaN, NaN],
1186
+ [NaN, NaN],
1187
+ [NaN, NaN],
1188
+ [NaN, NaN],
1189
+ [NaN, NaN],
1190
+ [NaN, NaN],
1191
+ [NaN, NaN],
1192
+ [NaN, NaN],
1193
+ [NaN, NaN],
1194
+ [NaN, NaN],
1195
+ [NaN, NaN],
1196
+ [NaN, NaN],
1197
+ ...
1198
+ ]
1199
+ >,
1200
+ #Nx.Tensor<
1201
+ f32[20][2]
1202
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94881>
1203
+ [
1204
+ [NaN, NaN],
1205
+ [NaN, NaN],
1206
+ [NaN, NaN],
1207
+ [NaN, NaN],
1208
+ [NaN, NaN],
1209
+ [NaN, NaN],
1210
+ [NaN, NaN],
1211
+ [NaN, NaN],
1212
+ [NaN, NaN],
1213
+ [NaN, NaN],
1214
+ [NaN, NaN],
1215
+ [NaN, NaN],
1216
+ [NaN, NaN],
1217
+ [NaN, NaN],
1218
+ [NaN, NaN],
1219
+ [NaN, NaN],
1220
+ [NaN, NaN],
1221
+ [NaN, ...],
1222
+ ...
1223
+ ]
1224
+ >,
1225
+ #Nx.Tensor<
1226
+ f32[20][2]
1227
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98903>
1228
+ [
1229
+ [NaN, NaN],
1230
+ [NaN, NaN],
1231
+ [NaN, NaN],
1232
+ [NaN, NaN],
1233
+ [NaN, NaN],
1234
+ [NaN, NaN],
1235
+ [NaN, NaN],
1236
+ [NaN, NaN],
1237
+ [NaN, NaN],
1238
+ [NaN, NaN],
1239
+ [NaN, NaN],
1240
+ [NaN, NaN],
1241
+ [NaN, NaN],
1242
+ [NaN, NaN],
1243
+ [NaN, NaN],
1244
+ [NaN, NaN],
1245
+ [NaN, NaN],
1246
+ ...
1247
+ ]
1248
+ >,
1249
+ #Nx.Tensor<
1250
+ f32[20][2]
1251
+ EXLA.Backend<cuda:0, 0.691480651.217186326.102539>
1252
+ [
1253
+ [NaN, NaN],
1254
+ [NaN, NaN],
1255
+ [NaN, NaN],
1256
+ [NaN, NaN],
1257
+ [NaN, NaN],
1258
+ [NaN, NaN],
1259
+ [NaN, NaN],
1260
+ [NaN, NaN],
1261
+ [NaN, NaN],
1262
+ [NaN, NaN],
1263
+ [NaN, NaN],
1264
+ [NaN, NaN],
1265
+ [NaN, NaN],
1266
+ [NaN, NaN],
1267
+ [NaN, NaN],
1268
+ [NaN, NaN],
1269
+ [NaN, ...],
1270
+ ...
1271
+ ]
1272
+ >,
1273
+ #Nx.Tensor<
1274
+ f32[20][2]
1275
+ EXLA.Backend<cuda:0, 0.691480651.217186328.98921>
1276
+ [
1277
+ [NaN, NaN],
1278
+ [NaN, NaN],
1279
+ [NaN, NaN],
1280
+ [NaN, NaN],
1281
+ [NaN, NaN],
1282
+ [NaN, NaN],
1283
+ [NaN, NaN],
1284
+ [NaN, NaN],
1285
+ [NaN, NaN],
1286
+ [NaN, NaN],
1287
+ [NaN, NaN],
1288
+ [NaN, NaN],
1289
+ [NaN, NaN],
1290
+ [NaN, NaN],
1291
+ [NaN, NaN],
1292
+ [NaN, NaN],
1293
+ ...
1294
+ ]
1295
+ >,
1296
+ #Nx.Tensor<
1297
+ f32[20][2]
1298
+ EXLA.Backend<cuda:0, 0.691480651.217186329.96026>
1299
+ [
1300
+ [NaN, NaN],
1301
+ [NaN, NaN],
1302
+ [NaN, NaN],
1303
+ [NaN, NaN],
1304
+ [NaN, NaN],
1305
+ [NaN, NaN],
1306
+ [NaN, NaN],
1307
+ [NaN, NaN],
1308
+ [NaN, NaN],
1309
+ [NaN, NaN],
1310
+ [NaN, NaN],
1311
+ [NaN, NaN],
1312
+ [NaN, NaN],
1313
+ [NaN, NaN],
1314
+ [NaN, NaN],
1315
+ [NaN, ...],
1316
+ ...
1317
+ ]
1318
+ >,
1319
+ #Nx.Tensor<
1320
+ f32[20][2]
1321
+ EXLA.Backend<cuda:0, 0.691480651.217186325.94929>
1322
+ [
1323
+ [NaN, NaN],
1324
+ [NaN, NaN],
1325
+ [NaN, NaN],
1326
+ [NaN, NaN],
1327
+ [NaN, NaN],
1328
+ [NaN, NaN],
1329
+ [NaN, NaN],
1330
+ [NaN, NaN],
1331
+ [NaN, NaN],
1332
+ [NaN, NaN],
1333
+ [NaN, NaN],
1334
+ [NaN, NaN],
1335
+ [NaN, NaN],
1336
+ [NaN, NaN],
1337
+ [NaN, NaN],
1338
+ ...
1339
+ ]
1340
+ >,
1341
+ #Nx.Tensor<
1342
+ f32[20][2]
1343
+ EXLA.Backend<cuda:0, 0.691480651.217186326.102571>
1344
+ [
1345
+ [NaN, NaN],
1346
+ [NaN, NaN],
1347
+ [NaN, NaN],
1348
+ [NaN, NaN],
1349
+ [NaN, NaN],
1350
+ [NaN, NaN],
1351
+ [NaN, NaN],
1352
+ [NaN, NaN],
1353
+ [NaN, NaN],
1354
+ [NaN, NaN],
1355
+ [NaN, NaN],
1356
+ [NaN, NaN],
1357
+ [NaN, NaN],
1358
+ [NaN, NaN],
1359
+ [NaN, ...],
1360
+ ...
1361
+ ]
1362
+ >,
1363
+ #Nx.Tensor<
1364
+ f32[20][2]
1365
+ EXLA.Backend<cuda:0, 0.691480651.217186330.95297>
1366
+ [
1367
+ [NaN, NaN],
1368
+ [NaN, NaN],
1369
+ [NaN, NaN],
1370
+ [NaN, NaN],
1371
+ [NaN, NaN],
1372
+ [NaN, NaN],
1373
+ [NaN, NaN],
1374
+ [NaN, NaN],
1375
+ [NaN, NaN],
1376
+ [NaN, NaN],
1377
+ [NaN, NaN],
1378
+ [NaN, NaN],
1379
+ [NaN, NaN],
1380
+ [NaN, NaN],
1381
+ ...
1382
+ ]
1383
+ >,
1384
+ #Nx.Tensor<
1385
+ f32[20][2]
1386
+ EXLA.Backend<cuda:0, 0.691480651.217186321.95421>
1387
+ [
1388
+ [NaN, NaN],
1389
+ [NaN, NaN],
1390
+ [NaN, NaN],
1391
+ [NaN, NaN],
1392
+ [NaN, NaN],
1393
+ [NaN, NaN],
1394
+ [NaN, NaN],
1395
+ [NaN, NaN],
1396
+ [NaN, NaN],
1397
+ [NaN, NaN],
1398
+ [NaN, NaN],
1399
+ [NaN, NaN],
1400
+ [NaN, NaN],
1401
+ [NaN, ...],
1402
+ ...
1403
+ ]
1404
+ >,
1405
+ #Nx.Tensor<
1406
+ f32[20][2]
1407
+ EXLA.Backend<cuda:0, 0.691480651.217186321.95441>
1408
+ [
1409
+ [NaN, NaN],
1410
+ [NaN, NaN],
1411
+ [NaN, NaN],
1412
+ [NaN, NaN],
1413
+ [NaN, NaN],
1414
+ [NaN, NaN],
1415
+ [NaN, NaN],
1416
+ [NaN, NaN],
1417
+ [NaN, NaN],
1418
+ [NaN, NaN],
1419
+ [NaN, NaN],
1420
+ [NaN, NaN],
1421
+ [NaN, NaN],
1422
+ ...
1423
+ ]
1424
+ >,
1425
+ #Nx.Tensor<
1426
+ f32[20][2]
1427
+ EXLA.Backend<cuda:0, 0.691480651.217186326.102666>
1428
+ [
1429
+ [NaN, NaN],
1430
+ [NaN, NaN],
1431
+ [NaN, NaN],
1432
+ [NaN, NaN],
1433
+ [NaN, NaN],
1434
+ [NaN, NaN],
1435
+ [NaN, NaN],
1436
+ [NaN, NaN],
1437
+ [NaN, NaN],
1438
+ [NaN, NaN],
1439
+ [NaN, NaN],
1440
+ [NaN, NaN],
1441
+ [NaN, ...],
1442
+ ...
1443
+ ]
1444
+ >,
1445
+ #Nx.Tensor<
1446
+ f32[20][2]
1447
+ EXLA.Backend<cuda:0, 0.691480651.217186326.102702>
1448
+ [
1449
+ [NaN, NaN],
1450
+ [NaN, NaN],
1451
+ [NaN, NaN],
1452
+ [NaN, NaN],
1453
+ [NaN, NaN],
1454
+ [NaN, NaN],
1455
+ [NaN, NaN],
1456
+ [NaN, NaN],
1457
+ [NaN, NaN],
1458
+ [NaN, NaN],
1459
+ [NaN, NaN],
1460
+ [NaN, NaN],
1461
+ ...
1462
+ ]
1463
+ >,
1464
+ #Nx.Tensor<
1465
+ f32[20][2]
1466
+ EXLA.Backend<cuda:0, 0.691480651.217186329.96108>
1467
+ [
1468
+ [NaN, NaN],
1469
+ [NaN, NaN],
1470
+ [NaN, NaN],
1471
+ [NaN, NaN],
1472
+ [NaN, NaN],
1473
+ [NaN, NaN],
1474
+ [NaN, NaN],
1475
+ [NaN, NaN],
1476
+ [NaN, NaN],
1477
+ [NaN, NaN],
1478
+ [NaN, NaN],
1479
+ [NaN, ...],
1480
+ ...
1481
+ ]
1482
+ >,
1483
+ #Nx.Tensor<
1484
+ f32[20][2]
1485
+ EXLA.Backend<cuda:0, 0.691480651.217186329.96120>
1486
+ [
1487
+ [NaN, NaN],
1488
+ [NaN, NaN],
1489
+ [NaN, NaN],
1490
+ [NaN, NaN],
1491
+ [NaN, NaN],
1492
+ [NaN, NaN],
1493
+ [NaN, NaN],
1494
+ [NaN, NaN],
1495
+ [NaN, NaN],
1496
+ [NaN, NaN],
1497
+ [NaN, NaN],
1498
+ ...
1499
+ ]
1500
+ >,
1501
+ #Nx.Tensor<
1502
+ f32[20][2]
1503
+ EXLA.Backend<cuda:0, 0.691480651.217186329.96125>
1504
+ [
1505
+ [NaN, NaN],
1506
+ [NaN, NaN],
1507
+ [NaN, NaN],
1508
+ [NaN, NaN],
1509
+ [NaN, NaN],
1510
+ [NaN, NaN],
1511
+ [NaN, NaN],
1512
+ [NaN, NaN],
1513
+ [NaN, NaN],
1514
+ [NaN, NaN],
1515
+ [NaN, ...],
1516
+ ...
1517
+ ]
1518
+ >,
1519
+ #Nx.Tensor<
1520
+ f32[20][2]
1521
+ EXLA.Backend<cuda:0, 0.691480651.217186321.95471>
1522
+ [
1523
+ [NaN, NaN],
1524
+ [NaN, NaN],
1525
+ [NaN, NaN],
1526
+ [NaN, NaN],
1527
+ [NaN, NaN],
1528
+ [NaN, NaN],
1529
+ [NaN, NaN],
1530
+ [NaN, NaN],
1531
+ [NaN, NaN],
1532
+ [NaN, NaN],
1533
+ ...
1534
+ ]
1535
+ >,
1536
+ #Nx.Tensor<
1537
+ f32[20][2]
1538
+ EXLA.Backend<cuda:0, 0.691480651.217186326.102744>
1539
+ [
1540
+ [NaN, NaN],
1541
+ [NaN, NaN],
1542
+ [NaN, NaN],
1543
+ [NaN, NaN],
1544
+ [NaN, NaN],
1545
+ [NaN, NaN],
1546
+ [NaN, NaN],
1547
+ [NaN, NaN],
1548
+ [NaN, NaN],
1549
+ [NaN, ...],
1550
+ ...
1551
+ ]
1552
+ >,
1553
+ #Nx.Tensor<
1554
+ f32[20][2]
1555
+ EXLA.Backend<cuda:0, 0.691480651.217186328.99042>
1556
+ [
1557
+ [NaN, NaN],
1558
+ [NaN, NaN],
1559
+ [NaN, NaN],
1560
+ [NaN, NaN],
1561
+ [NaN, NaN],
1562
+ [NaN, NaN],
1563
+ [NaN, NaN],
1564
+ [NaN, NaN],
1565
+ [NaN, NaN],
1566
+ ...
1567
+ ]
1568
+ >,
1569
+ #Nx.Tensor<
1570
+ f32[20][2]
1571
+ EXLA.Backend<cuda:0, 0.691480651.217186330.95355>
1572
+ [
1573
+ [NaN, NaN],
1574
+ [NaN, NaN],
1575
+ [NaN, NaN],
1576
+ [NaN, NaN],
1577
+ [NaN, NaN],
1578
+ [NaN, NaN],
1579
+ [NaN, NaN],
1580
+ [NaN, NaN],
1581
+ [NaN, ...],
1582
+ ...
1583
+ ]
1584
+ >,
1585
+ #Nx.Tensor<
1586
+ f32[20][2]
1587
+ EXLA.Backend<cuda:0, 0.691480651.217186330.95367>
1588
+ [
1589
+ [NaN, NaN],
1590
+ [NaN, NaN],
1591
+ [NaN, NaN],
1592
+ [NaN, NaN],
1593
+ [NaN, NaN],
1594
+ [NaN, NaN],
1595
+ [NaN, NaN],
1596
+ [NaN, NaN],
1597
+ ...
1598
+ ]
1599
+ >,
1600
+ #Nx.Tensor<
1601
+ f32[20][2]
1602
+ EXLA.Backend<cuda:0, 0.691480651.217186325.95024>
1603
+ [
1604
+ [NaN, NaN],
1605
+ [NaN, NaN],
1606
+ [NaN, NaN],
1607
+ [NaN, NaN],
1608
+ [NaN, NaN],
1609
+ [NaN, NaN],
1610
+ [NaN, NaN],
1611
+ [NaN, ...],
1612
+ ...
1613
+ ]
1614
+ >,
1615
+ #Nx.Tensor<
1616
+ f32[20][2]
1617
+ EXLA.Backend<cuda:0, 0.691480651.217186330.95386>
1618
+ [
1619
+ [NaN, NaN],
1620
+ [NaN, NaN],
1621
+ [NaN, NaN],
1622
+ [NaN, NaN],
1623
+ [NaN, NaN],
1624
+ [NaN, NaN],
1625
+ [NaN, NaN],
1626
+ ...
1627
+ ]
1628
+ >,
1629
+ #Nx.Tensor<
1630
+ f32[20][2]
1631
+ EXLA.Backend<cuda:0, 0.691480651.217186330.95409>
1632
+ [
1633
+ [NaN, NaN],
1634
+ [NaN, NaN],
1635
+ [NaN, NaN],
1636
+ [NaN, NaN],
1637
+ [NaN, NaN],
1638
+ [NaN, NaN],
1639
+ [NaN, ...],
1640
+ ...
1641
+ ]
1642
+ >,
1643
+ #Nx.Tensor<
1644
+ f32[4][2]
1645
+ EXLA.Backend<cuda:0, 0.691480651.217186330.95412>
1646
+ [
1647
+ [NaN, NaN],
1648
+ [NaN, NaN],
1649
+ [NaN, NaN],
1650
+ [NaN, NaN]
1651
+ ]
1652
+ >
1653
+ ]
1654
+ ```
1655
+
1656
+ ```elixir
1657
+ results = Stream.zip([test_filenames, test_data_raw, prediction_labels])
1658
+ ```
1659
+
1660
+ <!-- livebook:{"output":true} -->
1661
+
1662
+ ```
1663
+ #Function<76.38948127/2 in Stream.zip_with/2>
1664
+ ```
1665
+
1666
+ ```elixir
1667
+ csv =
1668
+ results
1669
+ |> Stream.flat_map(fn batch ->
1670
+ {filenames_batch, _, labels_batch} = batch
1671
+
1672
+ Enum.zip([filenames_batch, labels_batch])
1673
+ |> Enum.map(fn {filename, label} ->
1674
+ %{id: Path.basename(filename, ".jpg"), label: String.downcase(label)}
1675
+ end)
1676
+ end)
1677
+ |> CSV.encode(headers: [:id, :label])
1678
+ |> Enum.join()
1679
+
1680
+ File.write!("/home/le-moski/Documents/FEFU/7S/AI/lab1-dirtyplates/results.csv", csv)
1681
+ ```
1682
+
1683
+ <!-- livebook:{"output":true} -->
1684
+
1685
+ ```
1686
+ :ok
1687
+ ```
1688
+
1689
+ ```elixir
1690
+ visualization =
1691
+ results
1692
+ |> Stream.map(fn batch ->
1693
+ {filenames_batch, {:ok, raw_batch}, labels_batch} = batch
1694
+
1695
+ filenames_batch
1696
+ |> Stream.with_index(fn filename, index ->
1697
+ Kino.Layout.grid(
1698
+ [
1699
+ Kino.Markdown.new("# " <> Path.basename(filename)),
1700
+ raw_batch |> Nx.to_list() |> Enum.at(index) |> Nx.tensor(type: :u8) |> Kino.Image.new(),
1701
+ labels_batch |> Enum.at(index) |> Kino.Markdown.new()
1702
+ ],
1703
+ boxed: true
1704
+ )
1705
+ end)
1706
+ |> Enum.to_list()
1707
+ |> Kino.Layout.grid()
1708
+ end)
1709
+ ```
1710
+
1711
+ <!-- livebook:{"output":true} -->
1712
+
1713
+ ```
1714
+ #Stream<[
1715
+ enum: #Function<76.38948127/2 in Stream.zip_with/2>,
1716
+ funs: [#Function<50.38948127/1 in Stream.map/2>]
1717
+ ]>
1718
+ ```
1719
+
1720
+ ```elixir
1721
+ visualization |> Enum.at(0)
1722
+ ```
1723
+
1724
+ ```elixir
1725
+ visualization |> Enum.at(1)
1726
+ ```