Skip to content
Permalink
main
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
from mxnet.gluon import nn,rnn
from mxnet import nd
from CnnCode import net
import copy
import mxnet as mx
from mxnet import gluon, init, nd, autograd
import random
from RnnCode import RnnModel,try_gpu
class Sequential(nn.Block):
def __init__(self,EMBEDDING_DIM,INPUT_DIM,LATENT_DIM,**kwargs):
super(Sequential, self).__init__(**kwargs)
self.convolution=net
self.dequence=RnnModel(EMBEDDING_DIM,INPUT_DIM,LATENT_DIM)
self.begin_state=self.dequence.begin_state
def forward(self, chessboard,maxlen_output,maxlen_input,decoder_inputs,weight,s,c):
chessboard=chessboard.reshape(1,1,chessboard.shape[0],chessboard.shape[1])
encoder_sequence=net(chessboard)
encoder_output=encoder_sequence.reshape(19,19)
output=self.dequence(maxlen_output,maxlen_input,decoder_inputs,weight,encoder_output,s,c)
return output
# if __name__ == '__main__':
# initlist=[0,0,0,0,135,255,0,0,0,135,0,255,135,0,0,0,0,0,0]
# def shuf(seq):
# random.seed(10)
# s=copy.deepcopy(seq)
# random.shuffle(s)
# return s
# chess_board=nd.array(list(map(lambda index:shuf(initlist),range(19))))
# print(chess_board.shape)
# seq=Sequential(EMBEDDING_DIM=19,INPUT_DIM=19*19,LATENT_DIM=19)
# decoder_inputs = nd.array([[int(i) for i in range(j * 19, j * 19 + 19)] for j in range(19 * 19)], dtype="float32")
# weight = nd.array([[0, 3, 4, 3, 3, 2, 3, 1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13],
# [1, 3, 5, 6, 8, 9, 10, 11, 12, 13, 14, 55, 66, 47, 28, 120, 121, 112, 213]])
# ctx=try_gpu()
# s, c=seq.begin_state(batch_size=19, ctx=ctx)
# seq.initialize(force_reinit=True, ctx=ctx, init=init.Xavier())
# seq(chess_board,9*19,200,decoder_inputs,weight,s,c)