Giter Club home page Giter Club logo

Comments (4)

mokemokechicken avatar mokemokechicken commented on August 26, 2024 2

@apollo-time

oh, I was careless.
How about like this?

  legal_mask = Input((8 * 8))  # (0: illegal, 1: legal)
  legal_mask_2 = Lambda(lambda x: (x-1)*1000000)(legal_mask)  # illegal -> -1000000, legal -> 0
  ...
  # no output for 'pass'
  x = Dense(8*8, kernel_regularizer=l2(mc.l2_reg))(x)
  x = Add()([x, legal_mask_2])
  policy_out = Activation("softmax", name="policy_out")(x)
  
  ...
  
  self.model = Model([in_x, legal_mask], [policy_out, value_out], name="reversi_model")
> softmax([-0.5, 0.5])
[ 0.26894142,  0.73105858]

> softmax([-0.5, 0.5, -1000000])
[ 0.26894142,  0.73105858,  0.        ]

from reversi-alpha-zero.

mokemokechicken avatar mokemokechicken commented on August 26, 2024 1

I see calculate policy softmax on the all moves contains illegal.
How can calculate softmax on the only legal moves, if set placeholder for legal moves?

Does this answer understand the intent of the question?


For example,

  # no output for 'pass'
  policy_out = Dense(8*8, kernel_regularizer=l2(mc.l2_reg), activation="softmax", name="policy_out")(x)

  legal_mask = Input((8 * 8))  # (0: illegal, 1: legal)
  ...
  # no output for 'pass'
  x = Dense(8*8, kernel_regularizer=l2(mc.l2_reg))(x)
  x = Multiply()([x, legal_mask])
  policy_out = Activation("softmax", name="policy_out")(x)
  
  ...
  
  self.model = Model([in_x, legal_mask], [policy_out, value_out], name="reversi_model")

Input of legal_mask is required to be computed in all training data.

from reversi-alpha-zero.

apollo-time avatar apollo-time commented on August 26, 2024

Is not equal softmax((0, -0.5, 0.5))[1:2] and softmax((-0.5,0.5)) when legal_mask=(0,1,1)?

from reversi-alpha-zero.

apollo-time avatar apollo-time commented on August 26, 2024

right, just it. thanks.

from reversi-alpha-zero.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.