lib/rumale/kernel_approximation/rbf.rb in rumale-0.11.0 vs lib/rumale/kernel_approximation/rbf.rb in rumale-0.12.0

- old
+ new

@@ -8,11 +8,11 @@ # Module for kernel approximation algorithms. module KernelApproximation # Class for RBF kernel feature mapping. # # @example - # transformer = Rumale::KernelApproximation::RBF.new(gamma: 1.0, n_coponents: 128, random_seed: 1) + # transformer = Rumale::KernelApproximation::RBF.new(gamma: 1.0, n_components: 128, random_seed: 1) # new_training_samples = transformer.fit_transform(training_samples) # new_testing_samples = transformer.transform(testing_samples) # # *Refernce*: # 1. A. Rahimi and B. Recht, "Random Features for Large-Scale Kernel Machines," Proc. NIPS'07, pp.1177--1184, 2007. @@ -61,11 +61,12 @@ # @return [RBF] The learned transformer itself. def fit(x, _y = nil) check_sample_array(x) n_features = x.shape[1] + sub_rng = @rng.dup @params[:n_components] = 2 * n_features if @params[:n_components] <= 0 - @random_mat = Rumale::Utils.rand_normal([n_features, @params[:n_components]], @rng) * (2.0 * @params[:gamma])**0.5 + @random_mat = Rumale::Utils.rand_normal([n_features, @params[:n_components]], sub_rng) * (2.0 * @params[:gamma])**0.5 n_half_components = @params[:n_components] / 2 @random_vec = Numo::DFloat.zeros(@params[:n_components] - n_half_components).concatenate( Numo::DFloat.ones(n_half_components) * (0.5 * Math::PI) ) self