Skip to content

Instantly share code, notes, and snippets.

View moggs2's full-sized avatar

moggs2

  • Germany
View GitHub Profile
def restructure(newlist, lookback):
total = np.shape(newlist)[0]
totalcolumns=np.shape(newlist)[1]
newarray=np.empty([total-(lookback-1), lookback, totalcolumns])
i=0
q=0
while i < total:
if i>=(lookback-1):
j=i-(lookback-1)
k=0
using DelimitedFiles
#using OrderedCollections
using Glob
function generateseries(length=140,readseries="dataseries.csv")
#newseries = rand(Int, (length, 1))
newseries=range(1,1,140)
newseries2=[1:1:length;]
#print(newseries)
@moggs2
moggs2 / custom_openai_stable_baselines_price_experiments.py
Last active January 31, 2023 19:13
Small Custom OpenAi program to start playing with prices and rewards. Stable Baselines3 is used for Deep Learning. It's compatible with A2C and DQN. Can be used with Google Colab.
import pandas as pd
import numpy as np
df =pd.DataFrame(np.random.randint(1,4,size=(1000, 6)), columns=list('ABCDEF'))
df.columns=['Date', 'Open', 'High', 'Low', 'Close', 'Volume']
import gym
from gym import spaces
import random
@moggs2
moggs2 / sketchdrawprocessingtf.py
Last active July 21, 2022 12:18
Loads Google Quick Draw dataset from tfrecord files and parses it. After it is modelled with tensorflow to predict the category. Only three sketches of 345 are used for prediction. But this can be changed easily.
import tensorflow as tf
import glob
import numpy as np
from PIL import Image, ImageDraw
import matplotlib.pyplot as plt
filenames = glob.glob('sketchesdata/training.tfrecord-*')
raw_dataset = tf.data.TFRecordDataset(filenames)
raw_dataset
@moggs2
moggs2 / choralesprocessing.py
Created June 23, 2022 10:01
Generating bach chorales with Tensorflow by giving the start.
import pandas as pd
import numpy as np
import tensorflow as tf
import glob
def preparedataset(thepath):
totalchorales=len(glob.glob(thepath))
newarray=np.zeros([totalchorales,3000])
i=0
@moggs2
moggs2 / tfrecord.py
Created June 8, 2022 09:48
Reading and processing Google QuickDraw Dataset in Tensorflow. Low memory usage. Using tfrecords files.
import tensorflow as tf
import glob
import numpy as np
from PIL import Image, ImageDraw
import matplotlib.pyplot as plt
def parse_function(tfrecorddata):
tf.io.parse_single_example(tfrecorddata,
{"ink": tf.io.VarLenFeature(dtype=tf.float32),
"shape": tf.io.FixedLenFeature([2], dtype=tf.int64),
import pandas as pd
import numpy as np
from random import random
import plotext as plt
import tensorflow as tf
newlist1=[]
newlist2=[]
newlisty=[]
import pandas as pd
import numpy as np
from random import random
import plotext as plt
import tensorflow as tf
newlist1=[]
newlist2=[]
newlisty=[]
@moggs2
moggs2 / tensorflowgenerator.py
Created May 22, 2022 15:16
Generates a sequence of numbers. At least one number must be given. Can be used for text generating.
import pandas as pd
import numpy as np
from random import random
import plotext as plt
import tensorflow as tf
newlist1=[]
newlisty=[]
@moggs2
moggs2 / tfflowers_classification.py
Created May 5, 2022 10:48
Classifies the tf_flowers dataset with the help of xception. All pictures used are saved after applying image manipulation. The wrong prediction are saved as well. The filename indicates what was predicted as what.
import tensorflow as tf
from pathlib import Path
import numpy as np
import pandas as pd
import tensorflow_datasets as tfds
import gc
#folderlist=[]
#
#photodir = Path('/root/flower_photos')