zaterdag 21 november 2015

Blijven Bazelen ? Of naar Keras over?

Helaas, de bazel (niet basel - waar het icoontje van lijkt afgeleid) installatie lukt nog niet. Er moet een bepaalde Workspace worden ingericht met een (lege) WORKSPACE file en een BUILD file en java directories ... Ik kom er helaas nog niet uit. Daar gaat mijn Tensorflow LSTM testje. Helaas;

no such package '': BUILD file not found on package path.

Misschien later nog eens proberen.

Een ander interessant platform (voor LSTMs) lijkt Keras. De eerste voorbeeldcode ziet er wel erg eenvoudig uit:

from keras.models import Sequential from keras.layers.core import Dense, Dropout, Activation from keras.layers.embeddings import Embedding from keras.layers.recurrent import LSTM model = Sequential() model.add(Embedding(max_features, 256, input_length=maxlen)) model.add(LSTM(output_dim=128, activation='sigmoid', inner_activation='hard_sigmoid')) model.add(Dropout(0.5)) model.add(Dense(1)) model.add(Activation('sigmoid')) model.compile(loss='binary_crossentropy', optimizer='rmsprop') model.fit(X_train, Y_train, batch_size=16, nb_epoch=10score = model.evaluate(X_test, Y_test, batch_size=16)

Kijk daar kan ik misschien zelfs nog wel uitkomen. :-) Keras is (ook) gebaseerd op Theano en gebruikt (dus?) ook de mogelijkheden van de GPU. Met name voor LSTM's is dat blijkbaar ook wel heel erg zinvol. De installatie loopt op zich goed maar het pakket heeft ook wat andere afhankelijkheden. Numpy, Scipy, Pyyaml, Theano (optioneel ook HDF5 en h5py?? en cuDNN voor cnn's - convolutional neural networks) .
Van de 'verplichte afhankelijkheden had ik Pyyaml volgens mij nog niet.   "What It Is: YAML is a human friendly data serialization standard for all programming languages." Zelf vraagt het ook weer om libYaml, uit dezelfde bron. Ok, hij geeft wat warnings maar laten we maar eens kijken hoever we komen.

Uiteraard blijkt bovenstaande Keras code niet afdoende.  Al snel vraagt hij om 'max_features', een onbekende variabele. Ook de andere zijn niet gedefinieerd evenmin als de 'leerdata' X_train, Y_train) Ik zoek op internet naar een compleet voorbeeld en vindt een tekstgenerator op basis van teksten van Nietzsche.    In 'no time', nou ja ... na een lange tijd begint 'hij' bij elke iteratie 'voorbeeldteksten' te genereren. Leuk! Hij doet het! Nu nog 'even begrijpen' en dan mijn eigen data hopelijk los gaan laten.

...
--------------------------------------------------
Iteration 21
Epoch 1/1
200294/200294 [==============================] - 234s - loss: 1.0117     

----- diversity: 0.2
----- Generating with seed: "see what
these thing"
see what
these things with the same power, the most serve as the most servents of the sentiment of the same with a profoundest and desires and
distrustful and as a morality of all the present because of the present to a present that the strict serse of the senses, something of the soul who has the counterpreted and presents the conscience of the same something of the self-subtical strongte, the most disglist of the s
----- diversity: 0.5
----- Generating with seed: "see what
these thing"
see what
these things with a genius to the
self-subjection, his result, the desires of such a moral favility of the subject of every you and all the case of the higher and his his fauth as the conscience of say and one seems to memory the same conscience of religions which is the primordial sanntaitioms undifferent and surpossition, so that the influence of the present to a proposition of the soul, who has the way to
----- diversity: 1.0
----- Generating with seed: "see what
these thing"

see what ...

Geen opmerkingen:

Een reactie posten