Comments (4)
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.
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.
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.
right, just it. thanks.
from reversi-alpha-zero.
Related Issues (20)
- About the optimizer? HOT 5
- invalid correct moves HOT 2
- GPU ResourceExhaustedError after many times of Keras model.load() during self-play HOT 1
- What's different between Challenge 2 & 3? HOT 2
- The sign of virtual loss is reversed
- The history dates of Challenge 3/4 are wrong. HOT 1
- It may forget pertinent information about positions that it no longer visits. HOT 21
- automatically ntest HOT 2
- Performance Reports HOT 23
- Unofficial AlphaGoZero implementation from Googlers HOT 15
- how much does share_mtcs_info_in_self_play contribute in strength? HOT 7
- Child seeds being identical to the parent seed may nullify the effect of multi-processing/threading HOT 3
- a question about reloading model HOT 2
- AlphaZero Approach HOT 2
- Replacing CNN with decoder-only Transformer for possible acceleration? HOT 3
- maybe a bug here HOT 1
- About using different players for training game generation HOT 6
- Cannot use multiple GPUs in self-play HOT 3
- tensorflow.python.framework.errors_impl.InvalidArgumentError: Tensor input_1:0, specified in either feed_devices or fetch_devices was not found in the Graph HOT 1
- Gobang version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reversi-alpha-zero.