python 2.7 - Converting theano tensor types -


I have a calculation graph created with the Thano, it happens in this way:

 < code> import from T importer as imported TNO, such as NPW1 = Nano. Shared (N.P.R.M.Rend (45,32). Staceype ('float32'), 'w1') b1 = thino. Shared (N.P.Randm.Rand (32). Stesip ('float32'), 'B1') W2 = Nano. Shared (N.P. Randem.Rand (32.3). Steppe 'Float32'), 'W2') B2 = Thino. Shared (Np.Rom.Rend (3) .stip ('float32'), 'b2') input = teamatics ('input') hidden = ttn (teadot (input, w1) + b1) Output = T.net Softmax (TDT (hidden, W2) + B2)   

Now, mapping from a vector is a vector, however, the input is set as a matrix type So, I can pass several vectors together with mapping. I'm learning some machines and it makes the learning phase more efficient.

The problem is that after the learning phase, I want to see the mapping vector in the form of a vector so that I can calculate:

  jac = theano.gradient. jacobian (output, wrt = input)   

jacobian complains that the input is not TensorType (float32, vector) . Is there any way that I can change the input tensor type without rebuilding the entire computing graph?

Technically, this is a possible solution:

  TNO import Import as TINO import as NAP w1 = theano.shared (np.random.rand (45,32). Sweetpe ('float32'), 'w1') b1 = theano.shared (np.random. ('Float32'), 'w2') b2 = theano. shared (np.random.rand (3). sweetpe ('float32'), 'b2') input = t. vector ('input') # will be made again! hidden = tt tn (tdt (input. Repp ((1, 45)), W1) + B1) Output = T.Nनेट.SoftMax (TD (Hidden, W2) + B2) # This driver is jac = theano.gradient.jacobian (output.rep ((- 1,)), wrt = input) .Upgrade ((1, 45, 3))   

jac.eval ({input: np.random.rand (10 * 45)}). Size result (100, 45, 3 ) The problem is that it calculates the derivative generated across the batch index, so in theory the first 1x45 number all 10x3 Output (in a length of 10 length) can affect

For this, there are many solutions. You can take a diagonal on the first two axes, but unfortunately,!

I think this can be done with scans , but this is another matter.

Comments

Popular posts from this blog

php - PDO bindParam() fatal error -

logging - How can I log both the Request.InputStream and Response.OutputStream traffic in my ASP.NET MVC3 Application for specific Actions? -

java - Why my included JSP file won't get processed correctly? -