Format: application/octet-stream
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "id": "d5089f4c",
7 "metadata": {},
8 "outputs": [],
9 "source": [
10 "import tensorflow as tf"
11 ]
12 },
13 {
14 "cell_type": "code",
15 "execution_count": 2,
16 "id": "2d35ddfb",
17 "metadata": {},
18 "outputs": [],
19 "source": [
20 "#%tensorflow_version x.x"
21 ]
22 },
23 {
24 "cell_type": "code",
25 "execution_count": 3,
26 "id": "c3f6ddcb",
27 "metadata": {},
28 "outputs": [],
29 "source": [
30 "s= tf.Variable('abc')"
31 ]
32 },
33 {
34 "cell_type": "code",
35 "execution_count": 4,
36 "id": "969c3fe4",
37 "metadata": {},
38 "outputs": [],
39 "source": [
40 "import numpy as np\n",
41 "import sys"
42 ]
43 },
44 {
45 "cell_type": "code",
46 "execution_count": null,
47 "id": "a02b3d7b",
48 "metadata": {},
49 "outputs": [],
50 "source": []
51 },
52 {
53 "cell_type": "code",
54 "execution_count": 5,
55 "id": "c7387f28",
56 "metadata": {},
57 "outputs": [],
58 "source": [
59 "ar= tf.Variable([[1,2,3],[4,5,6],[7,5,6],[7,8,6]])\n",
60 "br= tf.Variable([['a','b'],['c','d']], tf.string)"
61 ]
62 },
63 {
64 "cell_type": "code",
65 "execution_count": 6,
66 "id": "46fc1da9",
67 "metadata": {},
68 "outputs": [
69 {
70 "data": {
71 "text/plain": [
72 "TensorShape([4, 3])"
73 ]
74 },
75 "execution_count": 6,
76 "metadata": {},
77 "output_type": "execute_result"
78 }
79 ],
80 "source": [
81 "ar.shape"
82 ]
83 },
84 {
85 "cell_type": "code",
86 "execution_count": 7,
87 "id": "7cb14a0f",
88 "metadata": {},
89 "outputs": [
90 {
91 "data": {
92 "text/plain": [
93 "TensorShape([2, 2])"
94 ]
95 },
96 "execution_count": 7,
97 "metadata": {},
98 "output_type": "execute_result"
99 }
100 ],
101 "source": [
102 "br.shape"
103 ]
104 },
105 {
106 "cell_type": "code",
107 "execution_count": null,
108 "id": "8175657a",
109 "metadata": {},
110 "outputs": [],
111 "source": []
112 },
113 {
114 "cell_type": "code",
115 "execution_count": 8,
116 "id": "45888d6a",
117 "metadata": {},
118 "outputs": [],
119 "source": [
120 "ones= tf.ones([2,4])"
121 ]
122 },
123 {
124 "cell_type": "code",
125 "execution_count": 9,
126 "id": "d9d2746a",
127 "metadata": {},
128 "outputs": [
129 {
130 "name": "stdout",
131 "output_type": "stream",
132 "text": [
133 "[0 1 2 ... 7 8 9]\r\n"
134 ]
135 }
136 ],
137 "source": [
138 "tensor = tf.range(10)\n",
139 "tf.print(tensor, output_stream=sys.stderr)"
140 ]
141 },
142 {
143 "cell_type": "code",
144 "execution_count": 10,
145 "id": "da15bac6",
146 "metadata": {},
147 "outputs": [
148 {
149 "name": "stdout",
150 "output_type": "stream",
151 "text": [
152 "[0 1 2 ... 7 8 9]\r\n"
153 ]
154 }
155 ],
156 "source": [
157 "tensor = tf.range(10)\n",
158 "tf.print(tensor)"
159 ]
160 },
161 {
162 "cell_type": "code",
163 "execution_count": 11,
164 "id": "ef636feb",
165 "metadata": {},
166 "outputs": [
167 {
168 "name": "stdout",
169 "output_type": "stream",
170 "text": [
171 "[0 1 2 ... 7 8 9]\r\n"
172 ]
173 }
174 ],
175 "source": [
176 "import tensorflow as tf\n",
177 "import sys\n",
178 "\n",
179 "tensor = tf.range(10)\n",
180 "tf.print(tensor, output_stream=sys.stderr)"
181 ]
182 },
183 {
184 "cell_type": "code",
185 "execution_count": 12,
186 "id": "d263b7d7",
187 "metadata": {},
188 "outputs": [],
189 "source": [
190 "arr= np.arange(1,31).reshape(-1,2,3)"
191 ]
192 },
193 {
194 "cell_type": "code",
195 "execution_count": 13,
196 "id": "6d428297",
197 "metadata": {},
198 "outputs": [],
199 "source": [
200 "tensor= tf.Variable(arr)"
201 ]
202 },
203 {
204 "cell_type": "code",
205 "execution_count": 14,
206 "id": "347a39a6",
207 "metadata": {},
208 "outputs": [
209 {
210 "name": "stdout",
211 "output_type": "stream",
212 "text": [
213 "array([[[ 1, 2, 3],\n",
214 " [ 4, 5, 6]],\n",
215 "\n",
216 " [[ 7, 8, 9],\n",
217 " [10, 11, 12]],\n",
218 "\n",
219 " [[13, 14, 15],\n",
220 " [16, 17, 18]],\n",
221 "\n",
222 " [[19, 20, 21],\n",
223 " [22, 23, 24]],\n",
224 "\n",
225 " [[25, 26, 27],\n",
226 " [28, 29, 30]]])\r\n"
227 ]
228 }
229 ],
230 "source": [
231 "tf.print(arr)"
232 ]
233 },
234 {
235 "cell_type": "code",
236 "execution_count": 20,
237 "id": "1c24f1b8",
238 "metadata": {},
239 "outputs": [
240 {
241 "data": {
242 "text/plain": [
243 "array([[ 9, 12],\n",
244 " [15, 18]])"
245 ]
246 },
247 "execution_count": 20,
248 "metadata": {},
249 "output_type": "execute_result"
250 }
251 ],
252 "source": [
253 "arr[1:3,:,-1]"
254 ]
255 },
256 {
257 "cell_type": "code",
258 "execution_count": null,
259 "id": "3dd62479",
260 "metadata": {},
261 "outputs": [],
262 "source": []
263 }
264 ],
265 "metadata": {
266 "kernelspec": {
267 "display_name": "Python 3",
268 "language": "python",
269 "name": "python3"
270 },
271 "language_info": {
272 "codemirror_mode": {
273 "name": "ipython",
274 "version": 3
275 },
276 "file_extension": ".py",
277 "mimetype": "text/x-python",
278 "name": "python",
279 "nbconvert_exporter": "python",
280 "pygments_lexer": "ipython3",
281 "version": "3.8.8"
282 }
283 },
284 "nbformat": 4,
285 "nbformat_minor": 5
286 }
287