Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shape function is needed for every op #2

Closed
snnn opened this issue Oct 26, 2016 · 5 comments
Closed

Shape function is needed for every op #2

snnn opened this issue Oct 26, 2016 · 5 comments

Comments

@snnn
Copy link
Contributor

snnn commented Oct 26, 2016

No description provided.

@kopopt
Copy link
Owner

kopopt commented Oct 26, 2016

@snnn Thanks for your feedback. Can you be more specific? Currently I did not implement the shape function as it doesn't affect training/testing. Will it affect your usage case? Thanks.

@snnn
Copy link
Contributor Author

snnn commented Nov 1, 2016

Hi kopopt,

I guess it is no longer optional. There is a small change in their document of "Adding a New Op" between r0.11 and r0.10. Could you please check it? Sorry, I'm new to tensorflow so I'm not sure if I understood it correctly.

Here is my usage:
I'm trying to running your code on Windows with python 3.5 and tensorflow compiled from master branch. By now, tensorflow on Windows doesn't support dynamic loading user dlls, so I moved fm_grad_op.cc, fm_parser_op.cc and fm_scorer_op.cc to tensorflow\core\user_ops dir in my build.

And this is the output: (for command "python fast_tffm.py train sample.cfg")

Config:
  factor_num = 8
  vocabulary_size = 50000
  vocabulary_block_num = 2
  model_file = ./model
  hash_feature_id = True
  batch_size = 100
  init_value_range = 0.0001
  factor_lambda = 1
  bias_lambda = 1
  thread_num = 10
  epoch_num = 2
  train_files = ./data/train_0,./data/train_1,./data/train_2,./data/train_3,./data/train_4
  weight_files = ./data/weight_0,./data/weight_1,./data/weight_2,./data/weight_3,./data/weight_4
  validation_files = ./data/test_0,./data/test_1
  learning_rate = 0.01
  adagrad.initial_accumulator = 0.1
  loss_type = logistic
Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1789, in set_shapes_for_outputs
    shape_func = _shape_registry.lookup(op.type)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\registry.py", line 93, in lookup
    "%s registry has no entry for: %s" % (self._name, name))
LookupError: shape functions registry has no entry for: FmParser

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1792, in set_shapes_for_outputs
    shape_func = _default_shape_function_registry.lookup(op.type)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\registry.py", line 93, in lookup
    "%s registry has no entry for: %s" % (self._name, name))
LookupError: default shape functions registry has no entry for: FmParser

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "fast_tffm.py", line 101, in <module>
    local_train(train_files, weight_files, validation_files, epoch_num, vocabulary_size, vocabulary_block_num, hash_feature_id, factor_num, init_value_range, loss_type, optimizer, batch_size, factor_lambda, bias_lambda, thread_num, model_file)
  File "D:\os\tensorflow\tensorflow\contrib\cmake\fast_tffm\py\fm_train.py", line 100, in local_train
    model = LocalFmModel(_queue_size(train_files, validation_files, epoch_num), epoch_num, vocabulary_size, vocabulary_block_num, hash_feature_id,factor_num, init_value_range, loss_type, optimizer, batch_size, factor_lambda, bias_lambda)
  File "D:\os\tensorflow\tensorflow\contrib\cmake\fast_tffm\py\fm_model.py", line 68, in __init__
    self.saver = tf.train.Saver(self.vocab_blocks)
  File "C:\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3126, in device
    yield
  File "D:\os\tensorflow\tensorflow\contrib\cmake\fast_tffm\py\fm_model.py", line 55, in __init__
    labels, weights, ori_ids, feature_ids, feature_vals, feature_poses = fm_ops.fm_parser(self.file_id, self.data_file, self.weight_file, batch_size, vocabulary_size, hash_feature_id)
  File "C:\Python35\lib\site-packages\tensorflow\python\ops\gen_user_ops.py", line 95, in fm_parser
    hash_feature_id=hash_feature_id, name=name)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 759, in apply_op
    return op
  File "C:\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3698, in get_controller
    yield default
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 759, in apply_op
    return op
  File "C:\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 4216, in name_scope
    yield scope
  File "C:\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 3698, in get_controller
    yield default
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 4216, in name_scope
    yield scope
  File "C:\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2944, in name_scope
    yield "" if new_stack is None else new_stack + "/"
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 4216, in name_scope
    yield scope
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 759, in apply_op
    return op
  File "C:\Python35\lib\contextlib.py", line 77, in __exit__
    self.gen.throw(type, value, traceback)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 254, in _MaybeColocateWith
    yield
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\op_def_library.py", line 750, in apply_op
    op_def=op_def)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 2423, in create_op
    set_shapes_for_outputs(ret)
  File "C:\Python35\lib\site-packages\tensorflow\python\framework\ops.py", line 1795, in set_shapes_for_outputs
    % op.type)
RuntimeError: No shape function registered for standard op: FmParser

@kopopt
Copy link
Owner

kopopt commented Nov 3, 2016

@snnn
I upgraded tensorflow on my mac and ubuntu from 0.10 to 0.11.0rc2, and it is still working.. I use python 2.

@snnn
Copy link
Contributor Author

snnn commented Nov 3, 2016

You are right. I tested it on my Fedora machine, it works well. So it is a windows specific problem.

@snnn snnn closed this as completed Nov 3, 2016
@snnn
Copy link
Contributor Author

snnn commented Nov 4, 2016

Added

_ops.RegisterShape("FmGrad")(None)
_ops.RegisterShape("FmParser")(None)
_ops.RegisterShape("FmScorer")(None)

to C:\Python35\Lib\site-packages\tensorflow\python\ops\gen_user_ops.py in my tensorflow installation, now it works on Windows.

Thank you!

windreamer pushed a commit to douban/fast_tffm that referenced this issue Aug 8, 2017
* tensorboard & regex

* Update fm_train.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants