[go: nahoru, domu]

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

'module' object has no attribute 'core_rnn_cell' #50

Open
qclu opened this issue Aug 7, 2017 · 3 comments
Open

'module' object has no attribute 'core_rnn_cell' #50

qclu opened this issue Aug 7, 2017 · 3 comments

Comments

@qclu
Copy link
qclu commented Aug 7, 2017

Hi,

I have tried sample train with following cmd as listed below, but got error as title descirbes.
Tensorflow version is 0.12.1.
python src/launcher.py --phase=train --data-path=sample/sample.txt --data-base-dir=sample --log-path=log.txt --no-load-model
Detailed log info is listed below.

2017-08-07 17:39:12.301997: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-07 17:39:12.302045: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-07 17:39:12.302056: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-08-07 17:39:12.302065: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-08-07 17:39:12.302073: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
2017-08-07 17:39:15.857019: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 0 with properties:
name: Tesla P40
major: 6 minor: 1 memoryClockRate (GHz) 1.531
pciBusID 0000:02:00.0
Total memory: 22.38GiB
Free memory: 22.22GiB
2017-08-07 17:39:16.239217: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x7bf2770 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-08-07 17:39:16.240932: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 1 with properties:
name: Tesla P40
major: 6 minor: 1 memoryClockRate (GHz) 1.531
pciBusID 0000:03:00.0
Total memory: 22.38GiB
Free memory: 22.22GiB
2017-08-07 17:39:16.626551: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x7bf65c0 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-08-07 17:39:16.628301: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 2 with properties:
name: Tesla P40
major: 6 minor: 1 memoryClockRate (GHz) 1.531
pciBusID 0000:83:00.0
Total memory: 22.38GiB
Free memory: 22.22GiB
2017-08-07 17:39:17.002842: W tensorflow/stream_executor/cuda/cuda_driver.cc:523] A non-primary context 0x7c1ad70 exists before initializing the StreamExecutor. We haven't verified StreamExecutor works with that.
2017-08-07 17:39:17.004574: I tensorflow/core/common_runtime/gpu/gpu_device.cc:940] Found device 3 with properties:
name: Tesla P40
major: 6 minor: 1 memoryClockRate (GHz) 1.531
pciBusID 0000:84:00.0
Total memory: 22.38GiB
Free memory: 22.22GiB
2017-08-07 17:39:17.006291: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 0 and 2
2017-08-07 17:39:17.006319: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 0 and 3
2017-08-07 17:39:17.006346: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 1 and 2
2017-08-07 17:39:17.006362: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 1 and 3
2017-08-07 17:39:17.006398: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 2 and 0
2017-08-07 17:39:17.006412: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 2 and 1
2017-08-07 17:39:17.007788: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 3 and 0
2017-08-07 17:39:17.007814: I tensorflow/core/common_runtime/gpu/gpu_device.cc:832] Peer access not supported between device ordinals 3 and 1
2017-08-07 17:39:17.007880: I tensorflow/core/common_runtime/gpu/gpu_device.cc:961] DMA: 0 1 2 3
2017-08-07 17:39:17.007895: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 0: Y Y N N
2017-08-07 17:39:17.007908: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 1: Y Y N N
2017-08-07 17:39:17.007920: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 2: N N Y Y
2017-08-07 17:39:17.007941: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] 3: N N Y Y
2017-08-07 17:39:17.008000: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla P40, pci bus id: 0000:02:00.0)
2017-08-07 17:39:17.008017: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:1) -> (device: 1, name: Tesla P40, pci bus id: 0000:03:00.0)
2017-08-07 17:39:17.008030: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:2) -> (device: 2, name: Tesla P40, pci bus id: 0000:83:00.0)
2017-08-07 17:39:17.008039: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1030] Creating TensorFlow device (/gpu:3) -> (device: 3, name: Tesla P40, pci bus id: 0000:84:00.0)
2017-08-07 17:39:17,797 root INFO loading data
2017-08-07 17:39:17,806 root INFO phase: train
2017-08-07 17:39:17,806 root INFO model_dir: train
2017-08-07 17:39:17,807 root INFO load_model: False
2017-08-07 17:39:17,807 root INFO output_dir: results
2017-08-07 17:39:17,807 root INFO steps_per_checkpoint: 500
2017-08-07 17:39:17,807 root INFO batch_size: 64
2017-08-07 17:39:17,807 root INFO num_epoch: 1000
2017-08-07 17:39:17,808 root INFO learning_rate: 1
2017-08-07 17:39:17,808 root INFO reg_val: 0
2017-08-07 17:39:17,808 root INFO max_gradient_norm: 5.000000
2017-08-07 17:39:17,808 root INFO clip_gradients: True
2017-08-07 17:39:17,808 root INFO valid_target_length inf
2017-08-07 17:39:17,808 root INFO target_vocab_size: 39
2017-08-07 17:39:17,809 root INFO target_embedding_size: 10.000000
2017-08-07 17:39:17,809 root INFO attn_num_hidden: 128
2017-08-07 17:39:17,809 root INFO attn_num_layers: 2
2017-08-07 17:39:17,809 root INFO visualize: True
2017-08-07 17:39:17,809 root INFO buckets
2017-08-07 17:39:17,809 root INFO [(16, 11), (27, 17), (35, 19), (64, 22), (80, 32)]
input_tensor dim: (?, 1, 32, ?)
CNN outdim before squeeze: (?, 1, ?, 512)
CNN outdim: (?, ?, 512)
Traceback (most recent call last):
File "src/launcher.py", line 146, in
main(sys.argv[1:], exp_config.ExpConfig)
File "src/launcher.py", line 142, in main
session = sess)
File "/home/xxx/ocrbench/Attention-OCR/src/model/model.py", line 151, in init
use_gru = use_gru)
File "/home/xxx/ocrbench/Attention-OCR/src/model/seq2seq_model.py", line 87, in init
single_cell = tf.contrib.rnn.core_rnn_cell.BasicLSTMCell(attn_num_hidden, forget_bias=0.0, state_is_tuple=False)
AttributeError: 'module' object has no attribute 'core_rnn_cell'

@Fred-Erik
Copy link

Make sure you use TensorFlow 1.0.1.

@shoaibahmed
Copy link

If you are using TF 1.2 or 1.3, you can rename the tf.contrib.rnn.core_rnn_cell to tf.contrib.rnn so tf.contrib.rnn.core_rnn_cell.BasicLSTMCell will become tf.contrib.rnn.BasicLSTMCell and tf.contrib.rnn.MultiRNNCell, tf.contrib.rnn.GRUCell will be changed in the same way. Hope it helps.

@anandvijay619
Copy link

Also you will face an issue of Kernel and Bias, so use this code after what Shoaib Suggested

OLD_CHECKPOINT_FILE = "translate.ckpt-60000"
NEW_CHECKPOINT_FILE = "translate2.ckpt-60000"

import tensorflow as tf
vars_to_rename = {
"weights": "kernel",
"biases": "bias",

}

var_names = ["weights", "biases"]
new_checkpoint_vars = {}
reader = tf.train.NewCheckpointReader(OLD_CHECKPOINT_FILE)
for old_name in reader.get_variable_to_shape_map():
print(old_name)
for name in var_names:
if name in old_name:
print(vars_to_rename[name])
new_name = old_name.replace( name ,vars_to_rename[name])
break
else:
new_name = old_name
new_checkpoint_vars[new_name] = tf.Variable(reader.get_tensor(old_name))
print(new_name)
init = tf.global_variables_initializer()
saver = tf.train.Saver(new_checkpoint_vars)

with tf.Session() as sess:
sess.run(init)
saver.save(sess, NEW_CHECKPOINT_FILE)

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

4 participants