Spaces:
Running
Running
Update pages/2_CodeSimulator.py
Browse files- pages/2_CodeSimulator.py +12 -1
pages/2_CodeSimulator.py
CHANGED
|
@@ -25,7 +25,18 @@ def execute_code(code):
|
|
| 25 |
st.title('PyTorch Code Runner')
|
| 26 |
|
| 27 |
# Text area for inputting the PyTorch code
|
| 28 |
-
code_input = st.text_area("Enter your PyTorch code here", height=300
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
|
| 30 |
# Button to execute the code
|
| 31 |
if st.button("Run Code"):
|
|
|
|
| 25 |
st.title('PyTorch Code Runner')
|
| 26 |
|
| 27 |
# Text area for inputting the PyTorch code
|
| 28 |
+
code_input = st.text_area("Enter your PyTorch code here", height=300, value="""# Create two tensors of different shapes
|
| 29 |
+
tensor_c = torch.tensor([1, 2, 3])
|
| 30 |
+
tensor_d = torch.tensor([[1], [2], [3]])
|
| 31 |
+
|
| 32 |
+
# Perform addition using broadcasting
|
| 33 |
+
tensor_broadcast_add = tensor_c + tensor_d
|
| 34 |
+
print("Broadcast Addition:\\n", tensor_broadcast_add)
|
| 35 |
+
|
| 36 |
+
# Perform element-wise multiplication using broadcasting
|
| 37 |
+
tensor_broadcast_mul = tensor_c * tensor_d
|
| 38 |
+
print("Broadcast Multiplication:\\n", tensor_broadcast_mul)
|
| 39 |
+
""")
|
| 40 |
|
| 41 |
# Button to execute the code
|
| 42 |
if st.button("Run Code"):
|