Search is not available for this dataset
text
stringlengths 1.41k
102M
| id
stringlengths 22
24
| file_path
stringclasses 57
values |
---|---|---|
{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Aula 3 - Introdução ao Universo da Programação com Python - Professor Wendel Melo\n**Tópico: laços de repetição**"},{"metadata":{},"cell_type":"markdown","source":"# Laços de repetição\n\nEm muitos contextos, é comum a necessidade de executar um determinado bloco de instruções repetidamente. Para dar suporte a esse tipo de requisição, a linguagem Python nos fornece duas cláusulas para laços: **while** e **for**"},{"metadata":{},"cell_type":"markdown","source":"# Laço while\n\nA primeira forma geral do laço while é\n\nwhile <condição>:\n\n <instrução 1>\n <instrução 2>\n ...\n <instrução n>\n\n<primeira instrução pós while>\n\nA ideia é que o interpretador executa o bloco de instruções de 1 até n enquanto o teste <condição> for verdadeira. Desse modo, inicialmente <condição> é avaliada. Se <condição> resultar em Falso, o programa deve pular para a primeira instrução após o while. Se resultar em verdadeiro, o bloco de instruções de 1 até n é executado. Ao fim da execução do bloco, o programa deve retornar para a linha de cabeçalho do bloco e executar o teste <condição> novamente, repetindo toda a sistemática. Assim, se <condição> resultar em verdadeiro, o bloco será executado novamente e, após sua exeução, <condição> será novamente avaliada. Todo esse processo se repete até <condição> resultar em falso, ou o laço for interrompido por meio de uma instrução *break*. "},{"metadata":{"trusted":true},"cell_type":"code","source":"#Exemplo: imprimindo os primeiros 10 números naturais não nulos\n\nn = 1\nwhile n <= 10:\n print( n )\n n = n + 1","execution_count":2,"outputs":[{"output_type":"stream","text":"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n","name":"stdout"}]},{"metadata":{},"cell_type":"markdown","source":"**Ao utilizar um laço while, é bom se certificar que, em algum momento, <condição> resultará em falso, pois do contrário, você terá um laço infinito!**"},{"metadata":{},"cell_type":"markdown","source":"#exemplo de laço infinito"},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":4} | 0043/754/43754131.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n for filename in filenames:\n print(os.path.join(dirname, filename))\n\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":1,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"import tensorflow.compat.v1 as tf\nimport tensorflow.keras as keras","execution_count":2,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"tf.disable_eager_execution()","execution_count":3,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"mnist=keras.datasets.mnist.load_data()","execution_count":4,"outputs":[{"output_type":"stream","text":"Downloading data from https://storage.googleapis.com/tensorflow/tf-keras-datasets/mnist.npz\n11493376/11490434 [==============================] - 0s 0us/step\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"(x_train, y_train), (x_test, y_test)=mnist","execution_count":5,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# x_train=x_train.reshape(-1,28*28)\n# x_test=x_test.reshape(-1,28*28)","execution_count":6,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"# y_train = tf.keras.utils.to_categorical(y_train, 10)\n# y_test = tf.keras.utils.to_categorical(y_test, 10)","execution_count":7,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model=keras.Sequential([#keras.layers.Input(shape=(None,28,28,1)),\n keras.layers.Conv2D(32,(5,5),padding='same',strides=1,input_shape=(28,28,1)),\n keras.layers.MaxPooling2D(2),\n keras.layers.BatchNormalization(),\n keras.layers.Conv2D(64,(5,5),padding='same',strides=1),\n keras.layers.MaxPooling2D(2),\n keras.layers.Dropout(0.2),\n keras.layers.Flatten(),\n keras.layers.Dense(1024,activation='relu'),\n keras.layers.Dense(10,activation='softmax'),\n \n ])\n","execution_count":8,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"model.summary()","execution_count":9,"outputs":[{"output_type":"stream","text":"Model: \"sequential\"\n_________________________________________________________________\nLayer (type) Output Shape Param # \n=================================================================\nconv2d (Conv2D) (None, 28, 28, 32) 832 \n_________________________________________________________________\nmax_pooling2d (MaxPooling2D) (None, 14, 14, 32) 0 \n_________________________________________________________________\nbatch_normalization (BatchNo (None, 14, 14, 32) 128 \n_________________________________________________________________\nconv2d_1 (Conv2D) (None, 14, 14, 64) 51264 \n_________________________________________________________________\nmax_pooling2d_1 (MaxPooling2 (None, 7, 7, 64) 0 \n_________________________________________________________________\ndropout (Dropout) (None, 7, 7, 64) 0 \n_________________________________________________________________\nflatten (Flatten) (None, 3136) 0 \n_________________________________________________________________\ndense (Dense) (None, 1024) 3212288 \n_________________________________________________________________\ndense_1 (Dense) (None, 10) 10250 \n=================================================================\nTotal params: 3,274,762\nTrainable params: 3,274,698\nNon-trainable params: 64\n_________________________________________________________________\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"model.compile(loss='sparse_categorical_crossentropy',optimizer='adam',metrics=['accuracy'])","execution_count":10,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from tensorflow.keras import backend as K\nprint(K.image_data_format())","execution_count":11,"outputs":[{"output_type":"stream","text":"channels_last\n","name":"stdout"}]},{"metadata":{"trusted":true},"cell_type":"code","source":"x_np=x_train.reshape(-1,28,28,1)\nmodel.fit(x_np,y_train,epochs=5)","execution_count":12,"outputs":[{"output_type":"stream","text":"Train on 60000 samples\nEpoch 1/5\n60000/60000 [==============================] - 10s 166us/sample - loss: 0.2007 - accuracy: 0.9528\nEpoch 2/5\n60000/60000 [==============================] - 10s 172us/sample - loss: 0.0914 - accuracy: 0.9760\nEpoch 3/5\n60000/60000 [==============================] - 10s 167us/sample - loss: 0.0683 - accuracy: 0.9822\nEpoch 4/5\n60000/60000 [==============================] - 10s 167us/sample - loss: 0.0516 - accuracy: 0.9866\nEpoch 5/5\n60000/60000 [==============================] - 11s 188us/sample - loss: 0.0424 - accuracy: 0.9888\n","name":"stdout"},{"output_type":"execute_result","execution_count":12,"data":{"text/plain":"<tensorflow.python.keras.callbacks.History at 0x7f09f08c1090>"},"metadata":{}}]},{"metadata":{"trusted":true},"cell_type":"code","source":"x_re_test=x_test.reshape(-1,28,28,1)\nscore=model.evaluate(x_re_test,y_test)\nscore","execution_count":14,"outputs":[{"output_type":"execute_result","execution_count":14,"data":{"text/plain":"[0.051361694342092236, 0.9874]"},"metadata":{}}]},{"metadata":{"trusted":true},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"name":"python","version":"3.7.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":4} | 0043/754/43754262.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\"cells\":[{\"metadata\":{},\"cell_type\":\"markdown\",\"source\":\"# Первичный анал(...TRUNCATED) | 0043/754/43754580.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {\(...TRUNCATED) | 0043/754/43754712.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\n \"cells\": [\n {\n \"cell_type\": \"markdown\",\n \"metadata\": {\n \"papermill\": {\n (...TRUNCATED) | 0043/754/43754875.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {\(...TRUNCATED) | 0043/755/43755091.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\n \"cells\": [\n {\n \"attachments\": {\n \"2020_04_18_93081_1587195784._large.jpg\": {\n (...TRUNCATED) | 0043/755/43755763.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\"cells\":[{\"metadata\":{\"_uuid\":\"8f2839f25d086af736a60e9eeb907d3b93b6e0e5\",\"_cell_guid\":\"(...TRUNCATED) | 0043/755/43755906.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {\(...TRUNCATED) | 0043/756/43756003.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
"{\n \"cells\": [\n {\n \"cell_type\": \"code\",\n \"execution_count\": 1,\n \"metadata\": {\(...TRUNCATED) | 0043/756/43756263.ipynb | s3://data-agents/kaggle-outputs/sharded/033_00043.jsonl.gz |
End of preview. Expand
in Dataset Viewer.
README.md exists but content is empty.
- Downloads last month
- 5