Giter Club home page Giter Club logo

artml_text_generation's Introduction

ArtML_text_generation

Simple implementation of the charbased LSTM used to generate text. Part of ML4Art / Art4ML class (link https://sites.google.com/site/artml2018/)

Installation:

  • Set up the prerequisites: Python 3, Keras, Tensoflow, Numpy

    • install Python 3
    • sudo apt-get install build-essential python-dev
    • sudo pip install tensorflow keras numpy

Use model:

  • train the model with train_model_on_file(txt_file, name, epochs, batch_size) (produces ".hdf5" files)
  • evaluate model with use_model(txt_file, model_file)
  • see codes in wonderland.py and twinpeaks.py for example usage

Example outputs:

Wonderland

model = wonderland-weights-41-1.2619-bigger.hdf5 (loss 1.2619)

seed = to show you! a little bright-eyed terrier, you know, with oh, such long curly brown hair! and it’ll be a large cat!

generated text = ‘i’m afraid i con’t know the sea,’ the ming raid to the jury, and alice was soon a pieht of the way the white rabbit, who was not a great heard a little walterss the whole parter of the gianter and the thoee gardeners, aut she was a little sather so coubers, and the thing said to herself, ‘i won’t the breatures out of this mouse- and what would be ouizes for to dome tp the matter would be all the caby, and she thought that it was anl reppled and she thought that it was all croken to doob that she was now a bot of the word in the way of expe, and was beginning to be a long way that she was now a bot of the word and was to the white rabbit, who was not a great heard a little was to the white rabbit, who was not a great heard a little was to the white rabbit, who was not a great heard a little was to the white rabbit, who was not a great heard a little was to the white rabbit, who was not a great heard a little was to the white rabbit, who was not a great heard a little

(it definitelly likes white rabbits... they appear in many generated fragments)

Twin Peaks

model = twinpeaks-weights-20-1.3289-bigger.hdf5 (loss 1.3289)

seed 1 = listically could be. laura comes to shelly in a panic. laura shelly, you really can hel

generated text 1 =

     l me the tereyour hand ie a gook the breat.    

			   laura
		       (to herself)
		io it is in the bork sight.  there is
		she siog of the bare of the bar wour here
		and here and i was whth the breat.

			   laura
		       (to herself)
		io it is in the bork sight.  there is
		she siog of the bare of the bar wour here
		and here and i was whth the breat.

			   laura
		       (to herself)
		io it is in the bork sight.  there is
		she siog of the bare of the bar wour here
		and here and i was whth the breat.

			   laura
		       (to herself)
		io it is in the bork sight.  there is
		she siog of the bare of the bar wour here
		and here and i was whth the breat.

			   laura
		       (to herself)
		io it is in the bork sight.  there is
		she siog of the bare of the bar wour here
		and here and i was whth the breat.`

seed 2 = wavy hair with a black full mustache to match, shiny silk shirt with silver strands sown in and and the pi

generated text 2 =

			   laura
		       (vm herself)
		the srart about the ban fornd and ie
		the riog of the fan and take to 			the ring of the fan and the way 			the doeat and the high ther wou
		the found about the srailer was 			the doeat.  i don't know wher is 			the ricture you ar a light of the 			srailer park.

			   laura
		       (vm herself)
		the srart about the ban fornd and ie
		the riog of the fan and take to 			the ring of the fan and the way 			the doeat and the high ther wou
		the found about the srailer was 			the doeat.  i don't know wher is 			the ricture you ar a light of the 			srailer park.

(Seems to be mimicking at least the same structure as in the input file - of a theatrical play. But often the generated content is nonsence... Laura is talking a lot to herself... I was hoping for some cryptic "Owls are not what they seem to be" to appear)

Links:

Tutorial https://machinelearningmastery.com/text-generation-lstm-recurrent-neural-networks-python-keras/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.