Skip to content

Instantly share code, notes, and snippets.

View PyDataBlog's full-sized avatar
🥷
Code with purpose

Bernard Brenyah PyDataBlog

🥷
Code with purpose
View GitHub Profile
#!/bin/bash
# Function which takes a namespace, and waits until ip is assigned to it.
function wait_for_ip() {
namespace=$1
echo "Waiting for IP for namespace: $namespace"
while [ -z $ip ]; do
ip=$(kubectl get ingress -n $namespace -o jsonpath="{.items[*].status.loadBalancer.ingress[*].ip}")
[ -z "$ip" ]
done
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
namespace: ingress-demo
spec:
replicas: 10
selector:
matchLabels:
app: myapp
apiVersion: v1
kind: Service
metadata:
name: hello-svc
namespace: ingress-demo
spec:
selector:
app: myapp
ports:
- port: 8080
apiVersion: v1
kind: Namespace
metadata:
name: ingress-demo
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
name: hello-world-ingress
namespace: ingress-demo
labels:
name: hello-world-ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
name: dashboard-ingress
namespace: kubernetes-dashboard
labels:
name: dashboard-ingress
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
name: logs-ingress
namespace: kube-system
labels:
name: logs-ingress
cost = [10, 10, 10, 10, 1, 1, 1]
function count_no_improvements(x)
counter = 0
for i in 1:size(x, 1)
if (i > 1) && abs(x[i] - x[i-1]) < (1e-6 * x[i])
counter += 1
else
counter = 0
using Plots
using MLJBase
using StableRNGs # Seeding generator for reproducibility
# Generate fake data
X, y = make_blobs(10_000, 3; centers=2, as_table=false, rng=2020);
X = Matrix(X');
y = reshape(y, (1, size(X, 2)));
f(x) = x == 2 ? 0 : x
y2 = f.(y);
"""
Train the network using the desired architecture that best possible
matches the training inputs (DMatrix) and their corresponding ouptuts(Y)
over some number of iterations (epochs) and a learning rate (η).
"""
function train_network(layer_dims , DMatrix, Y; η=0.001, epochs=1000, seed=2020, verbose=true)
# Initiate an empty container for cost, iterations, and accuracy at each iteration
costs = []
iters = []
accuracy = []