GithubHelp home page GithubHelp logo

Comments (3)

candyzone avatar candyzone commented on May 29, 2024

Thanks for your issue and we will check it.

from deeprec.

candyzone avatar candyzone commented on May 29, 2024

it works in my testcase.

import tensorflow as tf
import os

checkpoint_directory = '/tmp/1'
with tf.device("/cpu:0"):
columns = tf.feature_column.categorical_column_with_embedding("col_emb", dtype=tf.string,
ev_option = tf.EmbeddingVariableOption(filter_option=tf.CounterFilter(filter_freq=3)))
W = tf.feature_column.embedding_column(columns,
dimension=3,
initializer=tf.ones_initializer(tf.float32))
ids={}
ids["col_emb"] = tf.SparseTensor(indices=[[0,0],[1,0],[2,0],[3,0],[4,0],[5,0]], values=['1','1','1','2','2','3'], dense_shape=[6, 1])
emb = tf.feature_column.input_layer(ids, [W])
fun = tf.multiply(emb, 2.0, name='multiply')
loss = tf.reduce_sum(fun, name='reduce_sum')
gs = tf.train.get_or_create_global_step()
opt = tf.train.AdagradOptimizer(0.1)
g_v = opt.compute_gradients(loss)
train_op = opt.apply_gradients(g_v, gs)
saver = tf.train.Saver()
init = tf.global_variables_initializer()
model_path = os.path.join(checkpoint_directory,
"model1.ckpt")
with tf.Session() as sess:
sess.run([init])
sess.run([train_op])
save_path = saver.save(sess, model_path)
for name, shape in tf.train.list_variables(model_path):
print(name, shape)

from deeprec.

dixingxing0 avatar dixingxing0 commented on May 29, 2024

We discovered that our string column wasn't a SparseTensor. After making a minor adjustment, it functioned as expected. Thanks @candyzone .
image

from deeprec.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.