I'm attempting to train the tflite_model_maker recommendation on custom data but I'm running into issues with turning my CSV into a dataset that it'll accept. All of the examples I've found online are utilizing the MovieLens dataset which skips over this problem, and the steps I've found for just tflite don't seem to work here. This is the simplified version of what I'm stuck on currently, Any help would be appreciated.
Dataset sample:
user_id post_ids
0 228000 800472
1 228000 795240
2 228021 756878
3 228021 828332
4 228009 834848
My attempt to load the data:
import pandas as pd
import tensorflow as tf
data = pd.read_csv('./dataset.csv')
dataset = tf.data.Dataset.from_tensor_slices(dict(data)).map(lambda x: {
"user_id": int(x["user_id"]),
"post_ids": int(x["post_ids"])
})
Attempt to train:
from tflite_model_maker import recommendation
spec='recommendation_bow'
model_x = recommendation.create(
dataset, spec, model_spec_options=None, model_dir=None,
validation_data=None, batch_size=16, steps_per_epoch=10000, epochs=1,
learning_rate=0.1, gradient_clip_norm=1.0, shuffle=True, do_train=True,
max_history_length=10
)
Error:
INFO:tensorflow:Training recommendation model...
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-24-a1fef1fee081> in <module>()
5 validation_data=None, batch_size=16, steps_per_epoch=10000, epochs=1,
6 learning_rate=0.1, gradient_clip_norm=1.0, shuffle=True, do_train=True,
----> 7 max_history_length=10
8 )
1 frames
/usr/local/lib/python3.7/dist-packages/tensorflow_examples/lite/model_maker/core/task/recommendation.py in train(self, train_data, validation_data, batch_size, steps_per_epoch, epochs)
101 batch_size = batch_size if batch_size else self.model_spec.batch_size
102
--> 103 train_ds = train_data.gen_dataset(
104 batch_size, is_training=True, shuffle=self.shuffle)
105 if validation_data:
AttributeError: 'MapDataset' object has no attribute 'gen_dataset'