Skip to content

Instantly share code, notes, and snippets.

View Breta01's full-sized avatar
🤹
All over the place

Bretislav Hajek Breta01

🤹
All over the place
View GitHub Profile
@Breta01
Breta01 / Changes to the file: package.json
Created January 19, 2022 07:56
Following packages should be added to configure TypeScript with React
{
"dependencies": {
"@types/jest": "^27.0.3",
"@types/node": "^17.0.0",
"@types/react": "^17.0.37",
"@types/react-dom": "^17.0.11",
"typescript": "^4.5.4",
...
},
"scripts": {
@Breta01
Breta01 / deploy_dapp.yaml
Created January 9, 2022 01:50
Deploying your decentralized application to GitHub Pages
# This workflow will build 'client' folder, test and deploy to github pages on branch gh-pages
# For more information see:
# - https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
# - https://github.com/marketplace/actions/deploy-to-github-pages
name: Build and Deploy Frontend
on:
push:
branches: [ main ]
@Breta01
Breta01 / Example of ransomware in TensorFlow.py
Last active December 28, 2021 14:22
Example of ransomware in TensorFlow
# Version: 2.4.1
import tensorflow as tf
class MaliciousModule(tf.keras.Model):
def __init__(self):
super(MaliciousModule, self).__init__()
self.dense = tf.keras.layers.Dense(1, activation='sigmoid')
@tf.function
@Breta01
Breta01 / GANEstimator with Combine Adversarial Loss.py
Last active March 14, 2019 12:29
GANEstimator with Combine Adversarial Loss
def combined_loss(gan_model, **kwargs):
"""Wrapper function for combine adversarial loss, use as generator loss"""
# Define non-adversarial loss - for example L1
non_adversarial_loss = tf.losses.absolute_difference(
gan_model.real_data, gan_model.generated_data)
# Define generator loss
generator_loss = tf.contrib.gan.losses.least_squares_generator_loss(
gan_model,
**kwargs)
@Breta01
Breta01 / ImportModulesNotebook.ipynb
Last active October 22, 2020 09:02
Example of importing multiple TensorFlow modules
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Breta01
Breta01 / Multiple TF Graph Class.py
Last active July 20, 2020 09:19
Class for importing multiple TensorFlow graphs.
import tensorflow as tf
class ImportGraph():
""" Importing and running isolated TF graph """
def __init__(self, loc):
# Create local graph and use it in the session
self.graph = tf.Graph()
self.sess = tf.Session(graph=self.graph)
with self.graph.as_default():
# Import saved model from location 'loc' into local graph
@Breta01
Breta01 / Multiple TF Graph Class.py
Created April 15, 2017 20:13
Class for importing multiple TensorFlow graphs.
import tensorflow as tf
class Graph():
""" Importing and running isolated TF graph """
def __init__(self, loc):
# Create local graph and use it in the session
self.graph = tf.Graph()
self.sess = tf.Session(graph=self.graph)
with self.graph.as_default():
# Import saved model from location 'loc' into local graph
@Breta01
Breta01 / Importing TF model.py
Last active March 6, 2018 21:14
Importing and using TensorFlow graph (model)
sess = tf.Session()
# Import graph from the path and recover session
saver = tf.train.import_meta_graph('models/model_name.meta', clear_devices=True)
saver.restore(sess, 'models/model_name')
# There are TWO options how to access the operation (choose one)
# FROM SAVED COLLECTION:
activation = tf.get_collection('activation')[0]
# BY NAME:
@Breta01
Breta01 / SavingModelTF.py
Last active January 9, 2020 14:30
Code for creating, training and saving TensorFlow model.
import tensorflow as tf
### Linear Regression ###
# Input placeholders
x = tf.placeholder(tf.float32, name='x')
y = tf.placeholder(tf.float32, name='y')
# Model parameters
W1 = tf.Variable([0.1], tf.float32)
W2 = tf.Variable([0.1], tf.float32)
W3 = tf.Variable([0.1], tf.float32)
b = tf.Variable([0.1], tf.float32)
@Breta01
Breta01 / android_jupyter_install.sh
Last active December 19, 2018 08:59
Run clear GNURoot Debian, download android_jupyter_install.sh and run command: sh android_jupyter_install.sh
#!/bin/bash
# Update
apt-get update && apt-get upgrade -y
# Install python+packages and curl
apt-get install -y python3 python3-pip python3-numpy python3-scipy python3-matplotlib ipython3 ipython3-notebook python3-pandas python3-nose curl wget
# Update pip
python3 -m easy_install -U pip
# Correctinng python file
# which causes stuck during package installation