Skip to content

Instantly share code, notes, and snippets.

@TheBojda
TheBojda / cartpole.py
Created December 9, 2019 08:09
Deep Q-learning CartPole example with OpenAI Gym and Tensorflow
# Deep Q-learning CartPole example
# based on https://github.com/gsurma/cartpole.git & https://gym.openai.com/evaluations/eval_OeUSZwUcR2qSAqMmOE1UIw/
import gym
import random
import numpy as np
from os import path
from collections import deque
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
@TheBojda
TheBojda / simplernn.py
Last active January 12, 2020 08:05
Tensorflow SimpleRNN example
import numpy as np
import tensorflow as tf
from tensorflow_core.python.keras import layers, models
text = "Hello World!"
input_text = text[:-1]
target_text = text[1:]
print(input_text)
print(target_text)
@TheBojda
TheBojda / minst_gan.py
Last active January 25, 2020 20:08
MINST GAN Example
# MINST GAN Example
# based on https://www.tensorflow.org/tutorials/generative/dcgan
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.keras import layers, models
import time
BUFFER_SIZE = 60000
BATCH_SIZE = 256
@TheBojda
TheBojda / minst_gan_batch_train.py
Created January 25, 2020 20:43
MINST GAN Example
# MINST GAN Example
# based on https://www.tensorflow.org/tutorials/generative/dcgan
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
from tensorflow.keras import layers, models
import time
BUFFER_SIZE = 60000
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>TensorFlow.js Tutorial</title>
<!-- Import TensorFlow.js -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.0.0/dist/tf.min.js"></script>
import {Cifar10} from './data.js';
async function load () {
const data = new Cifar10()
await data.load()
const [train_images, train_labels] = data.nextTrainBatch();
const [test_images, test_labels] = data.nextTestBatch();
console.log(train_images, train_labels, test_images, test_labels);
import {Cifar10} from './data.js';
async function load () {
const data = new Cifar10()
await data.load()
const model = await tf.loadLayersModel('./model/model.json');
//tfvis.show.modelSummary({name: 'Model Architecture'}, model);
const class_names = ['airplane', 'automobile', 'bird', 'cat', 'deer',
import React, { Component } from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
export default class App extends Component {
constructor() {
super()
this.state = {text: 'Hello World!'}
}
@TheBojda
TheBojda / todo_react.js
Created February 9, 2020 16:23
Simple TODO react native app
// Simple TODO react native app
// based on https://codeburst.io/todo-app-with-react-native-f889e97e398e
import React, { Component } from 'react';
import { StyleSheet, Text, View, FlatList, TextInput, Keyboard, Button } from 'react-native';
const isAndroid = Platform.OS == "android";
export default class App extends Component {
package org.tensorflow.lite.examples.digitclassifier
import android.content.Context
import android.content.res.AssetManager
import android.graphics.Bitmap
import android.util.Log
import com.google.android.gms.tasks.Task
import com.google.android.gms.tasks.Tasks.call
import java.io.FileInputStream
import java.io.IOException