GithubHelp home page GithubHelp logo

Comments (7)

maoyanying avatar maoyanying commented on July 26, 2024

Could you please tell me to generate yelp_academic_dataset_review.json?

from hierarchical-attention-networks.

maoyanying avatar maoyanying commented on July 26, 2024

Could you please tell me how to generate yelp_academic_dataset_review.json?

from hierarchical-attention-networks.

MtDersvan avatar MtDersvan commented on July 26, 2024

@maoyanying you need to register and download the dataset from here https://www.yelp.com/dataset_challenge. After, use the code in the README to launch the data prep:

python3 yelp_prepare.py yelp_academic_dataset_review.json

from hierarchical-attention-networks.

maoyanying avatar maoyanying commented on July 26, 2024

Thanks a lot.I have done it.When I use the code :
python3 worker.py --mode=eval
There is a erro:
File "worker.py", line 211, in
main()
File "worker.py", line 208, in main
evaluate(task.read_devset(epochs=1))
File "worker.py", line 142, in evaluate
model, _ = model_fn(s, restore_only=True)
File "worker.py", line 87, in HAN_model_1
is_training=is_training,
File "/home/bfs/Myy/NN/HATTdeep-text-classifier-master/HAN_model.py", line 64, in init
self._init_embedding(scope)
File "/home/bfs/Myy/NN/HATTdeep-text-classifier-master/HAN_model.py", line 101, in _init_embedding
dtype=tf.float32)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 988, in get_variable
custom_getter=custom_getter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 890, in get_variable
custom_getter=custom_getter)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 348, in get_variable
validate_shape=validate_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 333, in _true_getter
caching_device=caching_device, validate_shape=validate_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variable_scope.py", line 684, in _get_single_variable
validate_shape=validate_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 197, in init
expected_shape=expected_shape)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/variables.py", line 315, in _init_from_args
self._snapshot = array_ops.identity(self._variable, name="read")
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/gen_array_ops.py", line 1490, in identity
result = _op_def_lib.apply_op("Identity", input=input, name=name)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/op_def_library.py", line 763, in apply_op
op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2327, in create_op
original_op=self._default_original_op, op_def=op_def)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 1226, in init
self._traceback = _extract_stack()

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value tcm/embedding/embedding_matrix
[[Node: tcm/embedding/embedding_matrix/read = IdentityT=DT_FLOAT, _class=["loc:@tcm/embedding/embedding_matrix"], _device="/job:localhost/replica:0/task:0/cpu:0"]]

How do you deal with it?

from hierarchical-attention-networks.

MtDersvan avatar MtDersvan commented on July 26, 2024

@maoyanying I did not encounter such an error. Check python and tensorflow version, works for me on python 3.5 and tensorflow 1.2.

from hierarchical-attention-networks.

gaussic avatar gaussic commented on July 26, 2024

@MtDersvan Have you implemented it yet? I'm interested in implementing it recently.

from hierarchical-attention-networks.

MtDersvan avatar MtDersvan commented on July 26, 2024

Hi @gaussic ! Sorry for the late reply!
I don't think it was meant by tensorflow core team for that, I have asked them but to no avail(
So, I just implemented it in tensorflow without new seq2seq API.
It's actually quite easy:

def attention_reduction(self,
                        inputs,
                        output_size,
                        initializer=tf.contrib.layers.xavier_initializer(),
                        activation_fn=tf.tanh, 
                        scope=None):
    
    with tf.variable_scope(scope or 'Attention_Reduction') as scope:
        attention_context_vector = tf.get_variable(
            name='attention_context_vector',
            shape=[output_size],
            initializer=initializer,
            dtype=tf.float32)
        input_projection = tf.contrib.layers.fully_connected(
            inputs,
            output_size,
            activation_fn=activation_fn,
            scope=scope)
        vector_attention = tf.reduce_sum(
            tf.multiply(input_projection, attention_context_vector), 
            axis=2, 
            keep_dims=True)
        attention_weights = tf.nn.softmax(vector_attention, dim=1)
        weighted_projection = tf.multiply(input_projection, attention_weights)

        outputs = tf.reduce_sum(weighted_projection, axis=1)

        return outputs, attention_weights

from hierarchical-attention-networks.

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.