简体   繁体   English

神经网络分类器扑克

[英]Neural network classifier poker

I am currently trying to create a neural network to predict poker hands, I am quite new to machine learning and neural networks and might need some help!I found some tutorials on how to create a neural network and this is my try in trying to adapt this data set to it.The following code is making pycharm crash here is the code: 我目前正在尝试创建一个神经网络来预测扑克手,对于机器学习和神经网络来说我还很陌生,可能需要一些帮助!我找到了一些有关如何创建神经网络的教程,这是我尝试适应的尝试此数据集到它。以下代码使pycharm崩溃,这是代码:

import numpy as np
import pandas as pnd
# sigmoid function


def nonlin(x, deriv=False):
    if deriv:
        return x * (1 - x)
    return 1 / (1 + np.exp(-x))
# InputData
training_data = pnd.read_csv("train.csv")
print(training_data)
training_data = training_data.drop(['hand'], axis=1)
print(training_data)
X = np.array(training_data)

# output data
training_data = pnd.read_csv("train.csv")
print(training_data)
training_data = training_data.drop(['S1'], axis=1)
training_data = training_data.drop(['C1'], axis=1)
training_data = training_data.drop(['S2'], axis=1)
training_data = training_data.drop(['C2'], axis=1)
training_data = training_data.drop(['S3'], axis=1)
training_data = training_data.drop(['C3'], axis=1)
training_data = training_data.drop(['S4'], axis=1)
training_data = training_data.drop(['C4'], axis=1)
training_data = training_data.drop(['S5'], axis=1)
training_data = training_data.drop(['C5'], axis=1)
print(training_data)
Y = np.array(training_data).T
print(Y)
# input dataset
# seed random numbers to make calculation
# deterministic (just a good practice)
np.random.seed(1)
# initialize weights randomly with mean 0
syn0 = 2 * np.random.random((10, 25011)) - 1
syn1 = 2*np.random.random((10, 1)) - 1

for j in range(10000):
    # Feed forward through layers 0, 1, and 2
    l0 = X
    l1 = nonlin(np.dot(l0, syn0))
    l2 = nonlin(np.dot(l1, syn1))
    # how much did we miss the target value?
    l2_error = y - l2
    if (j % 10000) == 0:
        print("Error:" + str(np.mean(np.abs(l2_error))))
    # in what direction is the target value
    # were we really sure? if so, don't change too much.
    l2_delta = l2_error * nonlin(l2, deriv=True)
    # how much did each l1 value contribute to the l2 error (according to the weights)?
    l1_error = l2_delta.dot(syn1.T)
    # in what direction is the target l1?
    # were we really sure? if so, don't change too much.
    l1_delta = l1_error * nonlin(l1, deriv=True)
    syn1 += l1.T.dot(l2_delta)
    syn0 += l0.T.dot(l1_delta)

The following is a snippet of my data set: Data set snippet 以下是我的数据集的代码段数据集代码段

And the following is an explanation of the data set i am using: Attribute Information: 以下是我正在使用的数据集的解释:属性信息:

1) S1 "Suit of card #1" 
Ordinal (1-4) representing {Hearts, Spades, Diamonds, Clubs} 

2) C1 "Rank of card #1" 
Numerical (1-13) representing (Ace, 2, 3, ... , Queen, King) 

3) S2 "Suit of card #2" 
Ordinal (1-4) representing {Hearts, Spades, Diamonds, Clubs} 

4) C2 "Rank of card #2" 
Numerical (1-13) representing (Ace, 2, 3, ... , Queen, King) 

5) S3 "Suit of card #3" 
Ordinal (1-4) representing {Hearts, Spades, Diamonds, Clubs} 

6) C3 "Rank of card #3" 
Numerical (1-13) representing (Ace, 2, 3, ... , Queen, King) 

7) S4 "Suit of card #4" 
Ordinal (1-4) representing {Hearts, Spades, Diamonds, Clubs} 

8) C4 "Rank of card #4" 
Numerical (1-13) representing (Ace, 2, 3, ... , Queen, King) 

9) S5 "Suit of card #5" 
Ordinal (1-4) representing {Hearts, Spades, Diamonds, Clubs} 

10) C5 "Rank of card 5" 
Numerical (1-13) representing (Ace, 2, 3, ... , Queen, King) 

11) CLASS "Poker Hand" 
Ordinal (0-9) 

0: Nothing in hand; not a recognized poker hand 
1: One pair; one pair of equal ranks within five cards 
2: Two pairs; two pairs of equal ranks within five cards 
3: Three of a kind; three equal ranks within five cards 
4: Straight; five cards, sequentially ranked with no gaps 
5: Flush; five cards with the same suit 
6: Full house; pair + different rank three of a kind 
7: Four of a kind; four equal ranks within five cards 
8: Straight flush; straight + flush 
9: Royal flush; {Ace, King, Queen, Jack, Ten} + flush 

The variables being used: 使用的变量:

Variable    Definition
X   Input dataset matrix where each row is a training example
y   Output dataset matrix where each row is a training example
l0  First Layer of the Network, specified by the input data
l1  Second Layer of the Network, otherwise known as the hidden layer
l2  Final Layer of the Network, which is our hypothesis, and should approximate the correct answer as we train.
syn0    First layer of weights, Synapse 0, connecting l0 to l1.
syn1    Second layer of weights, Synapse 1 connecting l1 to l2.
l2_error    This is the amount that the neural network "missed".
l2_delta    This is the error of the network scaled by the confidence. It's almost identical to the error except that very confident errors are muted.
l1_error    Weighting l2_delta by the weights in syn1, we can calculate the error in the middle/hidden layer.
l1_delta    This is the l1 error of the network scaled by the confidence. Again, it's almost identical to the l1_error except that confident errors are muted.

First you should definitely clarify whether this is crashing your computer or your process. 首先,您绝对应该弄清楚这是否使您的计算机或进程崩溃。

If it is your computer, check your RAM specs and how much is in use (top, htop, etc.) when you launch the NN. 如果是您的计算机,请在启动NN时检查RAM规格以及正在使用的内存量(top,htop等)。

Your syn0 matrix is 10x25011. 您的syn0矩阵为10x25011。 That's 10 * 25011 * 8 / 1024 = 1953kB. 那是10 * 25011 * 8/1024 = 1953kB。 If you're putting almost 2 gigs into a single variable in Python and running a bunch of Chrome tabs, a full shutdown is a real possibility. 如果您要将近2个演出放到Python的单个变量中并运行一堆Chrome标签页,则完全关闭的可能性很大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 多分类器神经网络问题 - Multiclass classifier neural network problem 使用MLP的神经网络分类器 - Neural network classifier using MLP Keras 中的连体神经网络 + 分类器 (FFN) - Siamese Neural Network + Classifier (FFN) in Keras 如何检查keras分类器/神经网络的训练类? - how to check the classes a keras classifier/Neural Network is trained on? 改变神经元数量时,精度低的神经网络分类器没有改善 - Neural Network classifier with low accuracy does not improve when changing neuron count 是什么使神经网络很难学习x / 256的分类是x的分类器? - What make it so hard for a neural network to learn a classifier that class of x/256 is x? 何时在分类器神经网络 model 中使用“准确度”字符串或 tf.keras.metrics.Accuracy() - When to use "accuracy" string or tf.keras.metrics.Accuracy() in a classifier neural network model 我们如何使用神经网络计算多类分类器的准确度 - How do we calculate the accuracy of a multi-class classifier using neural network 为什么我们必须在tensorflow中的深度神经网络中而不是在线性分类器中嵌入列? - Why do we have to embed columns in Deep Neural Network but not in Linear Classifier in tensorflow? 您可以帮助我在pyBrain中线性激活我的简单分类器神经网络吗? - Can you help me with linear activation of my Simple Classifier Neural Network in pyBrain?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM