相关疑难解决方法(0)

UnboundLocalError:分配前引用了局部变量“batch_outputs”

我正在使用 Keras 编写机器学习代码来对前列腺癌的严重程度进行分级。运行后出现如下错误:

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-14-0e08590512ec> in <module>
      8     for file in column:
      9         data = generate_tiles(file)
---> 10         prediction = model.predict(data)
     11         max_score = prediction.max()
     12 

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in _method_wrapper(self, *args, **kwargs)
     86       raise ValueError('{} is not supported in multi-worker mode.'.format(
     87           method.__name__))
---> 88     return method(self, *args, **kwargs)
     89 
     90   return tf_decorator.make_decorator(

/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/engine/training.py in predict(self, x, batch_size, verbose, steps, callbacks, max_queue_size, workers, use_multiprocessing)
   1283             callbacks.on_predict_batch_end(step, {'outputs': batch_outputs})
   1284       callbacks.on_predict_end()
-> 1285     all_outputs = nest.map_structure_up_to(batch_outputs, …
Run Code Online (Sandbox Code Playgroud)

python machine-learning keras

10
推荐指数
1
解决办法
4495
查看次数

标签 统计

keras ×1

machine-learning ×1

python ×1