py2neo出现'Graph' object has no attribute 'find_one'

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_32795135/article/details/81198978

原因:py2neo的v2和v3版本有两个很简便的查找节点的函数find_one()和find(),但是在v4版本里面不见了。

现在查找节点的操作是这样子的:

from py2neo import Graph, NodeMatcher
graph = Graph()
matcher = NodeMatcher(graph)
matcher.match("Person", name="Keanu Reeves").first()
(_224:Person {born:1964,name:"Keanu Reeves"})

官方文档在这里:https://py2neo.org/v4/index.html

展开阅读全文

'Datasets' object has no attribute 'train_step'

07-19

import tensorflow as tfnfrom tensorflow.examples.tutorials.mnist import input_datanimport mnist_forwardnimport osnnBATAH_SIZE = 200nLEARNING_RATE_BASE = 0.1nLEARNING_RATE_DECAY = 0.99nREGULARIZER = 0.0001nSTEPS = 50000nMOVING_AVERAGE_DECAY = 0.99nMODEL_SAVE_PATH = "./model/"nMODEL_NAME = "mnist_model"nndef backward(mnist):nn x = tf.placeholder(tf.float32, [None, mnist_forward.INPUT_NODE])n y_ = tf.placeholder(tf.float32, [None, mnist_forward.OUTPUT_NODE])n y = mnist_forward.forward(x, REGULARIZER)n global_step = tf.Variable(0, trainable=False)nn ce = tf.nn.sparse_softmax_cross_entropy_with_logits(logits=y, labels=tf.arg_max(y_, 1))n cem = tf.reduce_mean(ce)n loss = cem + tf.add_n(tf.get_collection('losses'))nn learning_rate = tf.train.exponential_decay(LEARNING_RATE_BASE, global_step, mnist.train.num_examples / BATAH_SIZE,n LEARNING_RATE_DECAY, staircase=True)nn train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(loss, global_step=global_step)nn ema = tf.train.ExponentialMovingAverage(MOVING_AVERAGE_DECAY, global_step)n ema_op = ema.apply(tf.trainable_variables())n with tf.control_dependencies([train_step, ema_op]):n train_op = tf.no_op(name='train')nn saver = tf.train.Saver()nn with tf.Session() as sess:n init_op = tf.global_variables_initializer()n sess.run(init_op)nn for i in range(STEPS):n xs, ys = mnist.train_step.next_batch(BATAH_SIZE)n _, loss_value, step = sess.run([train_op, loss, global_step], feed_dict=x: xs, y_: ys)n if i % 1000 == 0:n print("After %d training step(s), loss on training batch is %g." % (step, loss_value))n saver.save(sess, os.path.join(MODEL_SAVE_PATH, MODEL_NAME), global_step=global_step)nndef main():n mnist = input_data.read_data_sets("./data/", one_hot=True)n backward(mnist)nnif __name__ == '__main__':n main()nn运行程序后报错:nn File "C:/Users/98382/PycharmProjects/minst/mnist_backward.py", line 54, in n main()n File "C:/Users/98382/PycharmProjects/minst/mnist_backward.py", line 51, in mainn backward(mnist)n File "C:/Users/98382/PycharmProjects/minst/mnist_backward.py", line 43, in backwardn xs, ys = mnist.train_step.next_batch(BATAH_SIZE)nAttributeError: 'Datasets' object has no attribute 'train_step'nn 问答

AttributeError: 'Settings' object has no attribute 'DATABASE_ENGINE'

09-10

环境:Centos、python2.7.7 Django:1.7 south:0.7rnsettings.py 里的部分配置:rnINSTALLED_APPS = (rn 'south',rn 'django.contrib.admin',rn 'django.contrib.auth',rn 'django.contrib.contenttypes',rn 'django.contrib.sessions',rn 'django.contrib.messages',rn 'django.contrib.staticfiles',rn 'polls'rn)rn其中south:为同步模型到数据库的第三方模块,用来取代syncdb。rnpolls:为自己的投票应用。rn目前我执行python manage.py syncdb或者python manage.py startmigration polls --initial均报错,报错信息如下:rnTraceback (most recent call last):rn File "manage.py", line 10, in rn execute_from_command_line(sys.argv)rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 385, in execute_from_command_linern utility.execute()rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 377, in executern self.fetch_command(subcommand).run_from_argv(self.argv)rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 238, in fetch_commandrn klass = load_command_class(app_name, subcommand)rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/core/management/__init__.py", line 41, in load_command_classrn module = import_module('%s.management.commands.%s' % (app_name, name))rn File "/usr/local/python2.7/lib/python2.7/importlib/__init__.py", line 37, in import_modulern __import__(name)rn File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.6-py2.7.egg/south/management/commands/syncdb.py", line 5, in rn from south import migrationrn File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.6-py2.7.egg/south/migration.py", line 17, in rn from south.db import dbrn File "/usr/local/python2.7/lib/python2.7/site-packages/South-0.6-py2.7.egg/south/db/__init__.py", line 9, in rn module_name = '.'.join(['south.db', settings.DATABASE_ENGINE])rn File "/usr/local/python2.7/lib/python2.7/site-packages/Django-1.7-py2.7.egg/django/conf/__init__.py", line 47, in __getattr__rn return getattr(self._wrapped, name)rn[color=#FF0000]AttributeError: 'Settings' object has no attribute 'DATABASE_ENGINE'[/color] 论坛

没有更多推荐了,返回首页