【问题标题】:Machine learning odd/even prediction doesn't work (50% success)机器学习奇数/偶数预测不起作用(50% 成功)
【发布时间】:2019-05-09 08:03:32
【问题描述】:

我对机器学习很陌生。我试图创建一个模型来预测数字是否是偶数。

我使用了这个代码https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/ 我根据自己的需要进行了更改。

问题是大约 50% 的成功率等于随机。

你知道怎么做才能让它发挥作用吗?

from keras.models import Sequential
from keras.layers import Dense
import numpy
# fix random seed for reproducibility
seed = 7
numpy.random.seed(seed)

X = list(range(1000))
Y = [1,0]*500
# create model
model = Sequential()
model.add(Dense(12, input_dim=1, init='uniform', activation='relu'))
model.add(Dense(8, init='uniform', activation='relu'))
model.add(Dense(1, init='uniform', activation='sigmoid'))
# Compile model
model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
# Fit the model
model.fit(X, Y, epochs=150, batch_size=10,  verbose=2)
# calculate predictions
predictions = model.predict(X)
# round predictions
rounded = [round(x[0])for x in predictions]
print(rounded)


>>> [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 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.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]

【问题讨论】:

  • 对于神经网络来说似乎是一件奇怪的事情:/而且我认为您的代码并不是那么正确。您正在构建的模型需要 12 个输入,如果只有一个数字,这些输入是什么?尝试以下操作:MNIST Tensorflow 由于 Keras 是基于 Tensorflow 构建的,这应该是可能的。
  • 你可以尝试一个简单的特征转换:x -> (-1)^x^我的意思是-1到x的幂。
  • 非常好的问题,任何在 Ai 领域工作的人都应该解决和理解。

标签: python tensorflow machine-learning keras


【解决方案1】:

此处是如何在keras中创建模型以在Python 3中对奇数/偶数进行分类。

它只在第一个隐藏层使用 1 个神经元,有 32 个输入。输出层只有 2 个用于 one-hot 编码 0 和 1 的神经元。

from keras.models import Sequential
from keras.layers import Dense
from keras.utils import to_categorical


# Helper function to convert a number 
# to its fixed width binary representation
def conv(x):
  a = format(x, '032b')
  l = list(str(a))
  l = np.array(list(map(int, l)))
  return l

# input data
data = [conv(i) for i in range(100000)]
X = np.array(data)


Y= list() # empty list of results
for v in range(100000):
  Y.append( to_categorical(v%2, 2) )

Y = np.array(Y) # we need np.array


# Sequential is a fully connected network
model = Sequential()

# 32 inputs and 1 neuron in the first layer (hidden layer)
model.add(Dense(1, input_dim=32, activation='relu'))

# 2 output layer 
model.add(Dense(2, activation='sigmoid'))


model.compile(loss='binary_crossentropy', 
              optimizer='adam', 
              metrics=['accuracy'])

# epochs is the number of times to retrain over the same data set
# batch_size is how may elements to process in parallel at one go
model.fit(X, Y, epochs=5, batch_size=100, verbose=1)
weights, biases = model.layers[0].get_weights()
print("weights",weights.size, weights, "biases", biases)
model.summary()

Epoch 1/5
100000/100000 [==============================] - 3s 26us/step - loss: 0.6111 - acc: 0.6668
Epoch 2/5
100000/100000 [==============================] - 1s 13us/step - loss: 0.2276 - acc: 1.0000
Epoch 3/5
100000/100000 [==============================] - 1s 13us/step - loss: 0.0882 - acc: 1.0000
Epoch 4/5
100000/100000 [==============================] - 1s 13us/step - loss: 0.0437 - acc: 1.0000
Epoch 5/5
100000/100000 [==============================] - 1s 13us/step - loss: 0.0246 - acc: 1.0000
weights 32 [[-4.07479703e-01]
 [ 2.29798079e-01]
 [ 4.12091196e-01]
 [-1.86401993e-01]
 [ 3.70162904e-01]
 [ 1.34553611e-02]
 [ 2.01252878e-01]
 [-1.00370705e-01]
 [-1.41752958e-01]
 [ 7.27931559e-02]
 [ 2.55639553e-01]
 [ 1.90407157e-01]
 [-2.42316410e-01]
 [ 2.43226111e-01]
 [ 2.22285628e-01]
 [-7.04377817e-05]
 [ 2.20522008e-04]
 [-1.48785894e-05]
 [-1.15533156e-04]
 [ 1.16850446e-04]
 [ 6.37861085e-05]
 [-9.74628711e-06]
 [ 3.84256418e-05]
 [-6.19597813e-06]
 [-7.05791535e-05]
 [-4.78575275e-05]
 [-3.07796836e-05]
 [ 3.26417139e-05]
 [-1.51580054e-04]
 [ 1.27965177e-05]
 [ 1.48101550e-04]
 [ 3.18456793e+00]] biases [-0.00016785]
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
dense_49 (Dense)             (None, 1)                 33        
_________________________________________________________________
dense_50 (Dense)             (None, 2)                 4         
=================================================================
Total params: 37
Trainable params: 37
Non-trainable params: 0

以下是预测:

print(X[0:1])
scores = model.predict(X[0:1])
print(scores)
print(np.argmax(scores))

print(X[1:2])
scores = model.predict(X[1:2])
print(scores)
print(np.argmax(scores))

[[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0]]
[[0.9687797  0.03584918]]
0
[[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1]]
[[0.00130448 0.9949934 ]]
1

【讨论】:

    【解决方案2】:

    我认为阅读perceptron XOR-problem 以了解单个感知器的工作原理以及它的局限性是一个好主意。

    预测一个数是否为偶数是一个二元分类问题,具有一维输入;在分类问题中,训练神经网络以通过边界分离类别。考虑这个问题的一种方法是通过将输入数添加到添加的维度(例如,映射 7 到 [7, 7])将其一维输入映射到二维输入,并查看散点图中偶数和奇数向量的样子。

    如果你在 Jupyter notebook 中运行以下代码

    %matplotlib inline
    import matplotlib.pyplot as plt
    
    X = list(range(-20, 20))
    evens = [x for x in X if x % 2 == 0]
    odds = [x for x in X if x % 2 != 0]
    data = (evens, odds)
    colors = ("green", "blue")
    groups = ("Even", "Odd") 
    
    fig = plt.figure()
    ax = fig.add_subplot(1, 1, 1)
    for data, color, group in zip(data, colors, groups):
        x = data
        ax.scatter(x, x, alpha=0.8, c=color, edgecolors='none', s=30, label=group)
    plt.title('Even/Odd numbers')
    plt.legend(loc=2)
    plt.show()
    
    data = (evens, odds)
    fig2 = plt.figure()
    ax = fig2.add_subplot(1, 1, 1)
    for data, color, group in zip(data, colors, groups):
        x = data
        y = [abs(i) if i%2==0 else -abs(i) for i in data]
        ax.scatter(x, y, alpha=0.8, c=color, edgecolors='none', s=30, label=group)
    plt.title('Even/Odd numbers (Separatable)')
    plt.legend(loc=2)
    plt.show()
    

    您将看到类似于下图的内容:

    您可以在第一个图中看到,实际上不可能在偶数和奇数向量之间建立边界,但是如果将第二维数映射到其等效的负数,则在两个类(偶数和奇数)之间绘制边界数字向量)很容易。因此,如果您将输入数据转换为二维并基于偶数或奇数来否定第二维值,那么神经网络可以学习如何分离偶数和奇数向量类。

    您可以尝试以下代码,您将看到网络将学习并收敛到几乎 100% 的准确度。

    import numpy
    from keras.models import Sequential
    from keras.layers import Dense
    
    # fix random seed for reproducibility
    seed = 7
    numpy.random.seed(seed)
    
    X = numpy.array([[x, x if x%2 == 0 else -x] for x in range(1000)])
    Y = [1,0]*500
    
    # create model
    model = Sequential()
    model.add(Dense(12, input_dim=2, init='uniform', activation='relu'))
    model.add(Dense(8, init='uniform', activation='relu'))
    model.add(Dense(1, init='uniform', activation='sigmoid'))
    # Compile model
    model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
    # Fit the model
    model.fit(X, Y, epochs=50, batch_size=10,  verbose=2)
    # Calculate predictions
    predictions = model.predict(X)
    

    请注意,基于偶数或奇数将数字转换为负空间也适用于一维,但使用具有二维向量的散点图更容易演示。

    【讨论】:

      【解决方案3】:

      神经网络不擅长判断一个数字是否为偶数。如果输入表示只是一个整数,至少不会。神经网络擅长找出和组合线性决策边界。在所有自然数的情况下,有无限数量的决策边界来检查一个数字是否为偶数。然而,如果你只是让你的神经网络在所有数字的一个子集上工作,那么你可以让它工作。但是,基本上每个数字都需要一个神经元才能在输入层中进行测试。所以对于0 <= n < 1000,你的输入层需要一千个神经元。这并不是神经网络的一个很好的例子。

      如果您要将输入的表示更改为数字的二进制表示,那么 NN 将更容易检测数字是否为偶数。例如。

      X = [
        [0, 0, 0], # 0
        [0, 0, 1], # 1
        [0, 1, 0], # 2
        [0, 1, 1], # 3
        [1, 0, 0], # 4
        [1, 0, 1], # 5
        [1, 1, 0], # 6
        [1, 1, 1]  # 7
      ]
      
      Y = [1, 0, 1, 0, 1, 0, 1, 0]
      

      如您所见,这是一个需要解决的相当简单的问题:基本上是最后一个二进制数字的倒数。这是一个预处理输入以创建神经网络更容易解决的问题的示例。

      【讨论】:

      • 优秀的答案。确认代表的重要性。我基本上使用你的模型来创建我的答案。
      【解决方案4】:

      我并不惊讶它不起作用 - 神经网络根本不像那样工作。

      您必须更好地感受您将什么作为输入传递给神经网络。

      当你传递数字时,它必须有一些含义。这意味着:如果一个数字大于另一个数字,它应该会导致某些事情。就像年龄 -> 金钱,应该有任何依赖。

      但是在找奇数的时候,这个意思就比较抽象了。老实说,您应该将输入视为独立的字符串值。

      也许:请尝试作为输入:

      X = [[math.floor(item/2), item/2 - math.floor(item/2)] for item in range(1000)]
      

      并检查网络是否会理解“如果第二个值大于零,则数字是奇数”。

      继续阅读以获得更好的感觉:)

      编辑:

      @米兰诺 完整的代码看起来像

      from keras.models import Sequential
      from keras.layers import Dense
      import numpy
      import math
      # fix random seed for reproducibility
      seed = 7
      numpy.random.seed(seed)
      
      X = numpy.array([[math.floor(item/2), item/2 - math.floor(item/2)] for item in range(1000)])
      
      Y = [1, 0]*500
      # create model
      model = Sequential()
      model.add(Dense(12, input_shape=(2,), init='uniform', activation='relu'))
      model.add(Dense(8, init='uniform', activation='relu'))
      model.add(Dense(1, init='uniform', activation='sigmoid'))
      # Compile model
      model.compile(loss='mean_squared_error', optimizer='adam', metrics=['accuracy'])
      # Fit the model
      model.fit(X, Y, epochs=150, batch_size=10,  verbose=2)
      # calculate predictions
      predictions = model.predict(X)
      # round predictions
      rounded = [round(x[0])for x in predictions]
      print(rounded)
      

      【讨论】:

      • 我试过了,但它返回:ValueError:检查模型输入时出错:您传递给模型的 Numpy 数组列表不是模型预期的大小。预计会看到 1 个数组,但得到了以下 1000 个数组的列表:[array([[0.],
      【解决方案5】:

      机器学习的目标是在具有特征/模式的数据上预测标签(Y 代表你)(X 代表你这里)

      你的问题是你的 X 只是一个不断增长的列表,没有特定的模式序列或任何解释。

      所以你试图让一个统计算法来解释完全随机的事情,这是不可能

      在机器学习的参考平台 Kaggle 上尝试使用 Titanic 数据集开始机器学习:

      https://www.kaggle.com/upendr/titanic-machine-learning-from-disaster/data

      下载它,通过 pandas 加载它并尝试相同的算法。

      您的 X 将是每个特征,例如阶级、年龄、性别等。您的 Y 是幸存的,如果他活着,则值为 1,否则为 0。并且您将尝试确定他是否还活着,这要归功于时代、性别等方面的模式......

      我还可以推荐看看 Andrew Ng : Machine Learning Courses,它会解释一切,并且对初学者来说真的很容易理解

      玩得开心! :)

      【讨论】:

      • 没有一门或多门课程可以解释一切!
      【解决方案6】:

      这不是我见过的最奇怪的神经网络应用。最接近的例子是 2006 年的 A Compositional Neural-network Solution to Prime-number Testing,它使用神经网络来解决更复杂的数论问题。

      研究的结果是它可以被训练,我建议你尝试使用类似的结构,但正如论文得出的结论,对于这类问题有更好的解决方案。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-05
        • 1970-01-01
        • 2019-09-23
        • 1970-01-01
        • 2017-05-03
        • 2015-12-13
        • 1970-01-01
        • 2023-03-04
        相关资源
        最近更新 更多