所以我目前正在用Python进行我的第一个AI / Keras项目,但是我的NN并没有显着改变预测输出:
import keras, numpy, random
# Creating the Model
input = keras.Input(shape=(8,), name="Input")
dense = keras.layers.Dense(25, activation="sigmoid", name="Middle")(input)
select = keras.layers.Dense(5, activation="sigmoid", name="Select")(dense)
model = keras.models.Model(inputs=input, outputs=select)
def predict(data):
data = numpy.array([data])
data = data / 6 # Normalizing
prediction = model.predict(data)
for x in prediction:
print(x)
for _ in range(30):
data = [random.randint(1, 6) for _ in range(8)]
predict(data)
您可能已经看到,这只是整个代码的简化版本(这就是为什么预测什么也没发生的原因)。我在大型模型中遇到了这个问题,并试图简化它,但即使这样,问题仍然存在。
以下是示例输出:
[0.45357195 0.5101176 0.6066073 0.59616214 0.32346085]
[0.45234042 0.50832504 0.61470693 0.5896992 0.31719455]
[0.4485785 0.51558554 0.60924697 0.6041078 0.32343972]
[0.43296802 0.4978232 0.60654384 0.5980472 0.32416025]
[0.46071726 0.51882887 0.61999756 0.5960711 0.32239592]
[0.4497589 0.51017994 0.6150334 0.5961156 0.328219 ]
[0.44080874 0.5004228 0.6147976 0.5961118 0.3279655 ]
[0.4618538 0.5148883 0.6156607 0.5945767 0.32228172]
[0.44991705 0.51072496 0.6219714 0.5943718 0.3167036 ]
[0.44801232 0.50875366 0.61004543 0.5957838 0.32481167]
[0.4461697 0.5075315 0.61299646 0.59860665 0.3184844 ]
[0.43305746 0.4930857 0.6096221 0.5926977 0.3309392 ]
[0.44183218 0.5020379 0.61970615 0.5955208 0.3254349 ]
[0.44254482 0.49376535 0.6126899 0.583543 0.32847765]
[0.4403061 0.50721973 0.60946244 0.6034762 0.3315672 ]
[0.4384259 0.5032901 0.60851157 0.5973858 0.32403302]
[0.43846375 0.5022315 0.6135255 0.60117215 0.33535388]
[0.4594089 0.5142279 0.62335753 0.5890998 0.31734776]
[0.43596834 0.49416542 0.6176787 0.5868927 0.32736892]
[0.45383313 0.51128554 0.62625104 0.58994234 0.31612635]
[0.4284321 0.4935397 0.6034159 0.596443 0.3285327]
[0.42604104 0.4915861 0.6057334 0.5972011 0.32937437]
[0.44639084 0.5085275 0.6094539 0.5973595 0.31766823]
[0.45737445 0.51187867 0.61704046 0.5949744 0.32312208]
[0.45286173 0.5039543 0.62771565 0.5865321 0.32633784]
[0.44536707 0.49676734 0.6164142 0.58691347 0.334003 ]
[0.45313308 0.5062818 0.62855715 0.5869772 0.3215919 ]
[0.4594305 0.50981486 0.61838317 0.5850767 0.3186839 ]
[0.44705614 0.50470227 0.62320054 0.5908667 0.32202294]
[0.4542963 0.49835688 0.6314806 0.5773467 0.3272368 ]
如您所见,尽管输入始终是随机且不同的,但输出几乎相同。
那是为什么?
〜冈加那州
编辑:为澄清起见:我在遗传算法方法中使用了此模型,并且我需要“输出”来退出各种值!