Skip to content

Commit

Permalink
add streamlit analytics
Browse files Browse the repository at this point in the history
  • Loading branch information
callummcdougall committed Aug 9, 2023
1 parent 8bf5659 commit 8c87a87
Show file tree
Hide file tree
Showing 27 changed files with 245 additions and 14 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ secrets.toml
*Grokking
*interp_on_model*.ipynb
*other_solns
*gitignore
*analytics.json
*gitignore
13 changes: 12 additions & 1 deletion chapter0_fundamentals/instructions/pages/01_[0.1]_Ray_Tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -1958,4 +1964,9 @@ def raytrace_mesh_lambert_wireframe(triangles: t.Tensor, rays: t.Tensor, triangl
""", unsafe_allow_html=True)

section_0()
section_0()

streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
5 changes: 0 additions & 5 deletions chapter0_fundamentals/instructions/pages/02_[0.2]_CNNs.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,8 @@ def section_0():
<img src="https://raw.githubusercontent.com/callummcdougall/Fundamentals/main/images/cnn.png" width="350">
## Introduction
This section is designed to get you familiar with basic neural networks: how they are structured, the basic operations like linear layers and convolutions which go into making them, and why they work as well as they do. You'll be using libraries like `einops`, and functions like `torch.as_strided` to get a very low-level picture of how these operations work, which will help build up your overall understanding.
Note that `torch.as_strided` isn't something which will come up explicitly in much of the rest of the course (unlike `einops`). The purpose of the stride exercises is more to give you an appreciation for what's going on under the hood, so that we can build layers of abstraction on top of that during the rest of this week (and by extension this course). I see this as analogous to how [many CS courses](https://cs50.harvard.edu/x/2023/) start by teaching you about languages like C and concepts like pointers and memory management before moving on to higher-level langauges like Python which abstract away these details. The hope is that when you get to the later sections of the course, you'll have the tools to understand them better.
Expand Down
12 changes: 12 additions & 0 deletions chapter0_fundamentals/instructions/pages/03_[0.3]_ResNets.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -2161,3 +2167,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
12 changes: 12 additions & 0 deletions chapter0_fundamentals/instructions/pages/04_[0.4]_Optimization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(
Expand Down Expand Up @@ -1874,3 +1880,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
12 changes: 12 additions & 0 deletions chapter0_fundamentals/instructions/pages/05_[0.5]_Backprop.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -3589,3 +3595,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
13 changes: 12 additions & 1 deletion chapter0_fundamentals/instructions/pages/99_🤖_Chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
sys.path.append(str(root_path))
sys.path.append(str(root_path.parent))

ANALYTICS_PATH = root_path / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

from chatbot import answer_question, Embedding, EmbeddingGroup

files = (root_path / "pages").glob("*.py")
Expand Down Expand Up @@ -172,4 +178,9 @@
# sort chronologically after top-k
# block signature

# %%


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -4060,3 +4066,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -3753,3 +3759,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -4449,3 +4455,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -2508,3 +2514,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -3265,3 +3271,8 @@ def page():
func()

page()

streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
11 changes: 11 additions & 0 deletions chapter1_transformers/instructions/pages/06_[1.6]_OthelloGPT.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -3184,3 +3190,8 @@ def page():
func()

page()

streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -1406,4 +1412,9 @@ def compute_dimensionality(
* [Open questions](https://transformer-circuits.pub/2022/toy_model/index.html#open-questions) from the original Anthropic paper. What do you think about them? Do any seem tractible to you?
""", unsafe_allow_html=True)

section_0()
section_0()

streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
14 changes: 13 additions & 1 deletion chapter1_transformers/instructions/pages/08_Reference_Page.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

st.sidebar.markdown(r"""
## Table of Contents
Expand Down Expand Up @@ -400,4 +406,10 @@ def forward(self, x):
Your workflow might use all three of these, e.g. working in VSCode using a combination of notebooks for exploratory analysis and Python files for writing functions that you'll import into your notebooks, then finally converting your notebooks to Colabs to publish your results.
""", unsafe_allow_html=True)
""", unsafe_allow_html=True)


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@
import platform
is_local = (platform.processor() != "")

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

def section_0_july():

st.sidebar.markdown(r"""
Expand Down Expand Up @@ -1307,3 +1313,9 @@ def page():
func()

page()


streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
13 changes: 12 additions & 1 deletion chapter1_transformers/instructions/pages/99_🤖_Chatbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
if str(instructions_dir) not in sys.path: sys.path.append(str(instructions_dir))
os.chdir(instructions_dir)

ANALYTICS_PATH = instructions_dir / "pages/analytics.json"
import streamlit_analytics
streamlit_analytics.start_tracking(
load_from_json=ANALYTICS_PATH.resolve(),
)

from chatbot import answer_question, Embedding, EmbeddingGroup

files = (instructions_dir / "pages").glob("*.py")
Expand Down Expand Up @@ -176,4 +182,9 @@
# sort chronologically after top-k
# block signature

# %%
# %%

streamlit_analytics.stop_tracking(
unsafe_password=st.secrets["analytics_password"],
save_to_json=ANALYTICS_PATH.resolve(),
)
1 change: 1 addition & 0 deletions chapter1_transformers/instructions/pages/analytics.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"loaded_from_firestore": false, "total_pageviews": 3, "total_script_runs": 11, "total_time_seconds": 128.336865, "per_day": {"days": ["2023-08-08", "2023-08-09"], "pageviews": [0, 3], "script_runs": [0, 11]}, "widgets": {}, "start_time": "09 Aug 2023, 17:43:29"}
Loading

0 comments on commit 8c87a87

Please sign in to comment.