Comments (8)
had you resolve this error。can you help give us the method。i replace tf.nn.bidirectional_rnn to tf.nn.bidirectional_dynamic_rnn,it still donot work。
from ner-lstm.
@gahu1125 It really depends on your use case. If you don't know your nsteps parameter in advance, you can set it None when defining input or output placeholder and use the dynamic one but if you know your max_nstetps in advance and have sufficient gpu memory you can even use the static verison.
I'm posting an snippet from my code for your reference:
def multi_layer_birnn_static(config, input, seq_len, dropout):
nhidden = config.nb_hidden
ntags = config.out_dim
nsteps = config.nb_steps
nlayers = config.nb_layers
cell = rnn_cell(config.cell_type)
# input shape: (batch_size, nsteps, in_dim)
# Unstack to get a list of 'n_steps' tensors of shape (batch_size, n_input)
input = tf.unstack(input, nsteps, 1)
def _single_cell():
_cell = cell(num_units=nhidden, state_is_tuple=True)
_cell = tf.contrib.rnn.DropoutWrapper(_cell, output_keep_prob=dropout)
return _cell
fw_cell = tf.contrib.rnn.MultiRNNCell(cells=[_single_cell() for _ in range(nlayers)], state_is_tuple = True)
bw_cell = tf.contrib.rnn.MultiRNNCell(cells=[_single_cell() for _ in range(nlayers)], state_is_tuple = True)
output, _, _ = tf.contrib.rnn.static_bidirectional_rnn(fw_cell, bw_cell, input ,dtype=tf.float32)
output = tf.stack(output, 1)
return output
def multi_layer_birnn_dynamic(config, input, seq_len, dropout):
nhidden = config.nb_hidden
ntags = config.out_dim
nsteps = config.nb_steps
nlayers = config.nb_layers
cell = rnn_cell(config.cell_type)
# permute n_steps and batch_size
input = tf.transpose(input, [1, 0, 2])
def _single_cell():
_cell = cell(num_units=nhidden, state_is_tuple=True)
_cell = tf.contrib.rnn.DropoutWrapper(_cell, output_keep_prob=dropout)
return _cell
fw_cell = tf.contrib.rnn.MultiRNNCell(cells=[_single_cell() for _ in range(nlayers)], state_is_tuple = True)
bw_cell = tf.contrib.rnn.MultiRNNCell(cells=[_single_cell() for _ in range(nlayers)], state_is_tuple = True)
outputs, states = tf.nn.bidirectional_dynamic_rnn(
cell_fw=fw_cell,
cell_bw=bw_cell,
dtype=tf.float32,
inputs=input,
time_major=True,
sequence_length=seq_len)
out_fw, out_bw = outputs
output = tf.concat([out_fw, out_bw], axis=-1)
output = tf.transpose(output, [1, 0 ,2])
return output
from ner-lstm.
https://github.com/swethmandava/text_normalization/blob/master/blstm_new.py May be this can help
from ner-lstm.
@gahu1125 Were you able to resolve the issue? I am also facing the same issue.
from ner-lstm.
@lin520chong Did you solve this issue ?
from ner-lstm.
maybe you can get solution from this https://github.com/KeithYin/mycodes/blob/master/tensorflow-piece/diy-multi-layer-bi-rnn.py
from ner-lstm.
for tensorflow version 1.10.1 this issue still exists.
from ner-lstm.
Updated code here with bidirectional_dynamic_rnn and using TF 1.4
https://github.com/gopi1410/ner-lstm
from ner-lstm.
Related Issues (20)
- get_conll_embeddings.py question HOT 1
- output trained NERs HOT 1
- "key error" while generating conll embeddings HOT 1
- Cost function HOT 2
- How to run this project
- Dropout shoud be 1 during test time.
- Glove error vector.txt not found HOT 1
- ValueError: setting an array element with a sequence. HOT 1
- Configurations on local machine HOT 1
- test data is labeled and is in iob format
- how to generate training data to train our custom ner ? HOT 1
- this cannot support tensorflow1.3 HOT 2
- Want to print prediction of unclassified text
- the F1-Score of CoNLL 2003 English dataset HOT 2
- can you provide source for Hindi training dataset? HOT 1
- how to run ? HOT 1
- use of NER HOT 1
- error HOT 1
- ICON execution problems
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ner-lstm.