We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9800c6f commit dabfeafCopy full SHA for dabfeaf
batcher.lua
@@ -30,6 +30,16 @@ function char_to_ints(text)
30
return alphabet, encoded
31
end
32
33
+-- function for one hot encoding
34
+function ints_to_one_hot(ints, width)
35
+ local height = ints:size()[1]
36
+ local zeros = torch.zeros(height, width)
37
+ local indices = ints:view(-1, 1):long()
38
+ local one_hot = zeros:scatter(2, indices, 1)
39
+
40
+ return one_hot
41
+end
42
43
-- function to generate chunks of encoded data based on chunk size
44
function generate_chunks(encoded_text, chunk_size)
45
local n_chunks = math.floor(encoded_text:size()[1]/chunk_size)
0 commit comments