我正在尝试使用小提琴在 Ruby 中定义Tinn C 库,但它给了我一个结构错误
廷恩.h
typedef struct
{
// All the weights.
float* w;
// Hidden to output layer weights.
float* x;
// Biases.
float* b;
// Hidden layer.
float* h;
// Output layer.
float* o;
// Number of biases - always two - Tinn only supports a single hidden layer.
int nb;
// Number of weights.
int nw;
// Number of inputs.
int nips;
// Number of hidden neurons.
int nhid;
// Number of outputs.
int nops;
}
Tinn;
float* xtpredict(Tinn, const float* in);
float xttrain(Tinn, const float* in, const float* tg, float rate);
Tinn xtbuild(int nips, int nhid, int nops);
红宝石小提琴
module Tinn
extend Fiddle::Importer
dlload './tinn.so'
Tinn = struct [
# All the weights.
'float* w',
# Hidden to output layer weights.
'float* x',
# Biases.
'float* b',
# Hidden layer.
'float* h',
# Output layer.
'float* o',
# Number of biases - always two - Tinn only supports a single hidden layer.
'int nb',
# Number of weights.
'int nw',
# Number of inputs.
'int nips',
# Number of hidden neurons.
'int nhid',
# Number of outputs.
'int nops'
]
extern 'float* xtpredict(Tinn, const float* in)'
extern 'float xttrain(Tinn, const float* in, const float* tg, float rate)'
extern 'Tinn xtbuild(int nips, int nhid, int nops)'
end
我收到这样的错误
/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/fiddle/cparser.rb:177:in `parse_ctype': unknown type: Tinn (Fiddle::DLError)
from /home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/fiddle/cparser.rb:90:in `block in parse_signature'
from /home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/fiddle/cparser.rb:90:in `collect'
from /home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/fiddle/cparser.rb:90:in `parse_signature'
from /home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/fiddle/import.rb:163:in `extern'
from rb_tinn.rb:31:in `<module:Tinn>'
from rb_tinn.rb:4:in `<main>'
第 31 行指向我们将 struct 作为参数传递的第一个函数
float* xtpredict(Tinn, const float* in)
我已经将 Tinn 定义为一个结构,但它仍然给出错误。