def create_calibrated_lattice(feature_columns, config, quantiles_dir): """Creates a calibrated Lattice estimator.""" feature_names = [fc.name for fc in feature_columns] hparams = tfl.CalibratedLatticeHParams( feature_names=feature_names, learning_rate=FLAGS.learning_rate, lattice_l2_laplacian_reg=5.0e-4, lattice_l2_torsion_reg=1.0e-4, interpolation_type='hypercube', num_keypoints=8, feature__outerIters__monotonicity=1, feature__innerIters__monotonicity=1, # feature__bitsPerCycle__monotonicity=-1, # feature__innerIters__lattice_size=3, # feature__outerIters__lattice_size=3, # monotonicity=frozenset({'outerIters': 1}.items), lattice_size=3, lattice_rank=len(feature_columns), num_lattices=FLAGS.num_lattices, optimizer=tf.train.AdamOptimizer) # Specific feature parameters. hparams.parse(FLAGS.hparams) _pprint_hparams(hparams) return tfl.calibrated_lattice_regressor(feature_columns=feature_columns, model_dir=config.model_dir, config=config, quantiles_dir=quantiles_dir, keypoints_initializers_fn=None, optimizer=tf.train.AdamOptimizer, hparams=hparams)
def create_calibrated_lattice(feature_columns, config, quantiles_dir): feature_names = [fc.name for fc in feature_columns] hparams = tfl.CalibratedLatticeHParams(feature_names=feature_names, num_keypoints=200, lattice_l2_laplacian_reg=5e-4, lattice_l2_torsion_reg=1e-4, learning_rate=lr, lattice_size=2) hparams.set_feature_param("feature1", "monotonicity", 1) return tfl.calibrated_lattice_classifier(feature_columns=feature_columns, model_dir=config.model_dir, config=config, hparams=hparams, quantiles_dir=quantiles_dir)
def create_calibrated_lattice(feature_columns, config, quantiles_dir): """Creates a calibrated lattice estimator.""" feature_names = [fc.name for fc in feature_columns] hparams = tfl.CalibratedLatticeHParams(feature_names=feature_names, num_keypoints=200, lattice_l2_laplacian_reg=5.0e-3, lattice_l2_torsion_reg=1.0e-4, learning_rate=0.1, lattice_size=2) hparams.parse(FLAGS.hparams) _pprint_hparams(hparams) return tfl.calibrated_lattice_classifier(feature_columns=feature_columns, model_dir=config.model_dir, config=config, hparams=hparams, quantiles_dir=quantiles_dir)
test_features = { 'distance': np.array([5.0, 10.0]), 'quality': np.array([3.0, 3.0]), } # Feature definition. feature_columns = [ tf.feature_column.numeric_column('distance'), tf.feature_column.numeric_column('quality'), ] # Hyperparameters. num_keypoints = 10 hparams = tfl.CalibratedLatticeHParams( feature_names=['distance', 'quality'], num_keypoints=num_keypoints, learning_rate=0.1, ) # Set feature monotonicity. hparams.set_feature_param('distance', 'monotonicity', -1) hparams.set_feature_param('quality', 'monotonicity', +1) # Define keypoint init. keypoints_init_fns = { 'distance': lambda: tfl.uniform_keypoints_for_signal(num_keypoints, input_min=0.0, input_max=10.0, output_min=0.0, output_max=1.0),
{"x": x_train}, y_train, batch_size=batch_size, num_epochs=1000, shuffle=False) # ==================================== # 訓練(トレーニング) # ==================================== # 機能のリストを宣言する。 1つの数値機能しかありません。 より複雑で有用な他の多くのタイプの列があります。 feature_columns = [ tf.feature_column.numeric_column("x") ] # Hyperparameters. num_keypoints = 20 hparams = tfl.CalibratedLatticeHParams( feature_names=['x'], num_keypoints=num_keypoints, learning_rate=0.1, lattice_rank=2 ) # Set feature monotonicity. hparams.set_feature_param('x', 'monotonicity', -1) # Define keypoint init. keypoints_init_fns = { 'x': lambda: tfl.uniform_keypoints_for_signal(num_keypoints, input_min=-5.0, input_max=5.0, output_min=0.0, output_max=25.0), }