Discussion:
[theano-users] About theano.function inside for loop
Chiu Chun Pang
2017-07-12 11:13:33 UTC
Permalink
for x in range(x_range):
for y in range(y_range):
t_test_set_x = theano_translation(test_set_x, x, y, borrow=True)
predict_model = theano.function(inputs=[index],
outputs=layer3.errors(y),
givens={layer0.input: t_test_set_x[index * 500: (index + 1) * 500],
y: test_set_y[index * 500: (index + 1) * 500]})
for batch_value in range(0, 20, 1):
temp_predicted_values = predict_model(batch_value)
predicted_values = temp_predicted_values + predicted_values


This is part of my source code. Now, the theano function is put inside 2 for loops. And my test set is updated in every loop. Is there anyway to put the
theano function outside the for loop so that i can speed up the computational process ?
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jesse Livezey
2017-07-12 19:59:48 UTC
Permalink
Yes, you should be able to just call theano.function(...) before the loops.
Post by Chiu Chun Pang
t_test_set_x = theano_translation(test_set_x, x, y, borrow=True)
predict_model = theano.function(inputs=[index],
outputs=layer3.errors(y),
givens={layer0.input: t_test_set_x[index * 500: (index + 1) * 500],
y: test_set_y[index * 500: (index + 1) * 500]})
temp_predicted_values = predict_model(batch_value)
predicted_values = temp_predicted_values + predicted_values
This is part of my source code. Now, the theano function is put inside 2 for loops. And my test set is updated in every loop. Is there anyway to put the
theano function outside the for loop so that i can speed up the computational process ?
--
---
You received this message because you are subscribed to the Google Groups "theano-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to theano-users+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...