Class: TLearnExt
- Inherits:
-
Object
- Object
- TLearnExt
- Defined in:
- ext/tlearn/tlearn_ext.c
Class Method Summary collapse
- .fitness(config) ⇒ Object
-
.train(config) ⇒ Object
– Ruby interface –.
Class Method Details
.fitness(config) ⇒ Object
431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 |
# File 'ext/tlearn/tlearn_ext.c', line 431 static VALUE tlearn_fitness(VALUE self, VALUE config) { VALUE ruby_array = rb_ary_new(); VALUE file_root_value = rb_hash_aref(config, ID2SYM(rb_intern("file_root"))); VALUE sweeps_value = rb_hash_aref(config, ID2SYM(rb_intern("sweeps"))); long nsweeps = NUM2DBL(sweeps_value); char *file_root = StringValueCStr(file_root_value); float *result_weights; float current_weights_output[6]; int failure = run_fitness(nsweeps, file_root, current_weights_output); post_cleanup(); if(failure == 0){ float weight; int result_index; for(result_index = 0; result_index < 6; result_index++){ weight = current_weights_output[result_index]; rb_ary_store(ruby_array, result_index, rb_float_new(weight)); } return(ruby_array); } else{ return(rb_int_new(failure)); } } |
.train(config) ⇒ Object
– Ruby interface –
415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'ext/tlearn/tlearn_ext.c', line 415 static VALUE tlearn_train(VALUE self, VALUE config) { VALUE sweeps_value = rb_hash_aref(config, ID2SYM(rb_intern("sweeps"))); long nsweeps = NUM2DBL(sweeps_value); VALUE file_root_value = rb_hash_aref(config, ID2SYM(rb_intern("file_root"))); char *file_root = StringValueCStr(file_root_value); float current_weights_output[6]; int result = run_training(nsweeps, file_root, current_weights_output); post_cleanup(); return rb_int_new(result); } |