python - 当我尝试运行此文件时出现错误。tf 学习问题?
问题描述
我发现了一些我想从 GitHub 运行的东西,但是当我这样做时,我得到了这个错误。
Traceback (most recent call last):
File "C:\Users\Samuel\Desktop\GTA\pygta5-master\pygta5-master\Tutorial Codes\Part 14-15\train_model.py", line 4, in <module>
from alexnet import alexnet
File "C:\Users\Samuel\Desktop\GTA\pygta5-master\pygta5-master\Tutorial Codes\Part 14-15\alexnet.py", line 11, in <module>
import tflearn
File "C:\Users\Samuel\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\__init__.py", line 4, in <module>
from . import config
File "C:\Users\Samuel\AppData\Local\Programs\Python\Python36\lib\site-packages\tflearn\config.py", line 3, in <module>
import tensorflow as tf
File "C:\Users\Samuel\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\__init__.py", line 22, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Samuel\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Users\Samuel\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow\core\framework\graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Users\Samuel\AppData\Local\Programs\Python\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified procedure could not be found.
这是代码
# train_model.py
import numpy as np
from alexnet import alexnet
WIDTH = 160
HEIGHT = 120
LR = 1e-3
EPOCHS = 10
MODEL_NAME = 'pygta5-car-fast-{}-{}-{}-epochs-300K-data.model'.format(LR, 'alexnetv2',EPOCHS)
model = alexnet(WIDTH, HEIGHT, LR)
hm_data = 22
for i in range(EPOCHS):
for i in range(1,hm_data+1):
train_data = np.load('training_data-{}-balanced.npy'.format(i))
train = train_data[:-100]
test = train_data[-100:]
X = np.array([i[0] for i in train]).reshape(-1,WIDTH,HEIGHT,1)
Y = [i[1] for i in train]
test_x = np.array([i[0] for i in test]).reshape(-1,WIDTH,HEIGHT,1)
test_y = [i[1] for i in test]
model.fit({'input': X}, {'targets': Y}, n_epoch=1, validation_set=({'input': test_x}, {'targets': test_y}),
snapshot_step=500, show_metric=True, run_id=MODEL_NAME)
model.save(MODEL_NAME)
# tensorboard --logdir=foo:C:/path/to/log
看起来它试图访问 alexnet.py 这是
# alexnet.py
""" AlexNet.
References:
- Alex Krizhevsky, Ilya Sutskever & Geoffrey E. Hinton. ImageNet
Classification with Deep Convolutional Neural Networks. NIPS, 2012.
Links:
- [AlexNet Paper](http://papers.nips.cc/paper/4824-imagenet-classification-with-deep-convolutional-neural-networks.pdf)
"""
import tflearn
from tflearn.layers.conv import conv_2d, max_pool_2d
from tflearn.layers.core import input_data, dropout, fully_connected
from tflearn.layers.estimator import regression
from tflearn.layers.normalization import local_response_normalization
def alexnet(width, height, lr):
network = input_data(shape=[None, width, height, 1], name='input')
network = conv_2d(network, 96, 11, strides=4, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 256, 5, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 384, 3, activation='relu')
network = conv_2d(network, 256, 3, activation='relu')
network = max_pool_2d(network, 3, strides=2)
network = local_response_normalization(network)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 4096, activation='tanh')
network = dropout(network, 0.5)
network = fully_connected(network, 3, activation='softmax')
network = regression(network, optimizer='momentum',
loss='categorical_crossentropy',
learning_rate=lr, name='targets')
model = tflearn.DNN(network, checkpoint_path='model_alexnet',
max_checkpoints=1, tensorboard_verbose=0, tensorboard_dir='log')
return model
环顾四周后,我尝试了很多东西,然后我厌倦了在 python cmd 上导入 tflearn,当我运行命令 import tflearn 时它不会导入。那么这是一个 Tflearn 问题吗?
我在 python 3.6 上,这里安装了其他所有东西
absl-py 0.5.0
astor 0.7.1
gast 0.2.0
grpcio 1.15.0
h5py 2.8.0
Keras-Applications 1.0.6
Keras-Preprocessing 1.0.5
Markdown 3.0.1
numpy 1.15.2
opencv-python 3.4.3.18
pandas 0.23.4
Pillow 5.3.0
pip 18.0
protobuf 3.6.1
pypiwin32 223
python-dateutil 2.7.3
pytz 2018.5
pywin32 224
setuptools 28.8.0
six 1.11.0
tensorboard 1.11.0
tensorflow 1.11.0
tensorflow-gpu 1.11.0
termcolor 1.1.0
tflearn 0.3.2
virtualenv 16.0.0
Werkzeug 0.14.1
wheel 0.32.0
解决方案
推荐阅读
- javascript - Firestore 事务可以批量处理吗?
- python-3.x - 如何使用 read_csv 在 Pandas 中查看 NaN 值
- typescript - 检查接口是否有必填字段
- java - 弹簧引导配置。集合自动装配 - 成功自动装配后获得意外值
- processing - 处理 FFT 背景噪声?
- python - XML解析python嵌套
- bash - 如何在 Bash 中将字符串转换为整数?
- android - 视图层次结构中缺少 PlatformView
- gcc - NASM 自动转义在 .data 中初始化的 shellcode
- java - 通过在运行时给出文件名并写入文件(如果存在)来检查文件是否存在于特定目录中 Java