View mnist_dropout.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View true_dropout.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TrueDropout(torch.nn.Module): | |
def __init__(self, p: float=0.5): | |
super(TrueDropout, self).__init__() | |
self.p = p | |
if self.p < 0 or self.p > 1: | |
raise ValueError("p must be a probability") | |
def forward(self, x): | |
if self.training: |
View mlp_mnist.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MNISTModel(torch.nn.Module): | |
def __init__(self): | |
super(MNISTModel, self).__init__() | |
self.layer_1 = nn.Linear(28 * 28, 512) | |
self.layer_2 = nn.Linear(512, 512) | |
self.layer_3 = nn.Linear(512, 10) | |
self.dropout = Dropout(.5) | |
def forward(self, x): |
View dropout_basic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Dropout(torch.nn.Module): | |
def __init__(self, p: float=0.5): | |
super(Dropout, self).__init__() | |
self.p = p | |
if self.p < 0 or self.p > 1: | |
raise ValueError("p must be a probability") | |
def forward(self, x): | |
if self.training: |
View Dockerfile.ui
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.8 | |
RUN mkdir /ui | |
COPY requirements.txt /ui | |
COPY . /ui | |
WORKDIR /ui | |
RUN apt-get update && apt-get install -y build-essential libapr1-dev libssl-dev openssh-client | |
# Install all necessary libraries into a pyenv environment |
View Dockerfile.api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.8 | |
# Setup the api directory for your project code | |
RUN mkdir /api | |
COPY . /api | |
COPY requirements.txt /api | |
WORKDIR /api | |
# Install all necessary libraries into a pyenv environment |
View ds-app-docker-compose.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.8' | |
services: | |
movie-app-api: | |
image: movie-app-api | |
ports: | |
- 8000:8000 | |
volumes: | |
- ./api:/api | |
networks: | |
- bridge_network |
View streamlit_app.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import streamlit as st | |
import requests | |
import json | |
url = "http://localhost:8000/review/predict" | |
# Write out the header for the page | |
st.write("# Movie Review Analyzer") | |
# Accept user text input |
View fast_api_post_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
from pydantic import BaseModel | |
# Initialize the FastAPI App | |
app = FastAPI() | |
# Create a Data Model so FastAPI can read the data from the request. | |
class Review(BaseModel): | |
text: str |
View sklearn_lambda_handler.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
import json | |
import os | |
import pickle | |
s3 = boto3.resource("s3") | |
BUCKET_NAME = "nic-sklearn-models" | |
NewerOlder