• <noscript id="e0iig"><kbd id="e0iig"></kbd></noscript>
  • <td id="e0iig"></td>
  • <option id="e0iig"></option>
  • <noscript id="e0iig"><source id="e0iig"></source></noscript>
  • 卷積神經網絡計數流程圖_用神經網絡計數卡

    標簽: 神經網絡  深度學習  卷積神經網絡  tensorflow  https

    卷積神經網絡計數流程圖

    You can find my code on my Github here.

    您可以在我的Github上找到我的代碼。

    Here are the links to my previous posts on blackjack. I used a modified version of my old blackjack simulator (discussed in detail in the linked posts). If you want to know more about how I coded it up or just need a refresher on basic blackjack strategy, you can read these first:

    這是我以前在二十一點上的帖子的鏈接。 我使用了舊的二十一點模擬器的修改版(在鏈接文章中詳細討論了)。 如果您想了解更多有關我如何編碼的信息,或者只需要對基本的二十一點策略進行復習,則可以先閱讀以下內容:

    One thing that perplexed me last year when I trained a neural net to play blackjack was why my neural net didn’t do better when I provided card counting information to it. Doesn’t card counting confer a significant advantage to the player?

    困惑著我,去年當我訓練神經網絡玩二十一點ØNE件事就是為什么當我提供的算牌信息,它在我的神經網絡沒有做的更好。 算牌不會給玩家帶來重大優勢嗎?

    For those unfamiliar with the concept, counting cards is a way of tracking the number of high cards (10, Jack, Queen, King, Ace) left in the deck. The idea is that when there are a lot of face cards left in the deck, it’s advantageous to players (because we are more likely to be dealt high cards and the dealer is also more likely to bust). So if our card counting tips us off that the remaining cards are more likely to be high, we should take advantage by making larger than normal bets.

    對于不熟悉此概念的人,計數卡是一種跟蹤剩余在甲板上的高級卡(10張,杰克,皇后,國王,王牌)數量的方法。 這個想法是,當甲板上有很多面子牌時,這對玩家是有利的(因為我們更有可能獲得高額牌,而發牌者也更有可能破產)。 因此,如果我們的紙牌計數使我們發現剩余紙牌的可能性更高,那么我們應該通過比正常情況下更大的賭注加以利用。

    When I tried to integrate card counting into my blackjack code last year, it failed to add anything because I did it incorrectly. The model that I built previously took in information like the cards in the player’s hand and the card that the dealer is showing and decided whether to keep hitting or stay.

    去年,當我嘗試將卡計數集成到我的二十一點代碼中時,由于我做錯了,它未能添加任何內容。 我之前建立的模型吸收了諸如玩家手中的卡和發牌者所顯示的卡之類的信息,并決定是繼續擊打還是留下。

    I attempted to augment my model by providing it with a detailed count of all the cards that had been seen thus far as part of its training data (the count is refreshed every time that the deck is reshuffled). I figured that the count would allow the neural net to predict when the dealer was likely to bust — and this additional information would improve its hit/stay decision making.

    我試圖通過向模型提供到目前為止已被視為其訓練數據一部分的所有卡片的詳細計數來擴充我的模型(每次重新排列牌組時都會刷新該計數)。 我認為,該計數將使神經網絡能夠預測經銷商何時可能破產—并且這些附加信息將改善其命中/停留決策。

    Surprisingly, this was not what happened. The performance actually got worse! The win probability dropped from 42% without card counting data to 38% with it. The tie probability also drops from 9% to 5% hinting at a more aggressive playing style.

    令人驚訝的是,這不是發生的事情。 性能實際上變差了! 獲勝幾率從無紙牌計數數據的42%下降到有數據的38%。 平局概率也從9%下降到5%,暗示了更具侵略性的比賽風格。

    有時機器學錯了東西 (Sometimes Machines Learn The Wrong Thing)

    As you can see below, when given card count data, the neural net is able to do ever so slightly better in terms of probability of a win or tie when the dealer is showing a low card but significantly underperforms its simpler (no card count data) predecessor when the dealer is showing a 10 or an ace (11 denotes ace). The probabilities in the following plots were generated by simulating approximately 250,000 blackjack games with trained neural nets deciding whether to hit or stay.

    如下所示,如果給定卡數數據,則神經網絡在發牌者顯示低卡數但顯著落后于簡單數據(無卡數數據)的情況下,在獲勝或平局的可能性方面要稍好一些。 )的前身,即莊家展示的是10或ace(11表示ace)。 以下情節中的概率是通過使用訓練有素的神經網絡模擬大約25萬個二十一點游戲來決定擊中還是停留而生成的。

    Image for post
    Win or tie probability with and without card counting data fed to neural net (Image by author)
    帶或不帶卡計數數據饋入神經網絡的獲勝或平局概率(圖片由作者提供)

    If we isolate out just the games where the dealer is showing a 10, face card, or an ace we can see the cause of the underperformance. Our supposedly smarter neural net (the one with the card count data) is doing some pretty dumb things. Looking at the blue bars in the plot below, we can see that it chooses to hit frequently even when it already holds a high hand total of 17 or more (it even hits occasionally when it’s already at 20). Contrast that to our simpler model — it correctly knows to stay for hands totaling 17 or more.

    如果我們僅將莊家出示10張,面子卡或ace的游戲隔離開,我們就可以看出性能不佳的原因。 我們所謂的更智能的神經網絡(帶有卡計數數據的神經網絡)正在做一些非常愚蠢的事情。 查看下面圖表中的藍色條,我們可以看到它選擇了頻繁擊球,即使它已經擁有高手牌總數達到或超過17(甚至已經達到20時也偶爾擊中)。 與我們更簡單的模型相比,它正確地知道要停留總計17張或更多的牌。

    Image for post
    Probability of hitting when the dealer is showing a 10, face card, or an ace (Image by author)
    莊家出示10,牌面或A牌時擊中的可能性(圖片由作者提供)

    It’s not all bad. Earlier we saw that adding card count data improves the winning probability when the dealer is showing a low card (6 or less). Intuitively, the reason for this is that when the dealer is showing a low card, the dealer will definitely have to hit until his hand totals at least 17 (or he or she busts). So having knowledge of when the dealer is more likely to bust should prove somewhat helpful in these situations. And as we can see, the behavior of our card counting neural net is different. It is much more likely to stay for hands totaling 13, 14, and 15 — and based on the higher win probabilities, it seems to be on average making the right decision in these cases.

    并不全是壞事。 較早前我們看到,當發牌者顯示一張低牌(6張或更少)時,增加卡數數據可以提高中獎幾率。 直觀地講,這樣做的原因是,當發牌者出示一張低牌時,發牌者肯定要打直到他的手牌總數至少為17(否則他或她破產)。 因此,了解經銷商何時更可能破產的事實在這些情況下會有所幫助。 正如我們所看到的,我們的卡片計數神經網絡的行為是不同的。 在總計13、14和15的牌局中,它更有可能留下來,并且基于更高的獲勝概率,在這些情況下,似乎平均可以做出正確的決定。

    Image for post
    Probability of hitting when the dealer is showing a 2, 3, 4, 5, or 6 (Image by author)
    經銷商顯示2、3、4、5或6時命中的可能性(作者提供的圖片)

    Still, the overall decline in win probability is disappointing. Choosing to hit when our hand is already at 19 or 20 is a big facepalm. Based on our examination of how the neural net’s behavior changed once we added in card count data, it looks like while the additional data embeds some signal, it also caused our model to become overfit and make some foolish decisions. So let’s attempt to fix this.

    盡管如此,獲勝幾率的整體下降還是令人失望的。 當我們的手已經在19或20時選擇擊打是個大難題。 根據我們對神經網絡行為的觀察,一旦我們添加了卡計數數據,神經網絡的行為就會發生變化,看起來當附加數據中嵌入了一些信號時,這也導致我們的模型變得過擬合并做出了一些愚蠢的決策。 因此,讓我們嘗試解決此問題。

    試圖修正我們的模型 (Trying To Fix Our Model)

    When I went back and reviewed how counting cards actually worked, I realized I was thinking about it wrong. The additional features offer limited assistance in terms of helping our model know whether to hit or stay. In fact, as we saw, the added features were more likely to confuse the model than help it. But where the card count data might be able to help us is in deciding how much to bet. If we know that there are a lot of high cards left in the deck, we should bet more because the probability of blackjack (two card hand consisting of an ace and a 10 or a face card) is higher. Conversely, if we know that the remaining cards consist primarily of low cards, we should just make the minimum bet.

    當我回過頭來回顧計數卡的實際工作原理時,我意識到自己在想錯。 附加功能在幫助我們的模型知道撞擊還是停留方面提供的幫助有限。 實際上,正如我們所看到的那樣,添加的功能比幫助模型更容易混淆模型。 但是,卡數數據可能在哪些方面可以幫助我們確定賭多少。 如果我們知道甲板上還剩下很多高牌,我們應該下更多的賭注,因為二十一點(兩張牌由一張ace和一張10或一張面牌組成)的可能性更高。 相反,如果我們知道其余的牌主要由低牌組成,那么我們應該進行最低**。

    In order to do this, instead of shoving everything into a single model, we can split up the responsibilities. We could have our old model that already worked pretty well handle the hit or stay decision and build a new model which uses the card count data to decide how much to bet. It would look something like what’s pictured below. A note on the card count features — I keep a count of how many of each card type I’ve seen thus far and when the dealer reshuffles the deck (or stack) I reset all the counts to 0.

    為了做到這一點,我們不必將所有事情都推到一個單一的模型中,而是可以分擔責任。 我們可以讓已經運行良好的舊模型處理命中或停留決定,并建立一個新模型,該模型使用卡計數數據來決定**多少。 它看起來像下面的圖片。 關于紙牌數量功能的注釋-我記下了到目前為止我所見過的每種紙牌類型的數量,并且當發牌人重新洗牌(或堆疊)時,我將所有計數重置為0。

    Image for post
    Two models each with their own job (Image by author)
    各自負責工作的兩個模型(作者提供)

    Of course all this depends on whether the card count data truly does help us predict blackjacks. Let’s check. We can use a ROC curve to check the efficacy of neural net 2 (if you need a refresher on what ROC curves are, check out the following link).

    當然,這取決于卡計數數據是否確實有助于我們預測二十一點。 讓我們檢查。 我們可以使用ROC曲線來檢查神經網絡2的功效(如果需要對ROC曲線進行復習,請查看以下鏈接)。

    Judging by the higher area under its ROC curve (blue line), neural net 2 does seem to add value (relative to deciding randomly):

    從其ROC曲線下的較高區域(藍線)來看,神經網絡2似乎確實增加了價值(相對于隨機決定):

    Image for post
    ROC curve for neural net 2 attempting to predict blackjacks (Image by author)
    嘗試預測二十一點的神經網絡2的ROC曲線(作者提供的圖片)

    So let’s use it to size our bets and see if our performance improves. I simulated 100 blackjack decks (like a long night at the casino) 100 times and compared the average results and distributions between the following two betting strategies:

    因此,讓我們用它來衡量我們的賭注,看看我們的表現是否有所改善。 我模擬了100次二十一點套牌(就像在賭場里漫長的一夜),并比較了以下兩種**策略的平均結果和分布:

    1. Making the minimum bet of $10 every time.

      每次最少**$ 10。
    2. When the count is advantageous, bet more based on how confident we are (formula below). Otherwise bet $10.

      如果計數是有利的,則根據我們的信心(下式)進行更多**。 否則**$ 10。

    Here’s how I decided to size the bets (full disclosure — I didn’t think super hard about this decision rule):

    這是我決定**的方式(全面披露-對于此決定規則,我并不覺得辛苦):

    Using the training data, calculate the mean and standard deviation of the probabilities (of a blackjack) generated by neural net 2.Z-score neural net 2’s output prediction:
    Z_prob = (prediction - mean)/std_devif Z_prob > 0:
    bet = 10*(1 + Z_prob)
    else:
    bet = 10

    Basically if the predicted probability of getting a blackjack is higher than average, I bet more — and the excess amount that I bet is determined by how much higher than average the predicted probability is.

    基本上,如果獲得二十一點的預測概率高于平均水平,我會下更多的賭注,而我所下的超額賭注則取決于預測概率比平均水平高多少。

    Cool, let’s see if we can actually improve our gambling results. The following plot compares gambling performance with and without neural net 2. While it looks like we still aren’t able to consistently make money, the dynamic bet sizing does improve our performance. The mean ending bankroll with dynamic bet sizing is 12% higher than without it.

    很酷,讓我們看看我們是否可以真正提高**效果。 下圖比較了使用和不使用神經網絡2時的**性能。雖然看起來我們仍然無法持續賺錢,但動態**規模的確提高了我們的表現。 動態**大小的平均結束資金比沒有**的情況高12%。

    Image for post
    Dynamic bet sizing does help (Image by author)
    動態**大小確實有幫助(作者提供圖片)

    Finally, let’s compare the distributions of our ending bankrolls to make sure our dynamic (and larger) bets is not causing excessive volatility in our betting results. The shape of the distributions seem reasonably similar with the dynamic bet sizing one (blue) slightly shifted to the right, which is good.

    最后,讓我們比較期末存款的分布情況,以確保動態(和較大)的**不會導致我們的**結果過度波動。 分布的形狀似乎與動態**一個(藍色)的大小稍微向右移動相似,這很好。

    Image for post
    Histogram of gambling results (Image by author)
    **結果的直方圖(作者提供的圖片)

    結論 (Conclusion)

    I was hoping for a bigger boost, but oh well. It looks like more tinkering is necessary, but at least it looks like we are onto something. It also goes to show that as cool and versatile as deep learning models can be, it still pays to be thoughtful about and to sanity check (as much as we can) the way our model works. Finally, winning when the odds are stacked against you is hard! Cheers!

    我原本希望得到更大的推動,但是哦。 似乎有必要進行更多的修補,但至少看起來像我們在做些事情。 它還表明,盡管深度學習模型可以酷炫且用途廣泛,但仍然值得深思和對模型的工作方式進行健全性檢查(盡我們所能)。 最后,在賠率對您不利的情況下贏球很難! 干杯!

    翻譯自: https://towardsdatascience.com/counting-cards-with-a-neural-net-ce426c2b6e57

    卷積神經網絡計數流程圖

    版權聲明:本文為weixin_26717189原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接和本聲明。
    本文鏈接:https://blog.csdn.net/weixin_26717189/article/details/108971489

    智能推薦

    分母為0怎么除????---java后端處理 與 sql處理

    (一)java處理 (二)SQL處理 結果:后端處理與sql處理達到的效果一直!誰的效率更明顯,暫時未知!...

    知識點最全的數據庫面試題

    來源:https://zhuanlan.zhihu.com/p/150959652 13道sql,基本上覆蓋了所有sql的核心點。 要求寫出一下SQL語句 1、查詢位于“華東”或“華南”地區的供應商的ID、公司名稱、地區、城市和電話字段的值 a. 地區=”華東” OR a.地區=”華南”; 2、查詢&l...

    面向切面編程(AOP)知識總結

    目錄 1.存在問題 2.AOP的概念 3.AOP應用范圍 3.AOP實現方式 4.應用舉例 5.結束語 本文在學習【老張的哲學】系列文章AOP相關章節后,自己歸納總結的筆記。 1.存在問題 最近,其它項目小組在開發的過程中遇到了一個問題,在日志記錄時,用戶明明點擊的是更新操作,可翻看記錄時卻發現是查詢操作,起初是一頭霧水,后面跟蹤該更新操作的代碼后才發現,在日志記錄時確實是寫著查詢,說到這里,大家...

    集合中出現的問題

    1.Java集合框架的長處? 2.集合框架中的泛型有什么長處? 3.Java集合框架的基礎接口有哪些? 4.為何Map接口不繼承Collection接口? 5.Iterater和ListIterator之間有什么差別? 6.fail-fast與fail-safe有什么差別? 7.在迭代一個集合的時候,怎樣避免ConcurrentModificationException?8.在Java中,Hash...

    猜你喜歡

    三元運算符引起的bug

    三元運算符引起的bug 前言 延伸 總結 前言 今天測試提交了一個bug,跟蹤發現了一段代碼,初看還沒什么問題,簡易后的代碼: 這段代碼想要實現的功能是返回 細看發現后面使用的是三元運算符,這就是造成這個bug的元兇。 解決方案:使用括號括起來。 延伸 在做這個例子的時候,使用ideal,習慣性的使用sonar掃描: 這里很明顯的提醒這里表達式有問題。 總結 三元運算符格式:expression1...

    利用dom4j來生成xml

    xml比較常用,處理xml的方式也比較多。現在就聊聊如何用dom4j來生成xml吧 先看看效果。。。 上傳代碼: 大概說下主要步驟吧:   1.創建document對象,創建root根節點,然后通過根節點繼續生成節點。其中也可以給該節點添加屬性,復制等。   2.創建輸出流,將該對象輸出到xml文件中去。需要設置好路徑和文件名等。...

    Android輪播圖原理思路分析+實現方案

    來自:http://blog.csdn.net/wubihang/article/details/52512597 ListView的headerView設置為輪播圖之后結合上/下拉刷新/加載的模式成為現在大多數APP的一個必須具備的功能,對于許多初學者來說想要實現輪播圖這樣一個集線程睡眠、自動處理、替換過程中刷新UI界面的組合功能非常困難,沒有思路,感覺無從下手,去搜索各種實現方案,發現目前充斥...

    Lambda的編寫和使用---java8編程實戰

    目錄 1.使用匿名類來表示不同的行為來實現行為參數,代碼有點啰嗦,解決這個問題的新工具--Lambda表達式。 2.Lambda的概念 3.Lambda語法測試  4.在程序中如何使用Lambda表達式 1.使用匿名類來表示不同的行為來實現行為參數,代碼有點啰嗦,解決這個問題的新工具--Lambda表達式。       Lambda可以讓你很簡潔地表示一個行...

    Electron學習筆記[1]

    什么是Electron Electron(最初名為Atom Shell[3])是GitHub開發的一個開源框架。它允許使用Node.js(作為后端)和Chromium(作為前端)完成桌面GUI應用程序的開發。 Electron 可以讓你使用純 JavaScript 調用豐富的原生 APIs 來創造桌面應用。你可以把它看作一個專注于桌面應用的 Node.js 的變體,而不是 Web 服務器。 很多很...

    精品国产乱码久久久久久蜜桃不卡