chengstone / cchess-zero Goto Github PK
View Code? Open in Web Editor NEWAlphaZero implemented Chinese chess. AlphaGo Zero / AlphaZero实践项目,实现**象棋。
License: MIT License
AlphaZero implemented Chinese chess. AlphaGo Zero / AlphaZero实践项目,实现**象棋。
License: MIT License
.
uvloop不支持windows系统,无法运行,望在readme中说明。如果可以,请添加不使用uvloop的版本。
系统是ubuntu18.04
以下是错误讯息:
(venv) kenny@wade-X750JB:~/Desktop/cchess-zero$ python main.py --mode play --ai_count 2 --ai_function mcts --play_playout 1200
Loading Models...
2018-08-29 15:55:02.524177: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
WARNING:tensorflow:From /home/kenny/Desktop/cchess-zero/policy_value_network.py:78: softmax_cross_entropy_with_logits (from tensorflow.python.ops.nn_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Future major versions of TensorFlow will allow gradients to flow
into the labels input on backprop by default.
See @{tf.nn.softmax_cross_entropy_with_logits_v2}.
Traceback (most recent call last):
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1278, in _do_call
return fn(*args)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1263, in _run_fn
options, feed_dict, fetch_list, target_list, run_metadata)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1350, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [128]
[[Node: save/Assign_66 = Assign[T=DT_FLOAT, _class=["loc:@conv2d_16/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv2d_16/bias, save/RestoreV2:66)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1725, in restore
{self.saver_def.filename_tensor_name: save_path})
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 877, in run
run_metadata_ptr)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1100, in _run
feed_dict_tensor, options, run_metadata)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1272, in _do_run
run_metadata)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1291, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [128]
[[Node: save/Assign_66 = Assign[T=DT_FLOAT, _class=["loc:@conv2d_16/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv2d_16/bias, save/RestoreV2:66)]]
Caused by op 'save/Assign_66', defined at:
File "main.py", line 1583, in
args.search_threads, args.processor, args.num_gpus, args.res_block_nums, args.human_color) # * args.num_gpus
File "/home/kenny/Desktop/cchess-zero/ChessGame.py", line 50, in init
processor=processor, num_gpus=num_gpus, res_block_nums=res_block_nums, human_color=human_color)
File "/home/kenny/Desktop/cchess-zero/main.py", line 1142, in init
self.policy_value_netowrk = policy_value_network(res_block_nums) if processor == 'cpu' else policy_value_network_gpus(num_gpus, res_block_nums)
File "/home/kenny/Desktop/cchess-zero/policy_value_network.py", line 148, in init
self.saver = tf.train.Saver()
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1281, in init
self.build()
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1293, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1330, in _build
build_save=build_save, build_restore=build_restore)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 778, in _build_internal
restore_sequentially, reshape)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 419, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 112, in restore
self.op.get_shape().is_fully_defined())
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 216, in assign
validate_shape=validate_shape)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 60, in assign
use_locking=use_locking, name=name)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op
op_def=op_def)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1717, in init
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [128]
[[Node: save/Assign_66 = Assign[T=DT_FLOAT, _class=["loc:@conv2d_16/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv2d_16/bias, save/RestoreV2:66)]]
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 1583, in
args.search_threads, args.processor, args.num_gpus, args.res_block_nums, args.human_color) # * args.num_gpus
File "/home/kenny/Desktop/cchess-zero/ChessGame.py", line 50, in init
processor=processor, num_gpus=num_gpus, res_block_nums=res_block_nums, human_color=human_color)
File "/home/kenny/Desktop/cchess-zero/main.py", line 1142, in init
self.policy_value_netowrk = policy_value_network(res_block_nums) if processor == 'cpu' else policy_value_network_gpus(num_gpus, res_block_nums)
File "/home/kenny/Desktop/cchess-zero/policy_value_network.py", line 149, in init
self.train_restore()
File "/home/kenny/Desktop/cchess-zero/policy_value_network.py", line 170, in train_restore
self.saver.restore(self.sess, tf.train.latest_checkpoint(self.save_dir))
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1759, in restore
err, "a mismatch between the current graph and the graph")
tensorflow.python.framework.errors_impl.InvalidArgumentError: Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [128]
[[Node: save/Assign_66 = Assign[T=DT_FLOAT, _class=["loc:@conv2d_16/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv2d_16/bias, save/RestoreV2:66)]]
Caused by op 'save/Assign_66', defined at:
File "main.py", line 1583, in
args.search_threads, args.processor, args.num_gpus, args.res_block_nums, args.human_color) # * args.num_gpus
File "/home/kenny/Desktop/cchess-zero/ChessGame.py", line 50, in init
processor=processor, num_gpus=num_gpus, res_block_nums=res_block_nums, human_color=human_color)
File "/home/kenny/Desktop/cchess-zero/main.py", line 1142, in init
self.policy_value_netowrk = policy_value_network(res_block_nums) if processor == 'cpu' else policy_value_network_gpus(num_gpus, res_block_nums)
File "/home/kenny/Desktop/cchess-zero/policy_value_network.py", line 148, in init
self.saver = tf.train.Saver()
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1281, in init
self.build()
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1293, in build
self._build(self._filename, build_save=True, build_restore=True)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 1330, in _build
build_save=build_save, build_restore=build_restore)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 778, in _build_internal
restore_sequentially, reshape)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 419, in _AddRestoreOps
assign_ops.append(saveable.restore(saveable_tensors, shapes))
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/training/saver.py", line 112, in restore
self.op.get_shape().is_fully_defined())
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/ops/state_ops.py", line 216, in assign
validate_shape=validate_shape)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/ops/gen_state_ops.py", line 60, in assign
use_locking=use_locking, name=name)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/framework/op_def_library.py", line 787, in _apply_op_helper
op_def=op_def)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py", line 454, in new_func
return func(*args, **kwargs)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 3155, in create_op
op_def=op_def)
File "/home/kenny/tensorflow/venv/lib/python3.6/site-packages/tensorflow/python/framework/ops.py", line 1717, in init
self._traceback = tf_stack.extract_stack()
InvalidArgumentError (see above for traceback): Restoring from checkpoint failed. This is most likely due to a mismatch between the current graph and the graph from the checkpoint. Please ensure that you have not altered the graph expected based on the checkpoint. Original error:
Assign requires shapes of both tensors to match. lhs shape= [1] rhs shape= [128]
[[Node: save/Assign_66 = Assign[T=DT_FLOAT, _class=["loc:@conv2d_16/bias"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/device:CPU:0"](conv2d_16/bias, save/RestoreV2:66)]]
(venv) kenny@wade-X750JB:~/Desktop/cchess-zero$
Help translate into English for non-Chinese enthusiasts of machine learning to read
[X] - add README.en.md for English
[X] - translate cchess-zero.ipynb
[X] - translate Mastering_Chess_and_Shogi_by_Self-Play_with_a_General_Reinforcement_Learning_Algorithm.ipynb
I did not remove the Chinese text in case you want to merge. It is up to you if you want to merge but I will leave this here.
如果你想合并,我没有删除中文文本。如果你想合并取决于你,但我会把它留在这里。
在main.py的第371行:
if self.is_black_turn(current_player): action_probs=cchess_main.flip_policy(action_probs)
是什麼意思?為什麼要判斷是不是黑棋?
temperature其實就是讓AI在非訓練時選N最大的;訓練時依N的大小隨機選
那為什麼不直接在非訓練時用max()
NotFoundError (see above for traceback): Key BatchNorm/moving_mean not found in checkpoint
[[Node: save/RestoreV2 = RestoreV2[dtypes=[DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, ..., DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_FLOAT, DT_INT32], _device="/job:localhost/replica:0/task:0/device:CPU:0"](_arg_save/Const_0_0, save/RestoreV2/tensor_names, save/RestoreV2/shape_and_slices)]]
能标注一下tensorflow的版本吗??
您好,我在train的时候,在get_action方法里,
actions, visits = zip(*actions_visits)
print(actions, visits)
probs = softmax(1.0 / temperature * np.log(visits)) # + 1e-10
这一步的visits会产生很多0,导致np.log计算时发生错误,这个应该怎么解决呢?
kenny@wade-X750JB:~/Desktop/cchess-zero$ python2 main.py
File "main.py", line 261
def Q(self, move) -> float:
^
SyntaxError: invalid syntax
我用tensorflow1.0去运行tensorBoard ,可以进去,但是SCALARS什么的都是空的,只有EMBEDDINGD里面有东西,tensorflow新手,请问您那边代码可以正常现实tensorBoard么?感谢!
images的图片的副档名应该是小写的gif吧?
AttributeError: module 'dask.dataframe' has no attribute 'Series'
Sent from PPHub
我在我的5900x+rtx4090上跑起来了,可是cpu和gpu利用率都很低。如何增加cpu并发核心数量以及gpu利用率,加快下棋速度。
我的是ubuntu22.04版本。
运行下棋指令时,报错:_tkinter.TclError: no display name and no $DISPLAY environment variable
请问您有遇到过吗?
您好,感谢您的分享现在想问您关于ma.py的程序中
if (x if abs(dx) ==1 else x+dx/2, y if abs(dy) ==1 else y+ (dy/2)) in board.pieces:
#print 'blocked'
return False
这块是什么意思呢
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.