I have a racing dataset of which each competitor has 155 features and there are 10 competitors per race. I have approximately 100000 races worth of data. I wish to predict the winner.
The X
dataset is 100000x1550 (by concatenating the 155 features). I want to tie the weights so that the same weights are applied to each competitor. The model that I have created is as follows:
n_features = 155
n_competitors = 10
init_1 = np.random.randn(n_features, 1)*np.sqrt(2/(1 + n_features))
with pm.Model() as linear_model:
w1 = pm.Normal('w1', 0, sd=1, shape=(n_features, 1), testval=init_1)
w1_repeat = pm.math.block_diagonal([w1]*n_competitors)
act_out = tt.nnet.softmax(tt.dot(X, w1_repeat))
out = pm.Categorical('out', act_out, observed=Y)
Y
is a one hot encoded, so that it’s size is 100000x10.
I’m getting the error:
IndexError: shape mismatch: indexing arrays could not be broadcast together with shapes (100000,) (100000,10)
The first question is, is there something I’m doing wrong? Especially with the block diagonal part (this is how I tie weights).
The second question is, how would I get the shape of a variable? w1_repeat.shape
simply spits out Shape.0
.
Incase some needs a test X and Y;
N = 100000
n_features = 155
X = np.random.rand(N, n_features*10)
Y = np.zeros((N,10))
Y[:,0] = 1