我正在使用web.py创建一个简单的Web应用程序。 目前,我陷入了要在我的类中创建ResNet50实例的问题。 我正在使用tensorflow作为后端(版本1.10.0)的keras版本2.2.2。 Python 3.6版(由Anaconda3提供)。 我正在运行Slackware 14.2 x86_64。
抛出该异常的代码部分:
class Nets:
@classmethod
def Resnet_dog_detector_CNN(cls):
with graph.as_default():
cls.ResNet50_model = ResNet50()
Nets类是全局类。如您所见,我什至没有尝试使用模型->不是试图加载一些预定义的权重。
完整的错误是:
2018-09-17 22:01:35.736896: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX
2018-09-17 22:01:35.740913: I tensorflow/core/common_runtime/process_util.cc:69] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance.
Traceback (most recent call last):
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/web/application.py", line 257, in process
return self.handle()
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/web/application.py", line 248, in handle
return self._delegate(fn, self.fvars, args)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/web/application.py", line 488, in _delegate
return handle_class(cls)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/web/application.py", line 466, in handle_class
return tocall(*args)
File "/home/eindemwort/projects/dog-app_webapp/dog-app.py", line 97, in GET
Nets.Resnet_dog_detector_CNN()
File "/home/eindemwort/projects/dog-app_webapp/dog-app.py", line 34, in Resnet_dog_detector_CNN
cls.ResNet50_model = ResNet50()
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/keras_applications/resnet50.py", line 228, in ResNet50
name='conv1')(x)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py", line 431, in __call__
self.build(unpack_singleton(input_shapes))
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/keras/layers/convolutional.py", line 144, in build
constraint=self.bias_constraint)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/keras/legacy/interfaces.py", line 91, in wrapper
return func(*args, **kwargs)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/keras/engine/base_layer.py", line 252, in add_weight
constraint=constraint)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 400, in variable
v = tf.Variable(value, dtype=tf.as_dtype(dtype), name=name)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 259, in __init__
constraint=constraint)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/tensorflow/python/ops/variables.py", line 423, in _init_from_args
ops.add_to_collections(collections, self)
File "/home/eindemwort/anaconda3/lib/python3.6/contextlib.py", line 88, in __exit__
next(self.gen)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 5118, in init_scope
yield
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 4210, in __exit__
self._graph._pop_control_dependencies_controller(self)
File "/home/eindemwort/anaconda3/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 4231, in _pop_control_dependencies_controller
assert self._control_dependencies_stack[-1] is controller
AssertionError
127.0.0.1:50260 - - [17/Sep/2018 22:01:38] "HTTP/1.1 GET /" - 500 Internal Server Error
127.0.0.1:50258 - - [17/Sep/2018 22:01:45] "HTTP/1.1 HEAD /" - 200 OK
我已经用谷歌搜索了,但是我发现的解决方案需要直接处理张量流。就我而言,我将其用作Keras的后端。
另一件事,如果我从webpy中运行该代码(即直接在python中),则不会收到该错误(仍然是tensorflow作为keras的后端)。
外面有没有想给我提示的专家? 预先感谢。