I have code for BoostedTreesClassifier which works, but takes a very long time with the amount of data i'm feeding it and the parameters i'm choosing i.e max_depth https://www.tensorflow.org/api_docs/python/tf/estimator/BoostedTreesClassifier
I'm attempting to use BoostedTreesClassifier estimator in Colab with TPUs, using TPUEstimator https://www.tensorflow.org/api_docs/python/tf/contrib/tpu/TPUEstimator
Is BoostedTreesClassifier possible with TPUEstimator? I am seeing that only neural networks can be used with Estimator/TPUEstimator https://www.tensorflow.org/guide/using_tpu
What is the correct approach to get BoostedTreesClassifier working with Colab TPUs?
tpu_estimator = tf.contrib.tpu.TPUEstimator(
model_fn=model_fn,
config=my_tpu_run_config,
train_batch_size=100,
use_tpu=True)
I think using the TPUStrategy is the right approach, but it's still taking a long time for some reason.
import pandas as pd
import numpy as np
import tensorflow as tf
print(tf.__version__)
resolver = tf.distribute.cluster_resolver.TPUClusterResolver()
tf.tpu.experimental.initialize_tpu_system(resolver)
tpu_strategy = tf.distribute.experimental.TPUStrategy(resolver)
with tpu_strategy.scope():
model = tf.estimator.BoostedTreesClassifier(
feature_columns=attibute_columns,
n_batches_per_layer=10,
center_bias=True,
n_trees=100,
max_depth=20,
pruning_mode='post',
tree_complexity=0.1)
model.train(input_fn=train_input_fn)
results = model.evaluate(eval_input_fn)
print(results)