From c8215306ed17709b55079362d432a9dda9d61fa6 Mon Sep 17 00:00:00 2001 From: nglk Date: Thu, 27 Oct 2022 14:00:57 +0200 Subject: [PATCH] type input in the pin manipulate --- .ipynb_checkpoints/a_tune_in-checkpoint.ipynb | 166 +++++++----------- a_tune_in.ipynb | 166 +++++++----------- 2 files changed, 118 insertions(+), 214 deletions(-) diff --git a/.ipynb_checkpoints/a_tune_in-checkpoint.ipynb b/.ipynb_checkpoints/a_tune_in-checkpoint.ipynb index 003f29f..a7a3654 100644 --- a/.ipynb_checkpoints/a_tune_in-checkpoint.ipynb +++ b/.ipynb_checkpoints/a_tune_in-checkpoint.ipynb @@ -14,7 +14,7 @@ "\n", "## Pincelate\n", "\n", - "[Pincelate](https://pypi.org/project/pincelate/) is a machine learning model for spelling English words and sounding them out developed by artist [Allison Parrish](https://www.decontextualize.com/). It relies on particular versions of the Google-funded pre-trained machine learning models in [Tensorflow](https://www.tensorflow.org/) and the deep-learning API [Keras](https://keras.io/).\n", + "[Pincelate](https://pypi.org/project/pincelate/) is a machine learning model for spelling English words and sounding them out developed by artist [Allison Parrish](https://www.decontextualize.com/). It relies on particular versions of the Google-funded pre-trained machine learning models in [Tensorflow](https://www.tensorflow.org/) and the deep-learning API [Keras](https://keras.io/). If you are interested to see more ways to work with Pincelate, Parrish created a series of tutorials: [https://github.com/aparrish/nonsense-verse-pycon-2020](https://github.com/aparrish/nonsense-verse-pycon-2020).\n", "\n", "\n", "### Installing Pincelate" @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "ranking-bottom", "metadata": { "scrolled": false @@ -33,92 +33,53 @@ "output_type": "stream", "text": [ "Requirement already satisfied: tensorflow==1.15.5 in ./pocket/lib/python3.6/site-packages (1.15.5)\n", - "Requirement already satisfied: numpy<1.19.0,>=1.16.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.18.5)\n", - "Requirement already satisfied: termcolor>=1.1.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.0)\n", - "Requirement already satisfied: google-pasta>=0.1.6 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.2.0)\n", "Requirement already satisfied: protobuf>=3.6.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (3.19.6)\n", - "Requirement already satisfied: wrapt>=1.11.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.14.1)\n", - "Requirement already satisfied: keras-preprocessing>=1.0.5 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.2)\n", - "Requirement already satisfied: six>=1.10.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.16.0)\n", + "Requirement already satisfied: opt-einsum>=2.3.2 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (3.3.0)\n", + "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.0.8)\n", + "Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.15.0)\n", "Requirement already satisfied: tensorflow-estimator==1.15.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.15.1)\n", - "Requirement already satisfied: absl-py>=0.7.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.3.0)\n", + "Requirement already satisfied: termcolor>=1.1.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.0)\n", + "Requirement already satisfied: astor>=0.6.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.8.1)\n", "Requirement already satisfied: h5py<=2.10.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (2.10.0)\n", - "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.0.8)\n", + "Requirement already satisfied: wrapt>=1.11.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.14.1)\n", "Requirement already satisfied: gast==0.2.2 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.2.2)\n", - "Requirement already satisfied: wheel>=0.26 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.37.1)\n", + "Requirement already satisfied: six>=1.10.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.16.0)\n", + "Requirement already satisfied: numpy<1.19.0,>=1.16.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.18.5)\n", "Requirement already satisfied: grpcio>=1.8.6 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.48.2)\n", - "Requirement already satisfied: opt-einsum>=2.3.2 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (3.3.0)\n", - "Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.15.0)\n", - "Requirement already satisfied: astor>=0.6.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.8.1)\n", + "Requirement already satisfied: google-pasta>=0.1.6 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.2.0)\n", + "Requirement already satisfied: keras-preprocessing>=1.0.5 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.2)\n", + "Requirement already satisfied: wheel>=0.26 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.37.1)\n", + "Requirement already satisfied: absl-py>=0.7.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.3.0)\n", "Requirement already satisfied: setuptools>=41.0.0 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (59.6.0)\n", - "Requirement already satisfied: markdown>=2.6.8 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (3.3.7)\n", "Requirement already satisfied: werkzeug>=0.11.15 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (2.0.3)\n", + "Requirement already satisfied: markdown>=2.6.8 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (3.3.7)\n", "Requirement already satisfied: importlib-metadata>=4.4 in ./pocket/lib/python3.6/site-packages (from markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (4.8.3)\n", "Requirement already satisfied: dataclasses in ./pocket/lib/python3.6/site-packages (from werkzeug>=0.11.15->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (0.8)\n", "Requirement already satisfied: typing-extensions>=3.6.4 in ./pocket/lib/python3.6/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (4.1.1)\n", "Requirement already satisfied: zipp>=0.5 in ./pocket/lib/python3.6/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (3.6.0)\n", "Requirement already satisfied: keras==2.2.5 in ./pocket/lib/python3.6/site-packages (2.2.5)\n", - "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.0.8)\n", "Requirement already satisfied: scipy>=0.14 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.5.4)\n", "Requirement already satisfied: keras-preprocessing>=1.1.0 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.1.2)\n", "Requirement already satisfied: six>=1.9.0 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.16.0)\n", - "Requirement already satisfied: h5py in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (2.10.0)\n", - "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.18.5)\n", "Requirement already satisfied: pyyaml in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (6.0)\n", + "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.18.5)\n", + "Requirement already satisfied: h5py in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (2.10.0)\n", + "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.0.8)\n", "Requirement already satisfied: pincelate in ./pocket/lib/python3.6/site-packages (0.0.1)\n", + "Requirement already satisfied: scikit-learn>=0.20.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (0.24.2)\n", "Requirement already satisfied: Keras>=2.2.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (2.2.5)\n", "Requirement already satisfied: pronouncing>=0.2.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (0.2.0)\n", - "Requirement already satisfied: scikit-learn>=0.20.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (0.24.2)\n", + "Requirement already satisfied: six>=1.9.0 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.16.0)\n", "Requirement already satisfied: h5py in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (2.10.0)\n", - "Requirement already satisfied: scipy>=0.14 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.5.4)\n", - "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.18.5)\n", "Requirement already satisfied: keras-preprocessing>=1.1.0 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.1.2)\n", - "Requirement already satisfied: pyyaml in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (6.0)\n", "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.0.8)\n", - "Requirement already satisfied: six>=1.9.0 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.16.0)\n", + "Requirement already satisfied: pyyaml in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (6.0)\n", + "Requirement already satisfied: scipy>=0.14 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.5.4)\n", + "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.18.5)\n", "Requirement already satisfied: cmudict>=0.4.0 in ./pocket/lib/python3.6/site-packages (from pronouncing>=0.2.0->pincelate) (1.0.2)\n", "Requirement already satisfied: joblib>=0.11 in ./pocket/lib/python3.6/site-packages (from scikit-learn>=0.20.0->pincelate) (1.1.1)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in ./pocket/lib/python3.6/site-packages (from scikit-learn>=0.20.0->pincelate) (3.1.0)\n" ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Using TensorFlow backend.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:541: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:66: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:4432: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:148: The name tf.placeholder_with_default is deprecated. Please use tf.compat.v1.placeholder_with_default instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3733: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n", - "Instructions for updating:\n", - "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3239: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n", - "Instructions for updating:\n", - "Use tf.where in 2.0, which has the same broadcast rule as np.where\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:190: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:197: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:203: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:207: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:216: The name tf.is_variable_initialized is deprecated. Please use tf.compat.v1.is_variable_initialized instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:223: The name tf.variables_initializer is deprecated. Please use tf.compat.v1.variables_initializer instead.\n", - "\n" - ] } ], "source": [ @@ -138,6 +99,8 @@ "id": "9f1e2cc7", "metadata": {}, "source": [ + "### Respelling\n", + "\n", "This is how Parrish describes the *manipulate* function of Pincelate: \"Pincelate actually consists of two models: one that knows how to sound out words based on how they're spelled, and another that knows how to spell words from sounds.\"\n", "\n", "With this function, words are passing through the two models, taking words, sounding them out from their spelling and then bringing them back into writing via phonemes. As a way to situate ourselves into the conference, we propose to take the conference titles as material to reshape, contort, or respell. \n", @@ -175,46 +138,48 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "muslim-labor", "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "'arcsvtinex'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "what is your word? Archives\n", + "temperature value? 2\n" + ] + }, + { + "ename": "TypeError", + "evalue": "ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mwor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'what is your word? '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mtemp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'temperature value? '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mpin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmanipulate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mtemperature\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtemp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/__init__.py\u001b[0m in \u001b[0;36mmanipulate\u001b[0;34m(self, s, letters, features, temperature)\u001b[0m\n\u001b[1;32m 444\u001b[0m )\n\u001b[1;32m 445\u001b[0m orth_seq = [self.phon2orth.to_target_vocab(item, 1)[0][0]\n\u001b[0;32m--> 446\u001b[0;31m for item in orth_decoding]\n\u001b[0m\u001b[1;32m 447\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 448\u001b[0m \u001b[0;31m# trim start/end tokens\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 443\u001b[0m x ** np.exp(orth_exps), temperature)\n\u001b[1;32m 444\u001b[0m )\n\u001b[0;32m--> 445\u001b[0;31m orth_seq = [self.phon2orth.to_target_vocab(item, 1)[0][0]\n\u001b[0m\u001b[1;32m 446\u001b[0m for item in orth_decoding]\n\u001b[1;32m 447\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/seq2seq.py\u001b[0m in \u001b[0;36mdecode_sequence\u001b[0;34m(self, state_value, target_seq, transform, maxlen)\u001b[0m\n\u001b[1;32m 234\u001b[0m \"\"\"\n\u001b[1;32m 235\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 236\u001b[0;31m \u001b[0;32myield\u001b[0m \u001b[0mtransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtarget_seq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 237\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmaxlen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 238\u001b[0m output, h = self.infer_decoder_model.predict(\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 441\u001b[0m \u001b[0;31m# orthography inference manipulation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 442\u001b[0m transform=lambda x: softmax_temperature(\n\u001b[0;32m--> 443\u001b[0;31m x ** np.exp(orth_exps), temperature)\n\u001b[0m\u001b[1;32m 444\u001b[0m )\n\u001b[1;32m 445\u001b[0m orth_seq = [self.phon2orth.to_target_vocab(item, 1)[0][0]\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/seq2seq.py\u001b[0m in \u001b[0;36msoftmax_temperature\u001b[0;34m(t, temp)\u001b[0m\n\u001b[1;32m 301\u001b[0m \u001b[0mzeros\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 302\u001b[0m \u001b[0mdist\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mastype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m0.0001\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 303\u001b[0;31m \u001b[0mpred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdist\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mtemp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 304\u001b[0m \u001b[0mexp_pred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 305\u001b[0m \u001b[0mpred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexp_pred\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexp_pred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''" + ] } ], "source": [ - "pin.manipulate(\"archives\",temperature=2)" + "wor = input('what is your word? ')\n", + "temp = input('temperature value? ')\n", + "\n", + "pin.manipulate(wor.lower(),temperature = int(temp))" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "b648b5ae", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "52dbe8b1e0bb4ea9b0276e6902fce2b8", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(Text(value='any one future died', description='s'), FloatSlider(value=1.2500000000000002…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "@interact(s=\"any one future died\",temp=(0.05,2.5,0.05))\n", "def tempadjust(s,temp):\n", @@ -247,7 +212,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "id": "2e25f0db", "metadata": {}, "outputs": [], @@ -261,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "id": "189c5b06", "metadata": {}, "outputs": [], @@ -298,28 +263,15 @@ "\tfor word in dictionary:\n", "\t\tif word in new_sentence:\n", "\t\t\tnew_sentence = new_sentence.replace(word, random.choice(dictionary[word]['paradoxes']))\n", - "\tprint(new_sentence)\n", - "\n" + "\tprint(new_sentence)" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "b1dde66a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "what are your words? fdkhggfe futures\n", - "choose replacing method between \"paranyms\",\"parameanings\",\"paradoxes\",\"all\": all\n", - "fdkhggfe \n", - "fdkhggfe \n", - "fdkhggfe \n" - ] - } - ], + "outputs": [], "source": [ "\n", "sentence = input('what are your words? ')\n", diff --git a/a_tune_in.ipynb b/a_tune_in.ipynb index 003f29f..a7a3654 100644 --- a/a_tune_in.ipynb +++ b/a_tune_in.ipynb @@ -14,7 +14,7 @@ "\n", "## Pincelate\n", "\n", - "[Pincelate](https://pypi.org/project/pincelate/) is a machine learning model for spelling English words and sounding them out developed by artist [Allison Parrish](https://www.decontextualize.com/). It relies on particular versions of the Google-funded pre-trained machine learning models in [Tensorflow](https://www.tensorflow.org/) and the deep-learning API [Keras](https://keras.io/).\n", + "[Pincelate](https://pypi.org/project/pincelate/) is a machine learning model for spelling English words and sounding them out developed by artist [Allison Parrish](https://www.decontextualize.com/). It relies on particular versions of the Google-funded pre-trained machine learning models in [Tensorflow](https://www.tensorflow.org/) and the deep-learning API [Keras](https://keras.io/). If you are interested to see more ways to work with Pincelate, Parrish created a series of tutorials: [https://github.com/aparrish/nonsense-verse-pycon-2020](https://github.com/aparrish/nonsense-verse-pycon-2020).\n", "\n", "\n", "### Installing Pincelate" @@ -22,7 +22,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 3, "id": "ranking-bottom", "metadata": { "scrolled": false @@ -33,92 +33,53 @@ "output_type": "stream", "text": [ "Requirement already satisfied: tensorflow==1.15.5 in ./pocket/lib/python3.6/site-packages (1.15.5)\n", - "Requirement already satisfied: numpy<1.19.0,>=1.16.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.18.5)\n", - "Requirement already satisfied: termcolor>=1.1.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.0)\n", - "Requirement already satisfied: google-pasta>=0.1.6 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.2.0)\n", "Requirement already satisfied: protobuf>=3.6.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (3.19.6)\n", - "Requirement already satisfied: wrapt>=1.11.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.14.1)\n", - "Requirement already satisfied: keras-preprocessing>=1.0.5 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.2)\n", - "Requirement already satisfied: six>=1.10.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.16.0)\n", + "Requirement already satisfied: opt-einsum>=2.3.2 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (3.3.0)\n", + "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.0.8)\n", + "Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.15.0)\n", "Requirement already satisfied: tensorflow-estimator==1.15.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.15.1)\n", - "Requirement already satisfied: absl-py>=0.7.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.3.0)\n", + "Requirement already satisfied: termcolor>=1.1.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.0)\n", + "Requirement already satisfied: astor>=0.6.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.8.1)\n", "Requirement already satisfied: h5py<=2.10.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (2.10.0)\n", - "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.0.8)\n", + "Requirement already satisfied: wrapt>=1.11.1 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.14.1)\n", "Requirement already satisfied: gast==0.2.2 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.2.2)\n", - "Requirement already satisfied: wheel>=0.26 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.37.1)\n", + "Requirement already satisfied: six>=1.10.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.16.0)\n", + "Requirement already satisfied: numpy<1.19.0,>=1.16.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.18.5)\n", "Requirement already satisfied: grpcio>=1.8.6 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.48.2)\n", - "Requirement already satisfied: opt-einsum>=2.3.2 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (3.3.0)\n", - "Requirement already satisfied: tensorboard<1.16.0,>=1.15.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.15.0)\n", - "Requirement already satisfied: astor>=0.6.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.8.1)\n", + "Requirement already satisfied: google-pasta>=0.1.6 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.2.0)\n", + "Requirement already satisfied: keras-preprocessing>=1.0.5 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.1.2)\n", + "Requirement already satisfied: wheel>=0.26 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (0.37.1)\n", + "Requirement already satisfied: absl-py>=0.7.0 in ./pocket/lib/python3.6/site-packages (from tensorflow==1.15.5) (1.3.0)\n", "Requirement already satisfied: setuptools>=41.0.0 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (59.6.0)\n", - "Requirement already satisfied: markdown>=2.6.8 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (3.3.7)\n", "Requirement already satisfied: werkzeug>=0.11.15 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (2.0.3)\n", + "Requirement already satisfied: markdown>=2.6.8 in ./pocket/lib/python3.6/site-packages (from tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (3.3.7)\n", "Requirement already satisfied: importlib-metadata>=4.4 in ./pocket/lib/python3.6/site-packages (from markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (4.8.3)\n", "Requirement already satisfied: dataclasses in ./pocket/lib/python3.6/site-packages (from werkzeug>=0.11.15->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (0.8)\n", "Requirement already satisfied: typing-extensions>=3.6.4 in ./pocket/lib/python3.6/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (4.1.1)\n", "Requirement already satisfied: zipp>=0.5 in ./pocket/lib/python3.6/site-packages (from importlib-metadata>=4.4->markdown>=2.6.8->tensorboard<1.16.0,>=1.15.0->tensorflow==1.15.5) (3.6.0)\n", "Requirement already satisfied: keras==2.2.5 in ./pocket/lib/python3.6/site-packages (2.2.5)\n", - "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.0.8)\n", "Requirement already satisfied: scipy>=0.14 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.5.4)\n", "Requirement already satisfied: keras-preprocessing>=1.1.0 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.1.2)\n", "Requirement already satisfied: six>=1.9.0 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.16.0)\n", - "Requirement already satisfied: h5py in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (2.10.0)\n", - "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.18.5)\n", "Requirement already satisfied: pyyaml in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (6.0)\n", + "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.18.5)\n", + "Requirement already satisfied: h5py in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (2.10.0)\n", + "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from keras==2.2.5) (1.0.8)\n", "Requirement already satisfied: pincelate in ./pocket/lib/python3.6/site-packages (0.0.1)\n", + "Requirement already satisfied: scikit-learn>=0.20.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (0.24.2)\n", "Requirement already satisfied: Keras>=2.2.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (2.2.5)\n", "Requirement already satisfied: pronouncing>=0.2.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (0.2.0)\n", - "Requirement already satisfied: scikit-learn>=0.20.0 in ./pocket/lib/python3.6/site-packages (from pincelate) (0.24.2)\n", + "Requirement already satisfied: six>=1.9.0 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.16.0)\n", "Requirement already satisfied: h5py in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (2.10.0)\n", - "Requirement already satisfied: scipy>=0.14 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.5.4)\n", - "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.18.5)\n", "Requirement already satisfied: keras-preprocessing>=1.1.0 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.1.2)\n", - "Requirement already satisfied: pyyaml in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (6.0)\n", "Requirement already satisfied: keras-applications>=1.0.8 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.0.8)\n", - "Requirement already satisfied: six>=1.9.0 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.16.0)\n", + "Requirement already satisfied: pyyaml in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (6.0)\n", + "Requirement already satisfied: scipy>=0.14 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.5.4)\n", + "Requirement already satisfied: numpy>=1.9.1 in ./pocket/lib/python3.6/site-packages (from Keras>=2.2.0->pincelate) (1.18.5)\n", "Requirement already satisfied: cmudict>=0.4.0 in ./pocket/lib/python3.6/site-packages (from pronouncing>=0.2.0->pincelate) (1.0.2)\n", "Requirement already satisfied: joblib>=0.11 in ./pocket/lib/python3.6/site-packages (from scikit-learn>=0.20.0->pincelate) (1.1.1)\n", "Requirement already satisfied: threadpoolctl>=2.0.0 in ./pocket/lib/python3.6/site-packages (from scikit-learn>=0.20.0->pincelate) (3.1.0)\n" ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "Using TensorFlow backend.\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:541: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:66: The name tf.get_default_graph is deprecated. Please use tf.compat.v1.get_default_graph instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:4432: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:148: The name tf.placeholder_with_default is deprecated. Please use tf.compat.v1.placeholder_with_default instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3733: calling dropout (from tensorflow.python.ops.nn_ops) with keep_prob is deprecated and will be removed in a future version.\n", - "Instructions for updating:\n", - "Please use `rate` instead of `keep_prob`. Rate should be set to `rate = 1 - keep_prob`.\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:3239: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n", - "Instructions for updating:\n", - "Use tf.where in 2.0, which has the same broadcast rule as np.where\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:190: The name tf.get_default_session is deprecated. Please use tf.compat.v1.get_default_session instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:197: The name tf.ConfigProto is deprecated. Please use tf.compat.v1.ConfigProto instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:203: The name tf.Session is deprecated. Please use tf.compat.v1.Session instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:207: The name tf.global_variables is deprecated. Please use tf.compat.v1.global_variables instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:216: The name tf.is_variable_initialized is deprecated. Please use tf.compat.v1.is_variable_initialized instead.\n", - "\n", - "WARNING:tensorflow:From /home/angeliki/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:223: The name tf.variables_initializer is deprecated. Please use tf.compat.v1.variables_initializer instead.\n", - "\n" - ] } ], "source": [ @@ -138,6 +99,8 @@ "id": "9f1e2cc7", "metadata": {}, "source": [ + "### Respelling\n", + "\n", "This is how Parrish describes the *manipulate* function of Pincelate: \"Pincelate actually consists of two models: one that knows how to sound out words based on how they're spelled, and another that knows how to spell words from sounds.\"\n", "\n", "With this function, words are passing through the two models, taking words, sounding them out from their spelling and then bringing them back into writing via phonemes. As a way to situate ourselves into the conference, we propose to take the conference titles as material to reshape, contort, or respell. \n", @@ -175,46 +138,48 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "id": "muslim-labor", "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "'arcsvtinex'" - ] - }, - "execution_count": 2, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "what is your word? Archives\n", + "temperature value? 2\n" + ] + }, + { + "ename": "TypeError", + "evalue": "ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0mwor\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'what is your word? '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2\u001b[0m \u001b[0mtemp\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0minput\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'temperature value? '\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mpin\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmanipulate\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwor\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlower\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0mtemperature\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtemp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/__init__.py\u001b[0m in \u001b[0;36mmanipulate\u001b[0;34m(self, s, letters, features, temperature)\u001b[0m\n\u001b[1;32m 444\u001b[0m )\n\u001b[1;32m 445\u001b[0m orth_seq = [self.phon2orth.to_target_vocab(item, 1)[0][0]\n\u001b[0;32m--> 446\u001b[0;31m for item in orth_decoding]\n\u001b[0m\u001b[1;32m 447\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 448\u001b[0m \u001b[0;31m# trim start/end tokens\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m(.0)\u001b[0m\n\u001b[1;32m 443\u001b[0m x ** np.exp(orth_exps), temperature)\n\u001b[1;32m 444\u001b[0m )\n\u001b[0;32m--> 445\u001b[0;31m orth_seq = [self.phon2orth.to_target_vocab(item, 1)[0][0]\n\u001b[0m\u001b[1;32m 446\u001b[0m for item in orth_decoding]\n\u001b[1;32m 447\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/seq2seq.py\u001b[0m in \u001b[0;36mdecode_sequence\u001b[0;34m(self, state_value, target_seq, transform, maxlen)\u001b[0m\n\u001b[1;32m 234\u001b[0m \"\"\"\n\u001b[1;32m 235\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 236\u001b[0;31m \u001b[0;32myield\u001b[0m \u001b[0mtransform\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtarget_seq\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 237\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmaxlen\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 238\u001b[0m output, h = self.infer_decoder_model.predict(\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/__init__.py\u001b[0m in \u001b[0;36m\u001b[0;34m(x)\u001b[0m\n\u001b[1;32m 441\u001b[0m \u001b[0;31m# orthography inference manipulation\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 442\u001b[0m transform=lambda x: softmax_temperature(\n\u001b[0;32m--> 443\u001b[0;31m x ** np.exp(orth_exps), temperature)\n\u001b[0m\u001b[1;32m 444\u001b[0m )\n\u001b[1;32m 445\u001b[0m orth_seq = [self.phon2orth.to_target_vocab(item, 1)[0][0]\n", + "\u001b[0;32m~/Documents/Any_One_day_future/A_tune_in/pocket/lib/python3.6/site-packages/pincelate/seq2seq.py\u001b[0m in \u001b[0;36msoftmax_temperature\u001b[0;34m(t, temp)\u001b[0m\n\u001b[1;32m 301\u001b[0m \u001b[0mzeros\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mzeros\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mt\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshape\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 302\u001b[0m \u001b[0mdist\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mt\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m-\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mastype\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfloat64\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;36m0.0001\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 303\u001b[0;31m \u001b[0mpred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlog\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdist\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mtemp\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 304\u001b[0m \u001b[0mexp_pred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexp\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 305\u001b[0m \u001b[0mpred\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mexp_pred\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mnp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0msum\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexp_pred\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mTypeError\u001b[0m: ufunc 'true_divide' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''" + ] } ], "source": [ - "pin.manipulate(\"archives\",temperature=2)" + "wor = input('what is your word? ')\n", + "temp = input('temperature value? ')\n", + "\n", + "pin.manipulate(wor.lower(),temperature = int(temp))" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": null, "id": "b648b5ae", "metadata": {}, - "outputs": [ - { - "data": { - "application/vnd.jupyter.widget-view+json": { - "model_id": "52dbe8b1e0bb4ea9b0276e6902fce2b8", - "version_major": 2, - "version_minor": 0 - }, - "text/plain": [ - "interactive(children=(Text(value='any one future died', description='s'), FloatSlider(value=1.2500000000000002…" - ] - }, - "metadata": {}, - "output_type": "display_data" - } - ], + "outputs": [], "source": [ "@interact(s=\"any one future died\",temp=(0.05,2.5,0.05))\n", "def tempadjust(s,temp):\n", @@ -247,7 +212,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "id": "2e25f0db", "metadata": {}, "outputs": [], @@ -261,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 5, "id": "189c5b06", "metadata": {}, "outputs": [], @@ -298,28 +263,15 @@ "\tfor word in dictionary:\n", "\t\tif word in new_sentence:\n", "\t\t\tnew_sentence = new_sentence.replace(word, random.choice(dictionary[word]['paradoxes']))\n", - "\tprint(new_sentence)\n", - "\n" + "\tprint(new_sentence)" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "b1dde66a", "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "what are your words? fdkhggfe futures\n", - "choose replacing method between \"paranyms\",\"parameanings\",\"paradoxes\",\"all\": all\n", - "fdkhggfe \n", - "fdkhggfe \n", - "fdkhggfe \n" - ] - } - ], + "outputs": [], "source": [ "\n", "sentence = input('what are your words? ')\n",