Class: Secryst::Model::Onnx
- Inherits:
-
Model
- Object
- Model
- Secryst::Model::Onnx
- Defined in:
- lib/secryst/model.rb
Instance Method Summary collapse
- #argmax(*args) ⇒ Object
- #call(input, output, opts) ⇒ Object
-
#initialize(model_path_or_bytes, input_vocab, target_vocab) ⇒ Onnx
constructor
A new instance of Onnx.
Constructor Details
#initialize(model_path_or_bytes, input_vocab, target_vocab) ⇒ Onnx
Returns a new instance of Onnx.
37 38 39 40 41 |
# File 'lib/secryst/model.rb', line 37 def initialize(model_path_or_bytes, input_vocab, target_vocab) @model = OnnxRuntime::Model.new(model_path_or_bytes) @input_vocab = input_vocab @target_vocab = target_vocab end |
Instance Method Details
#argmax(*args) ⇒ Object
47 48 49 |
# File 'lib/secryst/model.rb', line 47 def argmax(*args) self.call(*args).map { |i| i.flatten.each_with_index.max[1] } end |
#call(input, output, opts) ⇒ Object
43 44 45 |
# File 'lib/secryst/model.rb', line 43 def call(input, output, opts) @model.predict({ src: input, tgt: output }.merge(opts))['output'] end |