小编Tor*_*ikh的帖子

SyntaxError:解析时意外的EOF

我在运行这部分代码时遇到错误.尝试了一些现有的解决方案,但都没有帮助

elec_and_weather = pd.read_csv(r'C:\HOUR.csv', parse_dates=True,index_col=0)
# Add historic DEMAND to each X vector
 for i in range(0,24):
    elec_and_weather[i] = np.zeros(len(elec_and_weather['DEMAND']))
    elec_and_weather[i][elec_and_weather.index.hour==i] = 1
# Set number of hours prediction is in advance
n_hours_advance = 24

# Set number of historic hours used
n_hours_window = 24

for k in range(n_hours_advance,n_hours_advance+n_hours_window):
    elec_and_weather['DEMAND_t-%i'% k] = np.zeros(len(elec_and_weather['DEMAND']))'
Run Code Online (Sandbox Code Playgroud)

我总是得到这个错误

for i in range(0,24):
File "<ipython-input-29-db3022a769d1>", line 1
for i in range(0,24):
                     ^
SyntaxError: unexpected EOF while parsing

File "<ipython-input-25-df0a44131c36>", line 1
    for k in range(n_hours_advance,n_hours_advance+n_hours_window): …
Run Code Online (Sandbox Code Playgroud)

python lint eof python-3.x python-3.6

21
推荐指数
4
解决办法
27万
查看次数

无法使用训练好的Tensorflow模型

我是深度学习和Tensorflow的新手。我重新训练了一个预训练过的tensorflow inceptionv3模型为save_model.pb,以识别不同类型的图像,但是当我尝试将fie与以下代码一起使用时。

with tf.Session() as sess:
    with tf.gfile.FastGFile("tensorflow/trained/saved_model.pb",'rb') as  f:
        graph_def = tf.GraphDef()
        tf.Graph.as_graph_def()
        graph_def.ParseFromString(f.read())
        g_in=tf.import_graph_def(graph_def)
        LOGDIR='/log'
        train_writer=tf.summary.FileWriter(LOGDIR)
        train_writer.add_graph(sess.graph)
Run Code Online (Sandbox Code Playgroud)

它给了我这个错误-

 File "testing.py", line 7, in <module>
graph_def.ParseFromString(f.read())
google.protobuf.message.DecodeError: Error parsing message
Run Code Online (Sandbox Code Playgroud)

我尝试了很多可以找到这个问题的解决方案,并且使用graph_def.ParseFromString(f.read())函数的tensorflow / python / tools中的模块给了我同样的错误。请告诉我如何解决此问题或告诉我可以避免ParseFromString(f.read())函数的方式。任何帮助,将不胜感激。谢谢!

image-processing python-3.x deep-learning tensorflow tensorboard

6
推荐指数
3
解决办法
4308
查看次数