Remove deprecated Jupyter notebook
This commit is contained in:
parent
d0220ab1f0
commit
f91abfe43d
|
@ -1,388 +0,0 @@
|
||||||
{
|
|
||||||
"nbformat": 4,
|
|
||||||
"nbformat_minor": 0,
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"name": "locimend.ipynb",
|
|
||||||
"provenance": []
|
|
||||||
},
|
|
||||||
"kernelspec": {
|
|
||||||
"name": "python3",
|
|
||||||
"display_name": "Python 3"
|
|
||||||
},
|
|
||||||
"language_info": {
|
|
||||||
"name": "python"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"cells": [
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"metadata": {
|
|
||||||
"id": "sRYtN362elcw"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"# Constants\n",
|
|
||||||
"BASES = \"ACGT\"\n",
|
|
||||||
"TRAIN_DATASET = \"data/train_data.tfrecords\"\n",
|
|
||||||
"TEST_DATASET = \"data/test_data.tfrecords\"\n",
|
|
||||||
"EVAL_DATASET = \"data/eval_data.tfrecords\"\n",
|
|
||||||
"EPOCHS = 1000\n",
|
|
||||||
"BATCH_SIZE = 256\n",
|
|
||||||
"LEARNING_RATE = 0.004\n",
|
|
||||||
"L2 = 0.001\n",
|
|
||||||
"LOG_DIR = \"logs\""
|
|
||||||
],
|
|
||||||
"execution_count": 4,
|
|
||||||
"outputs": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/"
|
|
||||||
},
|
|
||||||
"id": "mjwJOPSbvA0Y",
|
|
||||||
"outputId": "bb7fce1c-5758-4da8-e8a1-acd5275f979e"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"!mkdir logs\n",
|
|
||||||
"!mkdir data\n",
|
|
||||||
"!curl -fL https://git.coolneng.duckdns.org/coolneng/locimend/raw/branch/master/data/HVR.fastq -o data/HVR.fastq\n",
|
|
||||||
"!curl -fL https://git.coolneng.duckdns.org/coolneng/locimend/raw/branch/master/data/curesim-HVR.fastq -o data/curesim-HVR.fastq"
|
|
||||||
],
|
|
||||||
"execution_count": 3,
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"mkdir: cannot create directory ‘logs’: File exists\n",
|
|
||||||
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
|
||||||
" Dload Upload Total Spent Left Speed\n",
|
|
||||||
"100 1074k 100 1074k 0 0 804k 0 0:00:01 0:00:01 --:--:-- 804k\n",
|
|
||||||
" % Total % Received % Xferd Average Speed Time Time Time Current\n",
|
|
||||||
" Dload Upload Total Spent Left Speed\n",
|
|
||||||
"100 1484k 100 1484k 0 0 321k 0 0:00:04 0:00:04 --:--:-- 321k\n"
|
|
||||||
],
|
|
||||||
"name": "stdout"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/"
|
|
||||||
},
|
|
||||||
"id": "-uWm7bS7fkRE",
|
|
||||||
"outputId": "347d17aa-752e-425c-e727-71df2a32da67"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"!pip install biopython"
|
|
||||||
],
|
|
||||||
"execution_count": 5,
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Collecting biopython\n",
|
|
||||||
"\u001b[?25l Downloading https://files.pythonhosted.org/packages/5a/42/de1ed545df624180b84c613e5e4de4848f72989ce5846a74af6baa0737b9/biopython-1.79-cp37-cp37m-manylinux_2_5_x86_64.manylinux1_x86_64.whl (2.3MB)\n",
|
|
||||||
"\u001b[K |████████████████████████████████| 2.3MB 5.2MB/s \n",
|
|
||||||
"\u001b[?25hRequirement already satisfied: numpy in /usr/local/lib/python3.7/dist-packages (from biopython) (1.19.5)\n",
|
|
||||||
"Installing collected packages: biopython\n",
|
|
||||||
"Successfully installed biopython-1.79\n"
|
|
||||||
],
|
|
||||||
"name": "stdout"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"metadata": {
|
|
||||||
"id": "CKFwG1_afwFU"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"from typing import List, Tuple\n",
|
|
||||||
"\n",
|
|
||||||
"from Bio.motifs import create\n",
|
|
||||||
"from Bio.SeqIO import parse\n",
|
|
||||||
"from numpy.random import random\n",
|
|
||||||
"from tensorflow import Tensor, int64, stack, cast, int32\n",
|
|
||||||
"from tensorflow.sparse import to_dense\n",
|
|
||||||
"from tensorflow.data import TFRecordDataset\n",
|
|
||||||
"from tensorflow.io import (\n",
|
|
||||||
" FixedLenFeature,\n",
|
|
||||||
" TFRecordWriter,\n",
|
|
||||||
" VarLenFeature,\n",
|
|
||||||
" parse_single_example,\n",
|
|
||||||
")\n",
|
|
||||||
"from tensorflow.train import Example, Feature, Features, Int64List\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def generate_example(sequence, label, base_counts) -> bytes:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Create a binary-string for each sequence containing the sequence and the bases' counts\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" schema = {\n",
|
|
||||||
" \"A_counts\": Feature(int64_list=Int64List(value=[sum(base_counts[\"A\"])])),\n",
|
|
||||||
" \"C_counts\": Feature(int64_list=Int64List(value=[sum(base_counts[\"C\"])])),\n",
|
|
||||||
" \"G_counts\": Feature(int64_list=Int64List(value=[sum(base_counts[\"G\"])])),\n",
|
|
||||||
" \"T_counts\": Feature(int64_list=Int64List(value=[sum(base_counts[\"T\"])])),\n",
|
|
||||||
" \"sequence\": Feature(int64_list=Int64List(value=encode_sequence(sequence))),\n",
|
|
||||||
" \"label\": Feature(int64_list=Int64List(value=encode_sequence(label))),\n",
|
|
||||||
" }\n",
|
|
||||||
" example = Example(features=Features(feature=schema))\n",
|
|
||||||
" return example.SerializeToString()\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def encode_sequence(sequence) -> List[int]:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Encode the DNA sequence using the indices of the BASES constant\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" encoded_sequence = [BASES.index(element) for element in sequence]\n",
|
|
||||||
" return encoded_sequence\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def read_fastq(data_file, label_file) -> List[bytes]:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Parses a data and a label FASTQ files and generates a List of serialized Examples\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" examples = []\n",
|
|
||||||
" with open(data_file) as data, open(label_file) as labels:\n",
|
|
||||||
" for element, label in zip(parse(data, \"fastq\"), parse(labels, \"fastq\")):\n",
|
|
||||||
" motifs = create([element.seq])\n",
|
|
||||||
" example = generate_example(\n",
|
|
||||||
" sequence=str(element.seq),\n",
|
|
||||||
" label=str(label.seq),\n",
|
|
||||||
" base_counts=motifs.counts,\n",
|
|
||||||
" )\n",
|
|
||||||
" examples.append(example)\n",
|
|
||||||
" return examples\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def create_dataset(\n",
|
|
||||||
" data_file, label_file, train_eval_test_split=[0.8, 0.1, 0.1]\n",
|
|
||||||
") -> None:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Create a training, evaluation and test dataset with a 80/10/30 split respectively\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" data = read_fastq(data_file, label_file)\n",
|
|
||||||
" with TFRecordWriter(TRAIN_DATASET) as training, TFRecordWriter(\n",
|
|
||||||
" TEST_DATASET\n",
|
|
||||||
" ) as test, TFRecordWriter(EVAL_DATASET) as evaluation:\n",
|
|
||||||
" for element in data:\n",
|
|
||||||
" if random() < train_eval_test_split[0]:\n",
|
|
||||||
" training.write(element)\n",
|
|
||||||
" elif random() < train_eval_test_split[0] + train_eval_test_split[1]:\n",
|
|
||||||
" evaluation.write(element)\n",
|
|
||||||
" else:\n",
|
|
||||||
" test.write(element)\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def transform_features(parsed_features) -> List[Tensor]:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Cast and transform the parsed features of an Example into a list of Tensors\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" sparse_features = [\"sequence\", \"label\"]\n",
|
|
||||||
" for feature in sparse_features:\n",
|
|
||||||
" parsed_features[feature] = cast(parsed_features[feature], int32)\n",
|
|
||||||
" parsed_features[feature] = to_dense(parsed_features[feature])\n",
|
|
||||||
" for base in BASES:\n",
|
|
||||||
" parsed_features[f\"{base}_counts\"] = cast(\n",
|
|
||||||
" parsed_features[f\"{base}_counts\"], int32\n",
|
|
||||||
" )\n",
|
|
||||||
" features = list(parsed_features.values())[:-1]\n",
|
|
||||||
" return features\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def process_input(byte_string) -> Tuple[Tensor, Tensor]:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Parse a byte-string into an Example object\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" schema = {\n",
|
|
||||||
" \"A_counts\": FixedLenFeature(shape=[1], dtype=int64),\n",
|
|
||||||
" \"C_counts\": FixedLenFeature(shape=[1], dtype=int64),\n",
|
|
||||||
" \"G_counts\": FixedLenFeature(shape=[1], dtype=int64),\n",
|
|
||||||
" \"T_counts\": FixedLenFeature(shape=[1], dtype=int64),\n",
|
|
||||||
" \"sequence\": VarLenFeature(dtype=int64),\n",
|
|
||||||
" \"label\": VarLenFeature(dtype=int64),\n",
|
|
||||||
" }\n",
|
|
||||||
" parsed_features = parse_single_example(byte_string, features=schema)\n",
|
|
||||||
" features = transform_features(parsed_features)\n",
|
|
||||||
" return stack(features, axis=-1), parsed_features[\"label\"]\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def read_dataset(filepath) -> TFRecordDataset:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Read TFRecords files and generate a dataset\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" data_input = TFRecordDataset(filenames=filepath)\n",
|
|
||||||
" dataset = data_input.map(map_func=process_input)\n",
|
|
||||||
" shuffled_dataset = dataset.shuffle(buffer_size=10000, seed=42)\n",
|
|
||||||
" batched_dataset = shuffled_dataset.batch(batch_size=BATCH_SIZE).repeat(count=EPOCHS)\n",
|
|
||||||
" return batched_dataset\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def dataset_creation(\n",
|
|
||||||
" data_file, label_file\n",
|
|
||||||
") -> Tuple[TFRecordDataset, TFRecordDataset, TFRecordDataset]:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Generate the TFRecord files and split them into training, validation and test data\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" create_dataset(data_file, label_file)\n",
|
|
||||||
" train_data = read_dataset(TRAIN_DATASET)\n",
|
|
||||||
" eval_data = read_dataset(EVAL_DATASET)\n",
|
|
||||||
" test_data = read_dataset(TEST_DATASET)\n",
|
|
||||||
" return train_data, eval_data, test_data\n",
|
|
||||||
"\n"
|
|
||||||
],
|
|
||||||
"execution_count": 6,
|
|
||||||
"outputs": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"metadata": {
|
|
||||||
"id": "UXAAAVolf7GA"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"from random import seed\n",
|
|
||||||
"\n",
|
|
||||||
"from tensorflow.keras import Model, Sequential, layers\n",
|
|
||||||
"from tensorflow.keras.callbacks import TensorBoard\n",
|
|
||||||
"from tensorflow.keras.losses import sparse_categorical_crossentropy\n",
|
|
||||||
"from tensorflow.keras.optimizers import Adam\n",
|
|
||||||
"from tensorflow.keras.regularizers import l2\n",
|
|
||||||
"from tensorflow.random import set_seed\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def build_model() -> Model:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Build the CNN model\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" model = Sequential()\n",
|
|
||||||
" model.add(\n",
|
|
||||||
" layers.Conv1D(\n",
|
|
||||||
" filters=16,\n",
|
|
||||||
" kernel_size=5,\n",
|
|
||||||
" activation=\"relu\",\n",
|
|
||||||
" kernel_regularizer=l2(L2),\n",
|
|
||||||
" )\n",
|
|
||||||
" )\n",
|
|
||||||
" model.add(layers.MaxPool1D(pool_size=3, strides=1))\n",
|
|
||||||
" model.add(\n",
|
|
||||||
" layers.Conv1D(\n",
|
|
||||||
" filters=16,\n",
|
|
||||||
" kernel_size=3,\n",
|
|
||||||
" activation=\"relu\",\n",
|
|
||||||
" kernel_regularizer=l2(L2),\n",
|
|
||||||
" )\n",
|
|
||||||
" )\n",
|
|
||||||
" model.add(layers.MaxPool1D(pool_size=3, strides=1))\n",
|
|
||||||
" model.add(layers.Flatten())\n",
|
|
||||||
" model.add(\n",
|
|
||||||
" layers.Dense(\n",
|
|
||||||
" units=16,\n",
|
|
||||||
" activation=\"relu\",\n",
|
|
||||||
" kernel_regularizer=l2(L2),\n",
|
|
||||||
" )\n",
|
|
||||||
" )\n",
|
|
||||||
" model.add(layers.Dropout(rate=0.3))\n",
|
|
||||||
" model.add(\n",
|
|
||||||
" layers.Dense(\n",
|
|
||||||
" units=16,\n",
|
|
||||||
" activation=\"relu\",\n",
|
|
||||||
" kernel_regularizer=l2(L2),\n",
|
|
||||||
" )\n",
|
|
||||||
" )\n",
|
|
||||||
" model.add(layers.Dropout(rate=0.3))\n",
|
|
||||||
" # FIXME Change output size\n",
|
|
||||||
" model.add(layers.Dense(units=len(BASES), activation=\"softmax\"))\n",
|
|
||||||
" model.compile(\n",
|
|
||||||
" optimizer=Adam(LEARNING_RATE),\n",
|
|
||||||
" loss=sparse_categorical_crossentropy,\n",
|
|
||||||
" metrics=[\"accuracy\"],\n",
|
|
||||||
" )\n",
|
|
||||||
" return model\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def show_metrics(model, eval_dataset, test_dataset) -> None:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Show the model metrics\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" eval_metrics = model.evaluate(eval_dataset, verbose=0)\n",
|
|
||||||
" test_metrics = model.evaluate(test_dataset, verbose=0)\n",
|
|
||||||
" print(f\"Final eval metrics - loss: {eval_metrics[0]} - accuracy: {eval_metrics[1]}\")\n",
|
|
||||||
" print(f\"Final test metrics - loss: {test_metrics[0]} - accuracy: {test_metrics[1]}\")\n",
|
|
||||||
"\n",
|
|
||||||
"\n",
|
|
||||||
"def run(data_file, label_file, seed_value=42) -> None:\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" Create a dataset, a model and runs training and evaluation on it\n",
|
|
||||||
" \"\"\"\n",
|
|
||||||
" seed(seed_value)\n",
|
|
||||||
" set_seed(seed_value)\n",
|
|
||||||
" train_data, eval_data, test_data = dataset_creation(data_file, label_file)\n",
|
|
||||||
" tensorboard = TensorBoard(log_dir=LOG_DIR, histogram_freq=1, profile_batch=0)\n",
|
|
||||||
" model = build_model()\n",
|
|
||||||
" print(\"Training the model\")\n",
|
|
||||||
" model.fit(\n",
|
|
||||||
" train_data,\n",
|
|
||||||
" epochs=EPOCHS,\n",
|
|
||||||
" validation_data=eval_data,\n",
|
|
||||||
" callbacks=[tensorboard],\n",
|
|
||||||
" verbose=0,\n",
|
|
||||||
" )\n",
|
|
||||||
" print(\"Training complete. Obtaining final metrics...\")\n",
|
|
||||||
" show_metrics(model, eval_data, test_data)"
|
|
||||||
],
|
|
||||||
"execution_count": 7,
|
|
||||||
"outputs": []
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"cell_type": "code",
|
|
||||||
"metadata": {
|
|
||||||
"colab": {
|
|
||||||
"base_uri": "https://localhost:8080/",
|
|
||||||
"height": 1000
|
|
||||||
},
|
|
||||||
"id": "V8BuUmpIgDqc",
|
|
||||||
"outputId": "e7f697dc-a459-4e4e-ed98-406b44e120fc"
|
|
||||||
},
|
|
||||||
"source": [
|
|
||||||
"run(data_file=\"data/curesim-HVR.fastq\", label_file=\"data/HVR.fastq\")"
|
|
||||||
],
|
|
||||||
"execution_count": 8,
|
|
||||||
"outputs": [
|
|
||||||
{
|
|
||||||
"output_type": "stream",
|
|
||||||
"text": [
|
|
||||||
"Training the model\n"
|
|
||||||
],
|
|
||||||
"name": "stdout"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"output_type": "error",
|
|
||||||
"ename": "TypeError",
|
|
||||||
"evalue": "ignored",
|
|
||||||
"traceback": [
|
|
||||||
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
|
|
||||||
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
|
|
||||||
"\u001b[0;32m<ipython-input-8-4b0e5d1da156>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mrun\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata_file\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"data/curesim-HVR.fastq\"\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabel_file\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"data/HVR.fastq\"\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<ipython-input-7-d8ed7ecffd74>\u001b[0m in \u001b[0;36mrun\u001b[0;34m(data_file, label_file, seed_value)\u001b[0m\n\u001b[1;32m 84\u001b[0m \u001b[0mvalidation_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0meval_data\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 85\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mtensorboard\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;32m---> 86\u001b[0;31m \u001b[0mverbose\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;36m0\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 87\u001b[0m )\n\u001b[1;32m 88\u001b[0m \u001b[0mprint\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Training complete. Obtaining final metrics...\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py\u001b[0m in \u001b[0;36mfit\u001b[0;34m(self, x, y, batch_size, epochs, verbose, callbacks, validation_split, validation_data, shuffle, class_weight, sample_weight, initial_epoch, steps_per_epoch, validation_steps, validation_batch_size, validation_freq, max_queue_size, workers, use_multiprocessing)\u001b[0m\n\u001b[1;32m 1181\u001b[0m _r=1):\n\u001b[1;32m 1182\u001b[0m \u001b[0mcallbacks\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mon_train_batch_begin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mstep\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1183\u001b[0;31m \u001b[0mtmp_logs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtrain_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0miterator\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 1184\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mdata_handler\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mshould_sync\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1185\u001b[0m \u001b[0mcontext\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0masync_wait\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;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 887\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 888\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mOptionalXlaContext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_jit_compile\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;32m--> 889\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_call\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\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 890\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 891\u001b[0m \u001b[0mnew_tracing_count\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mexperimental_get_tracing_count\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;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m_call\u001b[0;34m(self, *args, **kwds)\u001b[0m\n\u001b[1;32m 931\u001b[0m \u001b[0;31m# This is the first call of __call__, so we have to initialize.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 932\u001b[0m \u001b[0minitializers\u001b[0m \u001b[0;34m=\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;32m--> 933\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_initialize\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwds\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0madd_initializers_to\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0minitializers\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 934\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 935\u001b[0m \u001b[0;31m# At this point we know that the initialization is complete (or less\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36m_initialize\u001b[0;34m(self, args, kwds, add_initializers_to)\u001b[0m\n\u001b[1;32m 762\u001b[0m self._concrete_stateful_fn = (\n\u001b[1;32m 763\u001b[0m self._stateful_fn._get_concrete_function_internal_garbage_collected( # pylint: disable=protected-access\n\u001b[0;32m--> 764\u001b[0;31m *args, **kwds))\n\u001b[0m\u001b[1;32m 765\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 766\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0minvalid_creator_scope\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0munused_args\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0munused_kwds\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;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_get_concrete_function_internal_garbage_collected\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 3048\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3049\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_lock\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3050\u001b[0;31m \u001b[0mgraph_function\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0m_\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_maybe_define_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\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 3051\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3052\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_maybe_define_function\u001b[0;34m(self, args, kwargs)\u001b[0m\n\u001b[1;32m 3442\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3443\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_function_cache\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmissed\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcall_context_key\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3444\u001b[0;31m \u001b[0mgraph_function\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_create_graph_function\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkwargs\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 3445\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_function_cache\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprimary\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mcache_key\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mgraph_function\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3446\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/function.py\u001b[0m in \u001b[0;36m_create_graph_function\u001b[0;34m(self, args, kwargs, override_flat_arg_shapes)\u001b[0m\n\u001b[1;32m 3287\u001b[0m \u001b[0marg_names\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0marg_names\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3288\u001b[0m \u001b[0moverride_flat_arg_shapes\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0moverride_flat_arg_shapes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 3289\u001b[0;31m capture_by_value=self._capture_by_value),\n\u001b[0m\u001b[1;32m 3290\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_function_attributes\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 3291\u001b[0m \u001b[0mfunction_spec\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mfunction_spec\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py\u001b[0m in \u001b[0;36mfunc_graph_from_py_func\u001b[0;34m(name, python_func, args, kwargs, signature, func_graph, autograph, autograph_options, add_control_dependencies, arg_names, op_return_value, collections, capture_by_value, override_flat_arg_shapes)\u001b[0m\n\u001b[1;32m 997\u001b[0m \u001b[0m_\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0moriginal_func\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtf_decorator\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0munwrap\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mpython_func\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 998\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 999\u001b[0;31m \u001b[0mfunc_outputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mpython_func\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0mfunc_args\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mfunc_kwargs\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 1000\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1001\u001b[0m \u001b[0;31m# invariant: `func_outputs` contains only Tensors, CompositeTensors,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/eager/def_function.py\u001b[0m in \u001b[0;36mwrapped_fn\u001b[0;34m(*args, **kwds)\u001b[0m\n\u001b[1;32m 670\u001b[0m \u001b[0;31m# the function a weak reference to itself to avoid a reference cycle.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 671\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mOptionalXlaContext\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcompile_with_xla\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;32m--> 672\u001b[0;31m \u001b[0mout\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mweak_wrapped_fn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__wrapped__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwds\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 673\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mout\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 674\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;32m/usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 984\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0;31m# pylint:disable=broad-except\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 985\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mhasattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"ag_error_metadata\"\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;32m--> 986\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mag_error_metadata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_exception\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0me\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 987\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 988\u001b[0m \u001b[0;32mraise\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
|
|
||||||
"\u001b[0;31mTypeError\u001b[0m: in user code:\n\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:855 train_function *\n return step_function(self, iterator)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:845 step_function **\n outputs = model.distribute_strategy.run(run_step, args=(data,))\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:1285 run\n return self._extended.call_for_each_replica(fn, args=args, kwargs=kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:2833 call_for_each_replica\n return self._call_for_each_replica(fn, args, kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/distribute/distribute_lib.py:3608 _call_for_each_replica\n return fn(*args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:838 run_step **\n outputs = model.train_step(data)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/training.py:795 train_step\n y_pred = self(x, training=True)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/base_layer.py:1030 __call__\n outputs = call_fn(inputs, *args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/sequential.py:394 call\n outputs = layer(inputs, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/engine/base_layer.py:1030 __call__\n outputs = call_fn(inputs, *args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/keras/layers/convolutional.py:249 call\n outputs = self._convolution_op(inputs, self.kernel)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py:206 wrapper\n return target(*args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/nn_ops.py:1019 convolution_v2\n name=name)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/nn_ops.py:1149 convolution_internal\n name=name)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/util/dispatch.py:206 wrapper\n return target(*args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/util/deprecation.py:602 new_func\n return func(*args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/util/deprecation.py:602 new_func\n return func(*args, **kwargs)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/nn_ops.py:1892 conv1d\n name=name)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/ops/gen_nn_ops.py:973 conv2d\n data_format=data_format, dilations=dilations, name=name)\n /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/op_def_library.py:558 _apply_op_helper\n inferred_from[input_arg.type_attr]))\n\n TypeError: Input 'filter' of 'Conv2D' Op has type float32 that does not match type int32 of argument 'input'.\n"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
Loading…
Reference in New Issue