Skip to content

Instantly share code, notes, and snippets.

View rish-16's full-sized avatar
🤖
backpropagating through memories

Rishabh Anand rish-16

🤖
backpropagating through memories
View GitHub Profile
@rish-16
rish-16 / CS2030S_week2.md
Created January 25, 2021 07:53
Notes from CS2030S Week 2

CS2030S Week 3 Lecture

Notes from Week 3 Lecture 1 on Object Oriented Programming

java.lang.Object class

  • Mother of all objects and classes
  • All classes implicitly inherit from the Object class

Polymorphism

Literally means "many forms" – allows us to decide and change already existing behaviour. At runtime, when methods are used for the polymorphed class, it'll call the methods that are specific to said object.

@rish-16
rish-16 / CS2040S_w2l2.md
Last active January 21, 2021 09:03
Notes from CS2040S Week 2 Lecture 2

CS2040S Week 2 Lecture 2

Notes from Week 2 Lecture 2 on Data Structures and Algorithms.

Problem Solving

Peak Finding

Aim is to find the global maximum and ignore local maxima.

inputs: Array A[0 ... n-1]
output: Maximum element in A
@rish-16
rish-16 / CS2040S_w2l1.md
Last active January 21, 2021 09:00
Notes on CS2040S from Week 2 Lecture 1

CS2040S Week 2 Lecture 1

Notes from Week 2 on Data Structures and Algorithms.

Miscellaneous

  • Midterm Exam: Week 7

Algorithm Analysis

Time Complexity Analysis

As we scale, we want to see which algorithms are faster for large inputs ie. asymptotic performance. T(n) is the running time of an algorithm.

@rish-16
rish-16 / CS2030S_week2.md
Last active January 19, 2021 09:52
Notes on CS2030S for Week 2

CS2030S Week 2

Abstraction Barrier

Something that stands between the client/user and implementation. The implementer declares the variables and methods and the user uses this implementation object via abstraction (only public things can be accessed). This protects the internal state attributes from the user.

Information Hiding

Information Hiding enables implementers to make changes within the class without affecting the user much. The user continues to use the class object the same way but the internal implementation might have changed.

In Python, there are no access control rules. However, Java provides mechanisms to the compiler to enforce access control. We can add modifiers to variables and methods:

@rish-16
rish-16 / CS2040S_w1l2.md
Last active January 21, 2021 09:00
Notes on CS2040S from Week 1 Lecture 2

CS2040S Week 1 Lecture 2

Notes from Week 1 on Data Structures and Algorithms.

Not covered

  • Lambda expressions
  • Type inference
  • Packages

Basics of OOP

Programming paradigms

@rish-16
rish-16 / deployment.md
Last active January 12, 2021 07:54
Flask API deployment instructions on repl.it

Deploying on repl.it

  1. Visit repl.it
  2. Click on any of the 3 servers, rhapp_facilities, rhapp_events, or rhapp_laundry
  3. Add changes to document
  4. Click the Stop button at the top
  5. Click the Run button at the top – a browser-like window should open with the default endpoint loaded
  6. Test installation by pinging the endpoints with Postman (your repl.it window should show 200 codes in the console)

Important Notes

# Select appropriate distribution strategy
if tpu:
tf.tpu.experimental.initialize_tpu_system(tpu)
strategy = tf.distribute.experimental.TPUStrategy(tpu, steps_per_run=128)
print('Running on TPU ', tpu.cluster_spec().as_dict()['worker'])
else:
strategy = tf.distribute.get_strategy() # Default strategy that works on CPU and single GPU
print('Running on CPU instead')
print("Number of accelerators: ", strategy.num_replicas_in_sync)
# Detect hardware
try:
tpu = tf.distribute.cluster_resolver.TPUClusterResolver() # TPU detection
except ValueError: # If TPU not found
tpu = None
history = model.fit(x_train,
y_train,
epochs=20,
steps_per_epoch=50
)
model.save_weights('./mnist_model.h5', overwrite=True)
with strategy.scope():
"""
This essentailly takes our model and makes it
compatible to train on a TPU.
"""
model = tf.keras.models.Sequential()
model.add(tf.keras.layers.Dense(512, input_size=[784,], activation='relu'))
model.add(tf.keras.layers.Dense(256, activation='relu'))
model.add(tf.keras.layers.Dense(128, activation='relu'))
model.add(tf.keras.layers.Dense(64, activation='relu'))