Commit f21231c6 authored by Rudolf Chrispens's avatar Rudolf Chrispens
Browse files

deadlock we have to rethink our structure with tutorial

parent 2a8ecec7
Loading
Loading
Loading
Loading
+123 −0
Original line number Diff line number Diff line
{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}"
        },
        {
            "name": "Python: START.py",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/start.py"
        },
        {
            "name": "Python: Attach",
            "type": "python",
            "request": "attach",
            "localRoot": "${workspaceFolder}",
            "remoteRoot": "${workspaceFolder}",
            "port": 3000,
            "secret": "my_secret",
            "host": "localhost"
        },
        {
            "name": "Python: Terminal (integrated)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal"
        },
        {
            "name": "Python: Terminal (external)",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "externalTerminal"
        },
        {
            "name": "Python: Django",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/manage.py",
            "args": [
                "runserver",
                "--noreload",
                "--nothreading"
            ],
            "debugOptions": [
                "RedirectOutput",
                "Django"
            ]
        },
        {
            "name": "Python: Flask (0.11.x or later)",
            "type": "python",
            "request": "launch",
            "module": "flask",
            "env": {
                "FLASK_APP": "${workspaceFolder}/app.py"
            },
            "args": [
                "run",
                "--no-debugger",
                "--no-reload"
            ]
        },
        {
            "name": "Python: Module",
            "type": "python",
            "request": "launch",
            "module": "module.name"
        },
        {
            "name": "Python: Pyramid",
            "type": "python",
            "request": "launch",
            "args": [
                "${workspaceFolder}/development.ini"
            ],
            "debugOptions": [
                "RedirectOutput",
                "Pyramid"
            ]
        },
        {
            "name": "Python: Watson",
            "type": "python",
            "request": "launch",
            "program": "${workspaceFolder}/console.py",
            "args": [
                "dev",
                "runserver",
                "--noreload=True"
            ]
        },
        {
            "name": "Python: All debug Options",
            "type": "python",
            "request": "launch",
            "pythonPath": "${config:python.pythonPath}",
            "program": "${file}",
            "module": "module.name",
            "env": {
                "VAR1": "1",
                "VAR2": "2"
            },
            "envFile": "${workspaceFolder}/.env",
            "args": [
                "arg1",
                "arg2"
            ],
            "debugOptions": [
                "RedirectOutput"
            ]
        }
    ]
}
 No newline at end of file
+2 −0
Original line number Diff line number Diff line
# reader init
from .basic_text_reader import basic_text_reader
from .basic_text_reader import get_words_as_int
from .basic_text_reader import get_integers_as_words
from .basic_masa_reader import basic_masa_reader
from .helper import get_input_data
from .helper import get_vocabulary
+35 −3
Original line number Diff line number Diff line
@@ -2,10 +2,11 @@

from lstm.configuration import current as config
import collections
import tensorflow as tf
import json as jsonlib
import os
from datetime import datetime
from lstm.Readers import helper
import tensorflow as tf

parent_folder_path = os.path.dirname(__file__) + "/.."
inputPath = parent_folder_path + config.path.input_folder_path
@@ -49,8 +50,11 @@ def read_input(filename):

'''
Create sequences and save them
example: [['You', 'can', 'see', 'a', 'cat', 'on', 'a', 'table', '<EOS>'], ['You', 'can', 'see', 'a', 'dog', 'on', 'a', 'table', '<EOS>']]
'''
example:
batches = [
    [['You', 'can', 'see', 'a', 'cat', '<EOS>'], ['You', 'can', 'see', 'a', 'dog', 'on', 'a', 'table', '<EOS>']]
    [['You', 'can', 'see', 'a', 'girafe', 'on', 'a', 'table', '<EOS>'], ['You', 'see', 'a', 'hotdog', '<EOS>']]
]'''
def create_sequences(filename):
    return True

@@ -92,3 +96,31 @@ def save_vocabulary(data, filename):
    if(config.reader.verbose):
        print("Reader:: Saved vocabulary at:", filename)
    print("[" + str(datetime.now().time()) + "]" + "Reader:: ...Finished saving vocabulary!")

'''
revert text input list [x, y, z]
to int list with vocab dict [23, 2342, 123]
'''
def get_words_as_int(sequence_list, filename):
    # print("Words to Integers")
    # print("input: ", sequence_list)
    vocab = helper.get_vocabulary(filename)
    # print("vocab: ", vocab)
    sequence = [vocab[word] for word in sequence_list if word in vocab]
    # print("output: ", sequence)
    return sequence

'''
revert int list of words [23,2342,123]
to string list with vocab dict [x, y, z]
'''
def get_integers_as_words(sequence_list, filename):
    # print("Integers to Words")
    # print("input: ", sequence_list)
    vocab = helper.get_vocabulary(filename)
    # print("vocab: ", vocab)
    id2word = {i: c for (c, i) in vocab.items()}
    # print("vocab rewersed: ", id2word)
    sequence = [id2word[integer_id] for integer_id in sequence_list if integer_id in id2word]
    # print("output: ", sequence)
    return sequence
+7 −4
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ class default_validator(object):

class default_trainer(object):
    train_on = True
    verbose = False
    padding = 0
    end_of_sentence = 1
    vocab_size = 10  # a word size
@@ -40,9 +41,10 @@ class default_trainer(object):
    decoder_hidden_units = encoder_hidden_units * 2
    max_batches = 2
    batches_in_epoch = 10
    batch_size = 10
    PAD = 0
    EOS = 1
    batch_size = 2
    sequence_size = 9
    PAD = ""
    EOS = '<EOS>'


'''
@@ -61,4 +63,5 @@ class current(default_reader, default_validator, default_trainer, default_paths)
    reader.reader_on = False
    reader.verbose = False
    validator.validator_on = False
    trainer.train_on = True
    trainer.train_on = False
    trainer.verbose = True
+1 −1
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ def batch(inputs, max_sequence_length=None):
    if max_sequence_length is None:
        max_sequence_length = max(sequence_lengths)

    inputs_batch_major = np.zeros(shape=[batch_size, max_sequence_length], dtype=np.int32) # == PAD
    inputs_batch_major = np.array([[None] * max_sequence_length] * batch_size)  # == PAD

    for i, seq in enumerate(inputs):
        for j, element in enumerate(seq):
Loading