我正在尝试用教我的第一个人工智能
google colab
和
tensorflow
.
.predict
方法工作我不清楚。
我有以下内容
dataset
实例
分类
|
输入1
|
输入2
|
1.
|
0.1
|
0.22
|
1.
|
0.333
|
0.4
|
4.
|
0.55
|
0.6
|
预期类为
1
或
4
。数据集包含每个的50%。
我的代码是:
-
切片数据:
features = df.iloc[1:, 1:]
labels = df.iloc[1:, 0]
-
构建模型:
model = tf.keras.Sequential([
tf.keras.layers.Dense(256, activation='tanh', input_shape=(82,)),
tf.keras.layers.Dense(2, input_shape=(256,), activation='tanh'),
tf.keras.layers.Dense(1, activation='softmax')
])
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
-
列车型号:
model.fit(x=features, y=labels, shuffle=True, epochs=1)
后果
的结果
预测
方法总是
[[1.]]
.
但我认为这应该是smth式的:
[1: 0.4][2: 0.88]
哪里
1 and 4
是
classifications
和
0.4 and 0.88
是
probability