Computer Vision News - January 2019

25 Focus on Computer Vision News Finally, let’s see how you can use both tools together: In the following example we will evaluate a number of network architectures using Hyperas and preserve the outcomes of the evaluation in a systematic way for future reference, using comet.ml . When you run the code below and its run ends, you will be able to go online to the comet.ml website and see the run outcomes for each run, that is for each network configuration. ● Lines 1-11: Upload the modules ● Lines 13-20: Upload the data ● Line 23 defines the link to comet.ml ● Lines 26-43 define the model of the network to be trained, using scroll-quotes to define hyperparameter settings, ranges and configuration element alternatives to be evaluated using Hyperast -- Hyperas will run all combinations specified. ● Lines 46 to 58 call the functions for training the network; and to store parameters on comet.ml . ● Lines 66 to the end: This is the MAIN, which executes the entire code. 1. from __future__ import print_function 2. from comet_ml import Experiment 3. 4. import numpy as np 5. from hyperopt import Trials, STATUS_OK, tpe 6. from keras.datasets import mnist 7. from keras.layers.core import Dense, Dropout, Activation 8. from keras.models import Sequential 9. from keras.utils import np_utils 10. from hyperas import optim 11. from hyperas.distributions import choice, uniform 12. 13. def data(): 14. (x_train, y_train), (x_test, y_test) = mnist.load_data() 15. x_train = x_train.reshape( 60000 , 784 ) ; x_test = x_test.reshape( 10000 , 784 ) 16. x_train = x_train.astype( 'float32' ) ; x_test = x_test.astype( 'float32' ) 17. x_train /= 255 ; x_test /= 255 ; nb_classes = 10 18. y_train = np_utils.to_categorical(y_train, nb_classes) 19. y_test = np_utils.to_categorical(y_test, nb_classes) 20. return x_train, y_train, x_test, y_test 21. 22. def create_model(x_train, y_train, x_test , y_test ): 23. experiment = Experiment( api_key = "" , 24. project_name = "" , workspace = "" ) 25. 26. model = Sequential() 27. model.add(Dense( 512 , input_shape =( 784 ,))) 28. model.add(Activation( 'relu' )) 29. model.add(Dropout({{uniform( 0 , 1 )}})) Tip - Train Your Network

RkJQdWJsaXNoZXIy NTc3NzU=