devsisters / pointer-network-tensorflow Goto Github PK
View Code? Open in Web Editor NEWTensorFlow implementation of "Pointer Networks"
License: MIT License
TensorFlow implementation of "Pointer Networks"
License: MIT License
line 179 i think losses should be inference_losses
Hi,
Thanks for your code sharing.
But I found there are some problems in layers.index_matrix_to_pairs function:
By using the original code, I can't get
[[[0, 3], [1, 1], [2, 2]],
[[0, 2], [1, 3], [2, 1]]]
while inputing [[3,1,2], [2,3,1]].
It works, after I change the code to:
def index_matrix_to_pairs(index_matrix):
# [[3,1,2], [2,3,1]] -> [[[0, 3], [1, 1], [2, 2]],
# [[0, 2], [1, 3], [2, 1]]]
replicated_first_indices = tf.range(tf.shape(index_matrix)[1])
rank = len(index_matrix.get_shape())
if rank == 2:
replicated_first_indices = tf.tile(
tf.expand_dims(replicated_first_indices, dim=0),
[tf.shape(index_matrix)[0], 1]
)
return tf.stack([replicated_first_indices, index_matrix], axis=rank)
I don't know either the given example or the code is wrong.
In my test, this project need the api version 1.0 for tensorflow. The ReadMe file need to update this information for user's convenience.
Thanks
Below is line 40 and line 45 in model.py. The is_training variable is always set to False without changing based on config.
`
self.is_training = tf.placeholder_with_default(
tf.constant(False, dtype=tf.bool),
shape=(), name='is_training'
)
self.enc_inputs, self.dec_targets, self.enc_seq_length, self.dec_seq_length, self.mask =
smart_cond(
self.is_training,
lambda: (inputs['train'], labels['train'], enc_seq_length['train'],
dec_seq_length['train'], mask['train']),
lambda: (inputs['test'], labels['test'], enc_seq_length['test'],
dec_seq_length['test'], mask['test'])
)
`
the comment is:[[3,1,2], [2,3,1]] -> [[[0, 3], [1, 1], [2, 2]], [[0, 2], [1, 3], [2, 1]]]
but when I test it, it output this:[[[0 3],[0 1],[0 2]],[[1 2],[1 3],[1 1]]]
this is test code:
with tf.Session():
,,,,,,,print index_matrix_to_pairs(tf.constant([[3,1,2], [2,3,1]])).eval()
File "xxx/project/PycharmProjects/seq2sql/pointer-network/pointer-network-tensorflow/layers.py", line 22, in
dynamic_rnn_decoder = tf.contrib.seq2seq.dynamic_rnn_decoder
AttributeError: 'module' object has no attribute 'dynamic_rnn_decoder'
print tensorflow.version
1.0.0
Hi,
I just cloned your repo and downloaded tensorflow version 0.12.1. I am trying to run your example code. I am getting errors on the imports:
Traceback (most recent call last):
File "main.py", line 5, in
from trainer import Trainer
File ".../pointer-network-tensorflow/trainer.py", line 7, in
from model import Model
File ".../pointer-network-tensorflow/model.py", line 4, in
from layers import *
File ".../pointer-network-tensorflow/layers.py", line 7, in
LSTMCell = rnn.LSTMCell
AttributeError: 'module' object has no attribute 'LSTMCell'.
From looking at the tensorflow docs it seems that LSTMCell is now located at:
tf.nn.rnn_cell.STMCell. I changed the code to read: LSTMCell = tf.nn.rnn_cell.LSTMCell and made a similar change for the next line of layers.py: MultiRNNCell = tf.nn.rnn_cell.MultiRNNCell.
I'm now getting a similar error on the seq2seq line, and can't figure out how to fix it:
Traceback (most recent call last):
File "main.py", line 5, in
from trainer import Trainer
File ".../pointer-network-tensorflow/trainer.py", line 7, in
from model import Model
File ".../pointer-network-tensorflow/model.py", line 4, in
from layers import *
File ".../pointer-network-tensorflow/layers.py", line 9, in
dynamic_rnn_decoder = seq2seq.dynamic_rnn_decoder
AttributeError: 'module' object has no attribute 'dynamic_rnn_decoder'
It seems that tensorflow.contrib.seq2seq exists but does not have a dynamic_rnn_decoder function in version 12.1.0? Can you confirm that this is still working on your version and that you are in fact using tensorflow version 12.1.0.
Thanks!
Maddie
with the program , l can train my data, but l can't test my data, It has a RuntimeError: Coordinator stopped with threads still running: Thread-11 Thread-12...can you give me some suggestion about it
hi,because in the code, all data has been filled with zeros, then seq_length = tf.shape(inputs)[0] should be the same, I think it should be calculated after removing all zero rows?
Did anyone get a working version of this? Which version of tensorflow did you use and which adaptions did you make?
In layers.py, can the 'xrange' change to 'range'? We want to use Python3.6
Hi,
I am reading the pointer-network codes. However, I have a question in model.py file. In model.py, line 133-134, you gathered enc_output into dec_inputs. But in the original paper, it seems that the decoder inputs should be from enc_inputs.
133 self.embeded_dec_inputs = tf.stop_gradient(
134 tf.gather_nd(self.enc_outputs, self.idx_pairs))
Could you explain this a little bit?
Best,
Zhe
When I run the main.py, getting the following errors:
Traceback (most recent call last):
File "main.py", line 5, in
from trainer import Trainer
File "/Users/peng.huangp/github/pointer-network-tensorflow/trainer.py", line 7, in
from model import Model
File "/Users/peng.huangp/github/pointer-network-tensorflow/model.py", line 4, in
from layers import *
File "/Users/peng.huangp/github/pointer-network-tensorflow/layers.py", line 22, in
dynamic_rnn_decoder = tf.contrib.seq2seq.dynamic_rnn_decoder
AttributeError: 'module' object has no attribute 'dynamic_rnn_decoder'
I check 0.1.2.1 API of tensorflow, and can not find the definition for 'dynamic_rnn_decoder', and it is in the 0.1.0 API
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.