Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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: |
This file contains hidden or 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): |
This file contains hidden or 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: |
This file contains hidden or 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 |
This file contains hidden or 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 |
This file contains hidden or 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 |
This file contains hidden or 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 |
This file contains hidden or 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 |
NewerOlder