I want to make system recommendations using custom data with TensorFlow recommenders, I have followed the tutorial on the official website (https://www.tensorflow.org/recommenders), and I also followed the tutorial at here
problem:
The recommended results are given outside of the options provided by the dataset. For example, in my dataset, there are only 3 items, say 1, 2, and 3. However, the recommendations given are items 1, 4, 6, 9, 11, and so on.
from typing import Dict, Text
import numpy as np
import pandas as pd
import tensorflow as tf
import tensorflow_datasets as tfds
import tensorflow_recommenders as tfrs
DATA_URL = "sample.csv"
df = pd.read_csv(DATA_URL)
ratings = tf.data.Dataset.from_tensor_slices(df[['item_id', 'user_id']].values)
items = tf.data.Dataset.from_tensor_slices(df[['item_id']].values)
user_id_vocabulary = tf.keras.layers.IntegerLookup()
user_id_vocabulary.adapt(ratings)
items_vocabulary = tf.keras.layers.IntegerLookup()
items_vocabulary.adapt(items)
class CustomModel(tfrs.Model):
# We derive from a custom base class to help reduce boilerplate. Under the hood,
# these are still plain Keras Models.
def __init__(
self,
user_model: tf.keras.Model,
item_model: tf.keras.Model,
task: tfrs.tasks.Retrieval):
super().__init__()
# Set up user and movie representations.
self.user_model = user_model
self.item_model = item_model
# Set up a retrieval task.
self.task = task
def compute_loss(self, features: Dict[Text, tf.Tensor], training=False) -> tf.Tensor:
# Define how the loss is computed.
user_embeddings = self.user_model(features[0])
item_embeddings = self.item_model(features[1])
return self.task(user_embeddings, item_embeddings)
users_model = tf.keras.Sequential([user_id_vocabulary, tf.keras.layers.Embedding(user_id_vocabulary.vocabulary_size(),64)])
items_model = tf.keras.Sequential([items_vocabulary,tf.keras.layers.Embedding(items_vocabulary.vocabulary_size(),64)])
task = tfrs.tasks.Retrieval(metrics=tfrs.metrics.FactorizedTopK(
items.batch(128).map(items_model)))
model = CustomModel(users_model,items_model,task)
model.compile(optimizer=tf.keras.optimizers.Adagrad(0.5))
model.fit(ratings.batch(8), epochs=3)
# Use brute-force search to set up retrieval using the trained representations.
index = tfrs.layers.factorized_top_k.BruteForce(model.user_model)
index.index_from_dataset(
items.batch(100).map(items_model))
# Get some recommendations.
_, titles = index(np.array([1]))
print(f"Top 3 recommendations for user 1: {titles[0, :3]}")
# print every recommendations.
titlesNumpy = titles.numpy()
for i in titlesNumpy[0]:
print(i)
I want to make system recommendations using custom data with TensorFlow recommenders, I have followed the tutorial on the official website (https://www.tensorflow.org/recommenders), and I also followed the tutorial at here problem: [list] [*]The recommended results are given outside of the options provided by the dataset. For example, in my dataset, there are only 3 items, say 1, 2, and 3. However, the recommendations given are items 1, 4, 6, 9, 11, and so on. [/list] My environment: [list] [*]google colab (https://colab.research.google.com/) [*]Python 3.7.14 [*]Tensorflow 2.10.0 [*]tensorflow_recommenders 0.7.2 [/list] Dataset (sample.csv): [img]https://i.stack.imgur.com/NmBru.png[/img] The full code: [code]from typing import Dict, Text
import numpy as np import pandas as pd import tensorflow as tf
import tensorflow_datasets as tfds import tensorflow_recommenders as tfrs
model = CustomModel(users_model,items_model,task) model.compile(optimizer=tf.keras.optimizers.Adagrad(0.5)) model.fit(ratings.batch(8), epochs=3)
# Use brute-force search to set up retrieval using the trained representations. index = tfrs.layers.factorized_top_k.BruteForce(model.user_model) index.index_from_dataset( items.batch(100).map(items_model))
# Get some recommendations. _, titles = index(np.array([1])) print(f"Top 3 recommendations for user 1: {titles[0, :3]}")
# print every recommendations. titlesNumpy = titles.numpy() for i in titlesNumpy[0]: print(i) [/code] The result: [code]Epoch 1/3 WARNING:tensorflow:5 out of the last 13 calls to triggered tf.function retracing. Tracing is expensive and the excessive number of tracings could be due to (1) creating @tf.function repeatedly in a loop, (2) passing tensors with different shapes, (3) passing Python objects instead of tensors. For (1), please define your @tf.function outside of the loop. For (2), @tf.function has reduce_retracing=True option that can avoid unnecessary retracing. For (3), please refer to https://www.tensorflow.org/guide/function#controlling_retracing and https://www.tensorflow.org/api_docs/python/tf/function for more details. 3/3 [==============================] - 1s 60ms/step - factorized_top_k/top_1_categorical_accuracy: 0.0000e+00 - factorized_top_k/top_5_categorical_accuracy: 0.0000e+00 - factorized_top_k/top_10_categorical_accuracy: 0.1667 - factorized_top_k/top_50_categorical_accuracy: 1.0000 - factorized_top_k/top_100_categorical_accuracy: 1.0000 - loss: 1.3775 - regularization_loss: 0.0000e+00 - total_loss: 1.3775 Epoch 2/3 3/3 [==============================] - 0s 60ms/step - factorized_top_k/top_1_categorical_accuracy: 0.3333 - factorized_top_k/top_5_categorical_accuracy: 0.3333 - factorized_top_k/top_10_categorical_accuracy: 0.3333 - factorized_top_k/top_50_categorical_accuracy: 1.0000 - factorized_top_k/top_100_categorical_accuracy: 1.0000 - loss: 1.0671 - regularization_loss: 0.0000e+00 - total_loss: 1.0671 Epoch 3/3 3/3 [==============================] - 0s 61ms/step - factorized_top_k/top_1_categorical_accuracy: 0.3333 - factorized_top_k/top_5_categorical_accuracy: 0.3333 - factorized_top_k/top_10_categorical_accuracy: 0.6667 - factorized_top_k/top_50_categorical_accuracy: 1.0000 - factorized_top_k/top_100_categorical_accuracy: 1.0000 - loss: 0.4586 - regularization_loss: 0.0000e+00 - total_loss: 0.4586 Top 3 recommendations for user 1: [1 4 6] 1 4 6 9 11 14 0 3 8 13 [/code] how to solve the problem? what's wrong with my code?
Можно ли найти матрицу с фиксированными собственными значениями и собственными векторами?
Я много искал, но я не могу найти ответ, поэтому я спрашиваю.
Я сравниваю производительность cuSOLVER и ARM PL во встраиваемых системах. Хотя cuSOLVER прошел проверку, я столкнулся с некоторыми проблемами при использовании ARM PL.
Например, в следующей одноэтапной функции EVD chbevd_ результаты значительно...
Я пытаюсь построить модель MLP с помощью PyleArn2. Но руководство не настолько явно в том, как импортировать внешние данные (все уроки используют набор данных MNIST).
Итак, мои данные являются файлами CSV:
0 0.129 -0.234 0.394 ...
0 0.293 -0.394...
Контекст: У меня есть система C# с локальной базой SQL Server...
И у меня также есть HA, настроенный в Windows Server 2016 с 1 DC, где находится мой AD и домен, и 3 клиентскими компьютерами, присоединенными к этому домену, на которых установлен...
Построить инструмент службы мониторинга сотрудников. Я использую службу Windows для создания инструмента. Теперь я очень запутался, какую услугу мне нужно использовать для создания этого инструмента. Эта путаница возникает, когда я пытался...