Module: NeuralNetworkRb::Embeddings
- Defined in:
- lib/neural_network_rb/embeddings/one_hot.rb
Class Method Summary collapse
Class Method Details
.one_hot(labels, class_count) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/neural_network_rb/embeddings/one_hot.rb', line 4 def one_hot(labels, class_count) Numo::Int8.zeros(labels.shape[0], class_count).tap do |matrix| labels.each_with_index do |v, i| matrix[i, v] = 1 end end end |