Skip to content

Commit

Permalink
chore: small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Valdes committed Dec 23, 2024
0 parents commit 7485470
Show file tree
Hide file tree
Showing 6 changed files with 156 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.ipynb*
81 changes: 81 additions & 0 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "02d39a02-17f2-4307-8d41-6903c289e9d2",
"metadata": {},
"outputs": [],
"source": [
"import tensorflow as tf"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "793e06aa-0230-433f-a92a-6c32846bc444",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"()\n"
]
}
],
"source": [
"a = tf.constant(1)\n",
"print(a.shape)\n"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "4ea11dda-ab38-4e21-97e4-c318c0790ec7",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"(5,)\n"
]
}
],
"source": [
"b = tf.constant([1,2,3,4,5])\n",
"print(b.shape)\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a3394f67-a3fc-4c26-887e-70c315703d65",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python (gym-env-py3.10)",
"language": "python",
"name": "gym-env-py3.10"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.16"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
10 changes: 10 additions & 0 deletions test_gym.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import gymnasium as gym

env = gym.make("CartPole-v1", render_mode="human")
env.reset()

for i in range(200):
env.step(env.action_space.sample())
env.render()

env.close()
22 changes: 22 additions & 0 deletions test_gym_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import gymnasium as gym

env = gym.make("CartPole-v1", render_mode="human")
env.reset()

for i in range(100):
done = False
game_rew = 0

while not done:
action = env.action_space.sample()
obs, rew, terminated, truncated, info = env.step(action)
game_rew += rew

# Combine `terminated` (episode ended in a terminal state)
# and `truncated` (time limit or another truncation condition)
done = terminated or truncated

if done:
print(f"Episode {i} finished, reward: {game_rew}")
env.reset()

30 changes: 30 additions & 0 deletions test_gym_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import gymnasium as gym


env = gym.make("CartPole-v1", render_mode="human")
print(env.observation_space)
print(env.action_space)
print(env.action_space.sample())
print(env.action_space.sample())
print(env.observation_space.low)
print(env.observation_space.high)

env.reset()

for i in range(100):
done = False
game_rew = 0

while not done:
action = env.action_space.sample()
obs, rew, terminated, truncated, info = env.step(action)
game_rew += rew

# Combine `terminated` (episode ended in a terminal state)
# and `truncated` (time limit or another truncation condition)
done = terminated or truncated

if done:
print(f"Episode {i} finished, reward: {game_rew}")
env.reset()

12 changes: 12 additions & 0 deletions test_tensorflow_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import tensorflow as tf

# Create two constants: a and b
a = tf.constant(4)
b = tf.constant(3)

# Perform a computation
c = a + b

# In TensorFlow 2.x, eager execution is enabled by default,
# so you can directly inspect the result.
print(c.numpy()) # This should print 7

0 comments on commit 7485470

Please sign in to comment.