WinError193 %1 不是有效的 Win32 应用程序

对于一个AI项目,我需要使用tensorflow结合anaconda和spyder。然而,自去年以来,我在启动Anaconda时遇到了问题。我一直未能解决这个错误,因为我之前没有使用Anaconda的需求,但现在我必须解决这个问题。

我首先在anaconda提示符中使用conda create -n tf2gpu tensorflow-gpu jupyter matplotlib pillow spyder创建了一个环境,然后使用conda activate tf2-gpu激活该环境,并通过终端使用spyder打开spyder。(注意:我有一块合适的GPU)。

这是我尝试运行的代码:

# -*- coding: utf-8 -*-from tensorflow.keras.datasets import mnist #datasetsfrom tensorflow.keras.models import Sequentialfrom tensorflow.keras.layers import Dense,Activationfrom tensorflow.keras.optimizers import SGDfrom tensorflow.keras.utils import to_categoricalimport matplotlib.pyplot as pltimport numpy as np(tr_imgs,tr_labs),(tst_imgs,tst_labs)=mnist.load_data()#loading dataprint("Training references :",tr_imgs.shape,tr_labs.shape,tr_imgs.dtype,tr_labs.dtype)#60,000 images of 28 by 28 size with 60,000 labels, both integer 8 bits signedprint("Testing references :",tst_imgs.shape,tst_labs.shape,tst_imgs.dtype,tst_labs.dtype)#10,000 images of 28 by 28 size with 10,000 labels, both integer 8 bits signedprint("__________________\n")tr_vec=np.reshape(tr_imgs,(len(tr_imgs),-1)).astype("float32")/255.0tst_vec=np.reshape(tst_imgs,(len(tst_imgs),-1)).astype("float32")/255.0cat_trlabs=to_categorical(tr_labs)cat_tstlabs=to_categorical(tst_labs)model=Sequential([Dense(251,input_shape=(784,)),Activation("sigmoid"),Dense(128),Activation("sigmoid"),Dense(10),Activation("sigmoid")])sgd=SGD(learning_rate=0.15,momentum=0.9,decay=0.0,nesterov=False)model.compile(loss="mse",optimizer=sgd,metrics=["accuracy"])history=model.fit(tr_vec,cat_trlabs,epochs=100,batch_size=200,validation_split=0.1,verbose=2)model_history=history.historyprediction=model.predict(tst_vec)model_loss=model_history["loss"]model_acc=model_history["accuracy"]model_valloss=model_history["val_loss"]model_valaccuracy=model_history["val_accuracy"]epochs=range(len(model_acc))plt.plot(epochs,model_valaccuracy,label="Val_accuracy")plt.plot(epochs,model_acc,label="Accuracy")plt.show()

然后出现了这个错误:[WinError193]%1 不是有效的 Win32 应用程序

我使用的是64位Windows 10,anaconda也是64位的。

提前感谢,我已经卡在这里两天了。

编辑1:似乎是tensorflow.keras库的问题


回答:

我可能有一个解决方案。我之前也遇到过同样的问题…然后我发现这里涉及到两个python环境。我只需要删除其中一个(与Anaconda不相关的那个)。希望这个回答能帮到你。祝你的项目好运,AI很有趣 🙂

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注