diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..71422c4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.ipynb* diff --git a/Untitled.ipynb b/Untitled.ipynb new file mode 100644 index 0000000..5faa02a --- /dev/null +++ b/Untitled.ipynb @@ -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 +} diff --git a/test_gym.py b/test_gym.py new file mode 100644 index 0000000..4d3a2f0 --- /dev/null +++ b/test_gym.py @@ -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() diff --git a/test_gym_2.py b/test_gym_2.py new file mode 100644 index 0000000..73612f6 --- /dev/null +++ b/test_gym_2.py @@ -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() + diff --git a/test_gym_3.py b/test_gym_3.py new file mode 100644 index 0000000..6143944 --- /dev/null +++ b/test_gym_3.py @@ -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() + diff --git a/test_tensorflow_1.py b/test_tensorflow_1.py new file mode 100644 index 0000000..7d9e00e --- /dev/null +++ b/test_tensorflow_1.py @@ -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