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

Check failed #1

Closed
ningshixian opened this issue Apr 3, 2019 · 5 comments
Closed

Check failed #1

ningshixian opened this issue Apr 3, 2019 · 5 comments

Comments

@ningshixian
Copy link

hello,
I modified a part of the code,

bert_outputs = self.bert(inputs=bert_inputs, signature="tokens", as_dict=True)['sequence_output']
return (max_seq_length, self.output_size)

but when i run the code, i have the following problem!
"F tensorflow/core/framework/tensor_shape.cc:44] Check failed: NDIMS == dims() (2 vs. 4)Asking for tensor of 2 dimensions from a tensor of 4 dimensions
Aborted (core dumped)"

may I know what is the reason?

@ningshixian
Copy link
Author

hello,
I modified a part of the code,

bert_outputs = self.bert(inputs=bert_inputs, signature="tokens", as_dict=True)['sequence_output']
return (max_seq_length, self.output_size)

but when i run the code, i have the following problem!
"F tensorflow/core/framework/tensor_shape.cc:44] Check failed: NDIMS == dims() (2 vs. 4)Asking for tensor of 2 dimensions from a tensor of 4 dimensions
Aborted (core dumped)"

may I know what is the reason?

i hava found the answer from google-research/bert#146

@ningshixian
Copy link
Author

but another question is raise!
Once i execute the following code, i will get an error:
ValueError: An operation has None for gradient. Please make sure that all of your ops have a gradient defined
'''
trainable_vars = self.bert.variables
trainable_vars = [var for var in trainable_vars if not "/cls/" in var.name]
trainable_vars = trainable_vars[-self.n_fine_tune_layers :]
for var in trainable_vars:
self.trainable_weights.append(var)
'''

@jacobzweig
Copy link
Collaborator

Hey @ningshixian you'll need to remove the pooling layers from trainable weights, e.g.

trainable_vars = [var for var in trainable_vars if not "/cls/" in var.name and not "/pooler/" in var.name]

@changquanyou
Copy link

2019-04-10 16:33:34.752272: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1053] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 11481 MB memory) -> physical GPU (device: 0, name: Tesla K40m, pci bus id: 0000:82:00.0, compute capability: 3.5)
segment_ids name: "segment_ids_1:0"
dtype: DT_INT32
tensor_shape {
dim {
size: -1
}
dim {
size: 256
}


1 import tensorflow as tf
}

segment_ids_1:0
==> Tensor("segment_ids_1:0", shape=(?, 256), dtype=int32)
input_ids name: "input_ids_1:0"
dtype: DT_INT32
tensor_shape {
dim {
size: -1
}
dim {
size: 256
}
}

input_ids_1:0
==> Tensor("input_ids_1:0", shape=(?, 256), dtype=int32)
input_mask name: "input_mask_1:0"
dtype: DT_INT32
tensor_shape {
dim {
size: -1
}
dim {
size: 256
}
}

input_mask_1:0
==> Tensor("input_mask_1:0", shape=(?, 256), dtype=int32)
label_ids name: "label_ids_1:0"
dtype: DT_INT32
tensor_shape {
dim {
size: -1
}
dim {
size: 256
}
}

label_ids_1:0
==> Tensor("label_ids_1:0", shape=(?, 256), dtype=int32)
probabilities name: "loss/Softmax:0"
dtype: DT_FLOAT
tensor_shape {
dim {
size: -1
}
dim {
size: 3
}
}

(3613, 2)
2019-04-10 16:33:37.213336: F tensorflow/core/framework/tensor_shape.cc:44] Check failed: NDIMS == dims() (2 vs. 4)Asking for tensor of 2 dimensions from a tensor of 4 dimensions
Aborted (core dumped)

above is the error messsage,I trained the classify model by cpu,I also predict it locally,It is normal; But I run in the server by Gpu, it is the error

@ningshixian
Copy link
Author

Hey @ningshixian you'll need to remove the pooling layers from trainable weights, e.g.

trainable_vars = [var for var in trainable_vars if not "/cls/" in var.name and not "/pooler/" in var.name]

thanks...but it does not work

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

3 participants