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

AttributeError: 'dict_values' object has no attribute 'op' #53

Open
maoxin7676 opened this issue Jul 13, 2018 · 1 comment
Open

AttributeError: 'dict_values' object has no attribute 'op' #53

maoxin7676 opened this issue Jul 13, 2018 · 1 comment

Comments

@maoxin7676
Copy link

maoxin7676 commented Jul 13, 2018

When i run “d_grads = d_opt.compute_gradients(self.d_losses[-1],
var_list=self.d_vars)” in model.py
it occurs this problem “ AttributeError: 'dict_values' object has no attribute 'op' ”
How to solve this problem?
Best regards!

@maoxin7676
Copy link
Author

maoxin7676 commented Jul 15, 2018

def get_vars(self):
t_vars = tf.trainable_variables()
self.d_vars_dict = {}
self.g_vars_dict = {}
for var in t_vars:
if var.name.startswith('d_'):
self.d_vars_dict[var.name] = var
if var.name.startswith('g_'):
self.g_vars_dict[var.name] = var
self.d_vars = self.d_vars_dict.values()
self.g_vars = self.g_vars_dict.values()
change to this:
def get_vars(self):
t_vars = tf.trainable_variables()
self.d_vars = [var for var in t_vars if 'd_' in var.name]
self.g_vars = [var for var in t_vars if 'g_' in var.name]

this way can solve the problem(model.py)

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

1 participant