我在这里用python编写了这段代码。我在json中有一个数据集,我正在尝试使用keras训练该数据集。我能够完美地加载数据,但是在编写了完整的代码以训练我的数据集并运行它之后,它开始给我程序导入错误。我尝试再次使用pip安装tensorflowjs和keras,但每次尝试tensorflowjs时,它都开始给我kerasApplications版本的兼容性错误。我尝试安装每个版本,但仍然给我同样的错误。我如何摆脱这种麻烦?
with T as
(
select
sp.ProfileId
,sp.ProfileHandle
,sp.[Description]
from
[SocialProfile] sp
inner join
Entity e on sp.EntityId = e.EntityId
where
e.EntityStatusId != 3 and e.EntityStatusId != 4
and sp.SocialProfileTypeId in (1, 2, 10)
and (ISNUMERIC(sp.ProfileHandle) = 1)
and IsRemoved = 0
)
update T
set ProfileHandle = NULL
where ProfileHandle = ProfileId
这是错误
import json
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout
import tensorflowjs as tfjs
with open("C:\\Users\\TechProBox\\Desktop\\Model.json") as f:
data = json.load(f)
x1 = np.array(data['attiude.roll'])
y1 = np.array(data['attitude.pitch'])
z1 = np.array(data['attitude.yaw'])
x2 = np.array(data['gravity.x'])
y2 = np.array(data['gravity.y'])
z2 = np.array(data['gravity.z'])
x3 = np.array(data['rotationRate.x'])
y3 = np.array(data['rotationRate.y'])
z3 = np.array(data['rotationRate.z'])
x4 = np.array(data['userAcceleration.x'])
y4 = np.array(data['userAcceleration.y'])
z4 = np.array(data['userAcceleration.z'])
x1_train = x1[:-10000]
y1_train = y1[:-10000]
z1_train = z1[:-10000]
x2_train = x2[:-10000]
y2_train = y2[:-10000]
z2_train = z2[:-10000]
x3_train = x3[:-10000]
y3_train = y3[:-10000]
z3_train = z3[:-10000]
x4_train = x4[:-10000]
y4_train = y4[:-10000]
z4_train = z4[:-10000]
x1_test = x1[:-10000]
y1_test = y1[:-10000]
z1_test = z1[:-10000]
x2_test = x2[:-10000]
y2_test = y2[:-10000]
z2_test = z2[:-10000]
x3_test = x3[:-10000]
y3_test = y3[:-10000]
z3_test = z3[:-10000]
x4_test = x4[:-10000]
y4_test = y4[:-10000]
z4_test = z4[:-10000]
model = Sequential()
model.add(Dense(64, activation='relu', input_dim=6))
model.add(Dropout(0.5))
model.add(Dense(64, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(3, activation='softmax'))
adam = keras.optimizers.Adam(lr=0.0001)
model.compile(loss='categorical_crossentropy',
optimizer=adam,
metrics=['accuracy'])
model.fit(x1_train, y1_train, z1_train, x2_train, y2_train, z2_train,x3_train, y3_train, z3_train,
x4_train, y4_train, z4_train,
epochs=14,
batch_size=128)
score = model.evaluate(x1_test, y2_test, z3_test, x2_test, y2_test, z2_test, x3_test, y3_test, z3_test,
x4_test, y4_test, z4_test, batch_size=128)
print(score)
model.save("Keras-64*2-10epoch")
tfjs.converters.save_keras_model(model,"tfjsv3")
答案 0 :(得分:1)
只需要安装新的原型就可以了
pip install protobuf==3.6.0