Skip to content

Instantly share code, notes, and snippets.

import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.01
training_epochs = 1000
num_labels = 3
batch_size = 100
x1_label0 = np.random.normal(1, 1, (100, 1))
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.1
training_epochs = 2000
def sigmoid(x):
return 1. / (1. + np.exp(-x))
import numpy as np
import tensorflow as tf
import matplotlib.pyplot as plt
learning_rate = 0.01
training_epochs = 1000
x1 = np.random.normal(-4, 2, 1000)
x2 = np.random.normal(4, 2, 1000)
xs = np.append(x1, x2)
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
# 1-dimensional values.
# Numbers close to 5 will be given the label [0], and
# Numbers close to 2 will be given the label [1].
x_label0 = np.random.normal(5, 1, 10)
# outliers:
import math
size = 5
# ( 1 + (1/1!) + (1/2!) + (1/3!) + (1/4!) + (1/5!) + ......... + 1/i! )
_list = [(1 / math.factorial(i)) for i in range(size)]
e = sum(_list)
print(f"e={e}")
import sys
# Prompt the user to enter the number of students
numOfStudents = sys.stdin.readline()
print("number of students = " + numOfStudents)
maxScore = 0
topStudent = None
for i in range(int(numOfStudents)):
line = sys.stdin.readline()
@sithu
sithu / python_tests_dir_structure.md
Created March 18, 2020 04:49 — forked from tasdikrahman/python_tests_dir_structure.md
Typical Directory structure for python tests

A Typical directory structure for running tests using unittest

Ref : stackoverflow

The best solution in my opinion is to use the unittest [command line interface][1] which will add the directory to the sys.path so you don't have to (done in the TestLoader class).

For example for a directory structure like this:

new_project

├── antigravity.py

@sithu
sithu / simple-redux.js
Created March 5, 2018 22:12
Redux Example
const print = console.log;
const actions = [
{ type: 'ADD', value: 1 },
{ type: 'SUBTRACT', value: 2 },
{ type: 'ADD', value: 3 },
{ type: 'SUBTRACT', value: 4 },
{ type: 'ADD', value: 5 },
]
@sithu
sithu / UdpServer.kt
Created November 29, 2017 09:29 — forked from codingtim/UdpServer.kt
Simple udp server with netty 4.1 and kotlin
import io.netty.bootstrap.Bootstrap
import io.netty.channel.ChannelHandlerContext
import io.netty.channel.SimpleChannelInboundHandler
import io.netty.channel.nio.NioEventLoopGroup
import io.netty.channel.socket.nio.NioDatagramChannel
import io.netty.util.CharsetUtil
import io.netty.util.concurrent.DefaultThreadFactory
import kotlinx.coroutines.experimental.async
import kotlinx.coroutines.experimental.newFixedThreadPoolContext
@sithu
sithu / Ubuntu1604py36Dockerfile
Created September 29, 2017 05:51 — forked from monkut/Ubuntu1604py36Dockerfile
Base Docker image for ubuntu-16.04 & Python3.6
# docker build -t ubuntu1604py36
FROM ubuntu:16.04
RUN apt-get update
RUN apt-get install -y software-properties-common vim
RUN add-apt-repository ppa:jonathonf/python-3.6
RUN apt-get update
RUN apt-get install -y build-essential python3.6 python3.6-dev python3-pip python3.6-venv
RUN apt-get install -y git