hexsha
stringlengths 40
40
| size
int64 6
14.9M
| ext
stringclasses 1
value | lang
stringclasses 1
value | max_stars_repo_path
stringlengths 6
260
| max_stars_repo_name
stringlengths 6
119
| max_stars_repo_head_hexsha
stringlengths 40
41
| max_stars_repo_licenses
list | max_stars_count
int64 1
191k
⌀ | max_stars_repo_stars_event_min_datetime
stringlengths 24
24
⌀ | max_stars_repo_stars_event_max_datetime
stringlengths 24
24
⌀ | max_issues_repo_path
stringlengths 6
260
| max_issues_repo_name
stringlengths 6
119
| max_issues_repo_head_hexsha
stringlengths 40
41
| max_issues_repo_licenses
list | max_issues_count
int64 1
67k
⌀ | max_issues_repo_issues_event_min_datetime
stringlengths 24
24
⌀ | max_issues_repo_issues_event_max_datetime
stringlengths 24
24
⌀ | max_forks_repo_path
stringlengths 6
260
| max_forks_repo_name
stringlengths 6
119
| max_forks_repo_head_hexsha
stringlengths 40
41
| max_forks_repo_licenses
list | max_forks_count
int64 1
105k
⌀ | max_forks_repo_forks_event_min_datetime
stringlengths 24
24
⌀ | max_forks_repo_forks_event_max_datetime
stringlengths 24
24
⌀ | avg_line_length
float64 2
1.04M
| max_line_length
int64 2
11.2M
| alphanum_fraction
float64 0
1
| cells
list | cell_types
list | cell_type_groups
list |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
eca96b51acebe44368945b895136f82ec263196f | 395,033 | ipynb | Jupyter Notebook | docs/notebooks/Rest_Pipeline.ipynb | ryscet/pySeries | 3ab1e0a9dbdeaef34c6c6d1fed5b248203c84fea | [
"MIT"
] | 1 | 2019-01-23T08:59:51.000Z | 2019-01-23T08:59:51.000Z | docs/notebooks/Rest_Pipeline.ipynb | ryscet/pySeries | 3ab1e0a9dbdeaef34c6c6d1fed5b248203c84fea | [
"MIT"
] | null | null | null | docs/notebooks/Rest_Pipeline.ipynb | ryscet/pySeries | 3ab1e0a9dbdeaef34c6c6d1fed5b248203c84fea | [
"MIT"
] | 3 | 2016-11-04T14:15:58.000Z | 2016-11-10T22:31:10.000Z | 1,525.223938 | 52,140 | 0.946374 | [
[
[
"# Notebook settings (i.e. this thing settings) \n%matplotlib inline\n#%matplotlib notebook \n#Change to %matplotlib notebook to be able to zoom, pan, etc the figures,\n#inline is only used so the notebook can be exported to .rst format and hosted on readthedocs\n%load_ext autoreload\n%autoreload 2 ",
"The autoreload extension is already loaded. To reload it, use:\n %reload_ext autoreload\n"
],
[
"# Documentation at: http://pyseries.readthedocs.io/en/latest/\n\n# To use last version of pyseries enter in the terminal (pip installation: https://pip.pypa.io/en/stable/installing/)\n# >>> pip install pyseries \n\n# To use use pyseries locally from downloaded github repo (when you want to make changes to source code),\n# 1) pip uninstall pyseries \n# 2) checkout https://github.com/ryscet/pyseries.git (tutorial: https://help.github.com/articles/fetching-a-remote/)\n# 3) uncomment below and put a correct path \n\nimport sys\nsys.path.insert(0, '/Users/user/Desktop/repo_for_pyseries/pyseries/')\n",
"_____no_output_____"
],
[
"\nimport pyseries.LoadingData as loading\nimport pyseries.Preprocessing as prep\nimport pyseries.Analysis as analysis\n",
"_____no_output_____"
],
[
"def plot_rest():\n paths = [ '/Users/user/Desktop/nagrania_eeg/rest/Ania_14_06_16/',\n '/Users/user/Desktop/nagrania_eeg/rest/Karen_14_06_16/',\n '/Users/user/Desktop/nagrania_eeg/rest/Kuba_14_06_16/',\n \n '/Users/user/Desktop/nagrania_eeg/rest/Rysiek_03_06_16/',\n '/Users/user/Desktop/nagrania_eeg/rest/Rysiek_07_21_16/',\n\n '/Users/user/Desktop/nagrania_eeg/rest/Aleksandra_07_21_16/',\n\n '/Users/user/Desktop/nagrania_eeg/rest/Aleksandra_07_15_16/',\n '/Users/user/Desktop/nagrania_eeg/rest/Agnieszka_03_06_16/',\n '/Users/user/Desktop/nagrania_eeg/rest/Agnieszka_07_21_16/'\n ]\n\n\n for idx, path in enumerate(paths):\n recording = loading.Read_edf.Combine_EDF_XML(path, 3, 70)\n \n epochs_info= {\"Eyes Open\": [0, 498*140], \"Eyes Closed\": [0, 498 *140]}\n \n epochs = prep.Epochs.Make_Epochs_for_Channels(recording, ['EEG O1'],epochs_info)\n \n power_density= analysis.Explore.PlotPowerSpectrum(epochs['EEG O1'], 498, mode = 'welch', name = path, save_path =\"/Users/user/Desktop/Figures/rest/\" + str(idx) + \".png\" )\n\n #prep.Epochs.mark_events(recording,['EEG O1'], subject_name = path)",
"_____no_output_____"
],
[
"plot_rest()",
"(497.971446705165,)\n/Users/user/Desktop/nagrania_eeg/rest/Ania_14_06_16/\n(497.971446705165,)\n/Users/user/Desktop/nagrania_eeg/rest/Karen_14_06_16/\n(497.971446705165,)\n/Users/user/Desktop/nagrania_eeg/rest/Kuba_14_06_16/\n(497.971446705165,)\n/Users/user/Desktop/nagrania_eeg/rest/Rysiek_03_06_16/\n(500.0,)\n/Users/user/Desktop/nagrania_eeg/rest/Aleksandra_07_15_16/\n(500.0,)\n/Users/user/Desktop/nagrania_eeg/rest/Rysiek_07_21_16/\n(500.0,)\n/Users/user/Desktop/nagrania_eeg/rest/Aleksandra_07_21_16/\n(497.971446705165,)\n/Users/user/Desktop/nagrania_eeg/rest/Agnieszka_03_06_16/\n(500.0,)\n/Users/user/Desktop/nagrania_eeg/rest/Agnieszka_07_21_16/\n"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code"
]
] |
eca96b9cdbce418ea6a93cfcbc6cb9fc04880962 | 16,212 | ipynb | Jupyter Notebook | notebooks/solution_ueb01/05_Spark.ipynb | hhain/sdap17 | 8bd0b4cb60d6140141c834ffcac8835a888a0949 | [
"MIT"
] | null | null | null | notebooks/solution_ueb01/05_Spark.ipynb | hhain/sdap17 | 8bd0b4cb60d6140141c834ffcac8835a888a0949 | [
"MIT"
] | 1 | 2017-06-08T22:32:48.000Z | 2017-06-08T22:32:48.000Z | notebooks/solution_ueb01/05_Spark.ipynb | hhain/sdap17 | 8bd0b4cb60d6140141c834ffcac8835a888a0949 | [
"MIT"
] | null | null | null | 30.302804 | 329 | 0.509191 | [
[
[
"## Excercise 5 Spark",
"_____no_output_____"
]
],
[
[
"# Load libraries\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport time",
"_____no_output_____"
],
[
"# Load dataset\nurl = \"https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/wdbc.data\"\ndataset = pd.read_csv(url, header=None)",
"_____no_output_____"
],
[
"# create Spark Dataframe from Pandas Dataframe\ncancer_df = sqlContext.createDataFrame(dataset, schema=None)",
"_____no_output_____"
],
[
"print 'After parsing, number of training lines: {}'.format(cancer_df.count())\ncancer_df.printSchema()",
"After parsing, number of training lines: 569\nroot\n |-- 0: long (nullable = true)\n |-- 1: string (nullable = true)\n |-- 2: double (nullable = true)\n |-- 3: double (nullable = true)\n |-- 4: double (nullable = true)\n |-- 5: double (nullable = true)\n |-- 6: double (nullable = true)\n |-- 7: double (nullable = true)\n |-- 8: double (nullable = true)\n |-- 9: double (nullable = true)\n |-- 10: double (nullable = true)\n |-- 11: double (nullable = true)\n |-- 12: double (nullable = true)\n |-- 13: double (nullable = true)\n |-- 14: double (nullable = true)\n |-- 15: double (nullable = true)\n |-- 16: double (nullable = true)\n |-- 17: double (nullable = true)\n |-- 18: double (nullable = true)\n |-- 19: double (nullable = true)\n |-- 20: double (nullable = true)\n |-- 21: double (nullable = true)\n |-- 22: double (nullable = true)\n |-- 23: double (nullable = true)\n |-- 24: double (nullable = true)\n |-- 25: double (nullable = true)\n |-- 26: double (nullable = true)\n |-- 27: double (nullable = true)\n |-- 28: double (nullable = true)\n |-- 29: double (nullable = true)\n |-- 30: double (nullable = true)\n |-- 31: double (nullable = true)\n\n"
],
[
"from pyspark.ml import Pipeline\nfrom pyspark.ml.feature import StringIndexer, VectorAssembler\nfrom pyspark.ml.classification import LogisticRegression\n\n# Pipeline stages\nstages = []\n\n\n# Convert label into label indices using StringIndexer\nlabel_stringIdx = StringIndexer(inputCol=\"1\", outputCol = \"label\")\nstages += [label_stringIdx]",
"_____no_output_____"
],
[
"# Transform all numerical features into a vector using VectorAssembler\n\n# numeric cols 2:31\nnumeric_cols = [\"{}\".format(x) for x in range(2,32)]\nassembler = VectorAssembler(inputCols=numeric_cols, outputCol=\"features\")\nstages += [assembler]",
"_____no_output_____"
],
[
"# Create a pipeline\npipeline = Pipeline(stages=stages)\n\npipeline_model = pipeline.fit(cancer_df)\ncancer_transformed_df = pipeline_model.transform(cancer_df)\n\n\n\n# Keep relevant columns\nselected_cols = [\"label\", \"features\"]\ncancer_final_df = cancer_transformed_df.select(selected_cols)\ncancer_final_df.printSchema()\ncancer_final_df.show(5)",
"root\n |-- label: double (nullable = true)\n |-- features: vector (nullable = true)\n\n+-----+--------------------+\n|label| features|\n+-----+--------------------+\n| 1.0|[17.99,10.38,122....|\n| 1.0|[20.57,17.77,132....|\n| 1.0|[19.69,21.25,130....|\n| 1.0|[11.42,20.38,77.5...|\n| 1.0|[20.29,14.34,135....|\n+-----+--------------------+\n\n"
],
[
"from pyspark.ml.feature import StandardScaler\n\nscaler = StandardScaler(inputCol=\"features\", outputCol=\"scaledFeatures\", withStd=True, withMean=False)\n\nscalerModel = scaler.fit(cancer_final_df)\n\n#normalize each feature to have unit stdev\nscaled_cancer_final_df = scalerModel.transform(cancer_final_df)\nscaled_cancer_final_df.printSchema()\nscaled_cancer_final_df.show(5)",
"root\n |-- label: double (nullable = true)\n |-- features: vector (nullable = true)\n |-- scaledFeatures: vector (nullable = true)\n\n+-----+--------------------+--------------------+\n|label| features| scaledFeatures|\n+-----+--------------------+--------------------+\n| 1.0|[17.99,10.38,122....|[5.10492359418784...|\n| 1.0|[20.57,17.77,132....|[5.83703603849048...|\n| 1.0|[19.69,21.25,130....|[5.58732326679036...|\n| 1.0|[11.42,20.38,77.5...|[3.24059074183575...|\n| 1.0|[20.29,14.34,135....|[5.75758197476772...|\n+-----+--------------------+--------------------+\n\n"
],
[
"# Substitute fetures with newly created scaledFeatures \n# (Spark Dataframe columns cannot be modified but a copy can be created and in next step a name can be changed)\nscaled_cancer_final_df = scaled_cancer_final_df.selectExpr(\"label\", \"scaledFeatures as features\")\nscaled_cancer_final_df.printSchema()\nscaled_cancer_final_df.show(5)",
"root\n |-- label: double (nullable = true)\n |-- features: vector (nullable = true)\n\n+-----+--------------------+\n|label| features|\n+-----+--------------------+\n| 1.0|[5.10492359418784...|\n| 1.0|[5.83703603849048...|\n| 1.0|[5.58732326679036...|\n| 1.0|[3.24059074183575...|\n| 1.0|[5.75758197476772...|\n+-----+--------------------+\n\n"
],
[
"# Split the data into training and test sets (30% held out for testing)\n(trainingData, testData) = cancer_final_df.randomSplit([0.7, 0.3], seed = 1)\n\nprint trainingData.count()\nprint testData.count()",
"420\n149\n"
],
[
"# Train a LogisticRegression model.\nlr = LogisticRegression(featuresCol=\"features\", labelCol=\"label\", maxIter=10)\n# Train model\nlr_model = lr.fit(trainingData)\n# make predictions\npredictions = lr_model.transform(testData)\n# select example rows to display\npredictions.show(5)\npredictions.printSchema()",
"+-----+--------------------+--------------------+--------------------+----------+\n|label| features| rawPrediction| probability|prediction|\n+-----+--------------------+--------------------+--------------------+----------+\n| 1.0|[20.57,17.77,132....|[-1.9032279000039...|[0.12974357579949...| 1.0|\n| 1.0|[20.29,14.34,135....|[-2.6720690064567...|[0.06464175711414...| 1.0|\n| 1.0|[18.25,19.98,119....|[-2.1792208875297...|[0.10163204110436...| 1.0|\n| 1.0|[16.02,23.24,102....|[0.29558400444961...|[0.57336263675245...| 0.0|\n| 1.0|[15.78,17.89,103....|[-1.9584906497444...|[0.12363048673566...| 1.0|\n+-----+--------------------+--------------------+--------------------+----------+\n\nroot\n |-- label: double (nullable = true)\n |-- features: vector (nullable = true)\n |-- rawPrediction: vector (nullable = true)\n |-- probability: vector (nullable = true)\n |-- prediction: double (nullable = true)\n\n"
],
[
"from pyspark.ml.evaluation import BinaryClassificationEvaluator\n\n#Evaluate model\nevaluator = BinaryClassificationEvaluator(rawPredictionCol=\"rawPrediction\")\nprint(str(evaluator.getMetricName()) + \" : \" + str(evaluator.evaluate(predictions)))\n",
"areaUnderROC : 0.987947269303\n"
],
[
"print(lr.explainParams())",
"elasticNetParam: the ElasticNet mixing parameter, in range [0, 1]. For alpha = 0, the penalty is an L2 penalty. For alpha = 1, it is an L1 penalty. (default: 0.0)\nfeaturesCol: features column name (default: features, current: features)\nfitIntercept: whether to fit an intercept term. (default: True)\nlabelCol: label column name (default: label, current: label)\nmaxIter: max number of iterations (>= 0) (default: 100, current: 10)\npredictionCol: prediction column name (default: prediction)\nprobabilityCol: Column name for predicted class conditional probabilities. Note: Not all models output well-calibrated probability estimates! These probabilities should be treated as confidences, not precise probabilities. (default: probability)\nregParam: regularization parameter (>= 0) (default: 0.1)\nthreshold: threshold in binary classification prediction, in range [0, 1]. (default: 0.5)\ntol: the convergence tolerance for iterative algorithms (default: 1e-06)\n"
]
],
[
[
"### Now lets test the Cross Validator with a parameter grid.",
"_____no_output_____"
]
],
[
[
"from pyspark.ml.tuning import ParamGridBuilder, CrossValidator\n\n# Create ParamGrid for Cross Validation\nparamGrid = (ParamGridBuilder()\n .addGrid(lr.regParam, [0.01, 0.1, 0.5, 2.0])\n .addGrid(lr.elasticNetParam, [0.0, 0.5, 1.0])\n .addGrid(lr.maxIter, [1, 10, 100])\n .build())",
"_____no_output_____"
],
[
"# Create 5-fold CrossValidator\ncv = CrossValidator(estimator=lr, estimatorParamMaps=paramGrid, evaluator=evaluator, numFolds=5)\n\n# Run cv\ncvModel = cv.fit(trainingData)",
"_____no_output_____"
],
[
"predictions2 = cvModel.transform(testData)\npredictions2.show(5)\npredictions2.printSchema()",
"+-----+--------------------+--------------------+--------------------+----------+\n|label| features| rawPrediction| probability|prediction|\n+-----+--------------------+--------------------+--------------------+----------+\n| 1.0|[20.57,17.77,132....|[-3.7099755446092...|[0.02389325976166...| 1.0|\n| 1.0|[20.29,14.34,135....|[-5.2965166269030...|[0.00498404666116...| 1.0|\n| 1.0|[18.25,19.98,119....|[-4.8198505720329...|[0.00800342109037...| 1.0|\n| 1.0|[16.02,23.24,102....|[-0.0350601111901...|[0.49123586993146...| 1.0|\n| 1.0|[15.78,17.89,103....|[-4.3766108829897...|[0.01241188939894...| 1.0|\n+-----+--------------------+--------------------+--------------------+----------+\n\nroot\n |-- label: double (nullable = true)\n |-- features: vector (nullable = true)\n |-- rawPrediction: vector (nullable = true)\n |-- probability: vector (nullable = true)\n |-- prediction: double (nullable = true)\n\n"
],
[
"print(str(evaluator.getMetricName()) + \" : \" + str(evaluator.evaluate(predictions)))",
"areaUnderROC : 0.987947269303\n"
]
],
[
[
"### We can see that of of the parameter grid no parameter combination was better than the default one. Unfortunately because of very long running time of CrossValidator and issues with the PySpark Kernel no finer parameter grid has been tested. For those parameter that were the following best combination can be extracted:",
"_____no_output_____"
]
],
[
[
"bestModel = cvModel.bestModel\nprint(\"Best Param <regParam>: {}\".format(bestModel._java_obj.getRegParam()))\nprint(\"Best Param <elasticNetParam>: {}\".format(bestModel._java_obj.getElasticNetParam()))\nprint(\"Best Param <maxIter>: {}\".format(bestModel._java_obj.getMaxIter()))",
"Best Param <regParam>: 0.01\nBest Param <elasticNetParam>: 0.0\nBest Param <maxIter>: 10\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
]
] |
eca97c01ffd9becbf20aaf49045c35ca354c7827 | 135,068 | ipynb | Jupyter Notebook | experiments/cifar-homogeneity/homogeneity_plotter.ipynb | g-benton/hessian-eff-dim | ed2431bc30d3233258bb7147b1c8fdc85c7bf1f0 | [
"Apache-2.0"
] | 34 | 2020-03-05T01:43:29.000Z | 2022-03-20T04:23:00.000Z | experiments/cifar-homogeneity/homogeneity_plotter.ipynb | g-benton/hessian-eff-dim | ed2431bc30d3233258bb7147b1c8fdc85c7bf1f0 | [
"Apache-2.0"
] | 3 | 2020-05-19T16:28:34.000Z | 2022-01-13T14:17:02.000Z | experiments/cifar-homogeneity/homogeneity_plotter.ipynb | g-benton/hessian-eff-dim | ed2431bc30d3233258bb7147b1c8fdc85c7bf1f0 | [
"Apache-2.0"
] | 5 | 2020-03-10T03:15:30.000Z | 2021-09-30T17:57:56.000Z | 444.302632 | 122,896 | 0.926215 | [
[
[
"import torch\nimport math\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport seaborn as sns\n\nimport torch.nn as nn\nimport torch.nn.functional as F\nimport torchvision\nimport torchvision.transforms as transforms\nfrom matplotlib.lines import Line2D\n",
"_____no_output_____"
],
[
"class Net(nn.Module):\n def __init__(self):\n super(Net, self).__init__()\n self.conv1 = nn.Conv2d(3, 6, 5)\n self.pool = nn.MaxPool2d(2, 2)\n self.conv2 = nn.Conv2d(6, 16, 5)\n self.fc1 = nn.Linear(16 * 5 * 5, 120)\n self.fc2 = nn.Linear(120, 84)\n self.fc3 = nn.Linear(84, 10)\n\n def forward(self, x):\n x = self.pool(F.relu(self.conv1(x)))\n x = self.pool(F.relu(self.conv2(x)))\n x = x.view(-1, 16 * 5 * 5)\n x = F.relu(self.fc1(x))\n x = F.relu(self.fc2(x))\n x = self.fc3(x)\n return x",
"_____no_output_____"
],
[
"use_cuda = torch.cuda.is_available()",
"_____no_output_____"
],
[
"model = Net()\n\nsaved_model = torch.load(\"./model.pt\", map_location=('cpu'))\nmodel.load_state_dict(saved_model)\nif use_cuda:\n torch.cuda.set_device(4)\n model = model.cuda()",
"_____no_output_____"
],
[
"sum(p.numel() for p in model.parameters())",
"_____no_output_____"
],
[
"transform = transforms.Compose(\n [transforms.ToTensor(),\n transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])\n\ntrainset = torchvision.datasets.CIFAR10(root='~/datasets/', train=True,\n download=False, transform=transform)\ntrainloader = torch.utils.data.DataLoader(trainset, batch_size=32,\n shuffle=False, num_workers=2)\n\ntestset = torchvision.datasets.CIFAR10(root='~/datasets/', train=False,\n download=False, transform=transform)\ntestloader = torch.utils.data.DataLoader(testset, batch_size=32,\n shuffle=False, num_workers=2)\n\nclasses = ('plane', 'car', 'bird', 'cat',\n 'deer', 'dog', 'frog', 'horse', 'ship', 'truck')",
"_____no_output_____"
],
[
"fpath = \"./\"\n\nfname = \"low_curve_losses.pt\"\nlow_curve_losses = torch.load(fpath + fname)\n\nfname = \"low_curve_losses_test.pt\"\nlow_curve_losses_test = torch.load(fpath + fname)\n\nfname = \"n_diff_low.pt\"\nn_diff_low = torch.load(fpath + fname)\n\nfname = \"n_diff_low_test.pt\"\nn_diff_low_test = torch.load(fpath + fname)\n\nfname = \"high_curve_losses.pt\"\nhigh_curve_losses = torch.load(fpath + fname)\n\nfname = \"high_curve_losses_test.pt\"\nhigh_curve_losses_test = torch.load(fpath + fname)\n\nfname = \"n_diff_high.pt\"\nn_diff_high = torch.load(fpath + fname)\n\nfname = \"n_diff_high_test.pt\"\nn_diff_high_test = torch.load(fpath + fname)\n\nntrain = 50000\nntest = 10000",
"_____no_output_____"
],
[
"std_low_loss = low_curve_losses.std(-1)\nstd_low_loss_test = low_curve_losses_test.std(-1)\n\nstd_low_diff = n_diff_low.std(-1)\nstd_low_diff_test = n_diff_low_test.std(-1)\n\nstd_high_loss = high_curve_losses.std(-1)\nstd_high_loss_test = high_curve_losses_test.std(-1)\n\nstd_high_diff = n_diff_high.std(-1)\nstd_high_diff_test = n_diff_high_test.std(-1)\n",
"_____no_output_____"
],
[
"def plot_curve(dat, npts, axis, cind, ls, errors=True):\n curve = dat.mean(-1).div(npts) \n\n ax[axis].plot(scales, curve,\n color=colors[cind], linestyle=ls,\n linewidth=2.)\n \n if errors:\n stdev = dat.div(npts).std(-1)\n ax[axis].fill_between(scales, curve - stdev, curve + stdev,\n alpha=0.15, color=colors[cind])",
"_____no_output_____"
],
[
"sns.set_style(\"white\")\ncolors = sns.color_palette(\"muted\")\n\nscales = torch.linspace(0, 1., low_curve_losses.shape[0])\n\nfig, ax = plt.subplots(1, 2, figsize=(20, 5))\nplot_curve(low_curve_losses, ntrain, \n axis=0, cind=0, ls=\"-\",\n errors=True)\nplot_curve(low_curve_losses_test, ntest, \n axis=0, cind=0, ls=\"--\",\n errors=True)\nplot_curve(high_curve_losses, ntrain, \n axis=0, cind=1, ls=\"-\",\n errors=True)\nplot_curve(high_curve_losses_test, ntest,\n axis=0, cind=1, ls=\"--\",\n errors=True)\n\nplot_curve(ntrain - n_diff_low, ntrain, \n axis=1, cind=0, ls=\"-\",\n errors=True)\nplot_curve(ntest - n_diff_low_test, ntest, \n axis=1, cind=0, ls=\"--\",\n errors=True)\nplot_curve(ntrain - n_diff_high, ntrain, \n axis=1, cind=1, ls=\"-\",\n errors=True)\nplot_curve(ntest - n_diff_high_test, ntest,\n axis=1, cind=1, ls=\"--\",\n errors=True)\n\nsns.despine()\n\nleg_fs = 22\ntitle_fs = 26\naxis_fs = 24\ntick_fs = 16\nax[0].tick_params('both', labelsize=tick_fs)\nax[1].tick_params('both', labelsize=tick_fs)\n\nax[0].set_xlim(0, 1)\nax[1].set_xlim(0, 1)\n\nax[0].set_xlabel(\"Perturbation Size\", fontsize=axis_fs)\nax[0].set_ylabel(\"Normalized Loss\", fontsize=axis_fs)\nax[1].set_xlabel(\"Perturbation Size\", fontsize=axis_fs)\nax[1].set_ylabel(\"Classification Homogeneity\", fontsize=axis_fs)\n\nfig.subplots_adjust(wspace=0.2)\n\ncustom_lines = [Line2D([0], [0], color=colors[0], lw=2),\n Line2D([0], [0], color=colors[1], lw=2),\n Line2D([0], [0], color='k', lw=2),\n Line2D([0], [0], color='k', lw=2, linestyle=\"--\")]\nax[1].legend(custom_lines, [\"Low Curvature\", \"High Curvature\", \"Train\", \"Test\"],\n bbox_to_anchor=(0.7, -0.17),fancybox=False, shadow=False, ncol=4,\n fontsize=leg_fs)\nplt.savefig(\"./cifar_homog.pdf\", bbox_inches=\"tight\")",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
eca97d134c9051025b289fc0daaef8337b5011e2 | 296,170 | ipynb | Jupyter Notebook | scratch_notebooks/test_imports.ipynb | hdmamin/mytorch | a116065e11b18a552271e8e6b23197df530bdb45 | [
"Apache-2.0"
] | 1 | 2022-02-28T07:57:15.000Z | 2022-02-28T07:57:15.000Z | scratch_notebooks/test_imports.ipynb | hdmamin/mytorch | a116065e11b18a552271e8e6b23197df530bdb45 | [
"Apache-2.0"
] | 4 | 2021-03-04T04:28:48.000Z | 2022-02-26T06:37:01.000Z | scratch_notebooks/test_imports.ipynb | hdmamin/mytorch | a116065e11b18a552271e8e6b23197df530bdb45 | [
"Apache-2.0"
] | null | null | null | 86.146015 | 73,452 | 0.813165 | [
[
[
"%load_ext autoreload\n%autoreload 2\n%matplotlib inline",
"_____no_output_____"
],
[
"from comet_ml import Experiment\nimport gc\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport os\nimport pandas as pd\nfrom sklearn.metrics import (accuracy_score, dcg_score, roc_auc_score, \n precision_score, recall_score)\nimport torch\nimport torch.nn as nn\nfrom torch.utils.data import Dataset, DataLoader\nimport torch.nn.functional as F\nfrom torch.optim import Adam\n\nfrom htools import assert_raises, save, load, hdir\nfrom incendio.core import *\nfrom incendio.callbacks import *\nfrom incendio.metrics import *\nfrom incendio.optimizers import *\nfrom incendio.utils import *",
"_____no_output_____"
],
[
"# Reproducible testing.\nnp.random.seed(0)\ntorch.manual_seed(0)\ntorch.backends.cudnn.deterministic = True",
"_____no_output_____"
],
[
"class Data(Dataset):\n \n def __init__(self, n=64, dim=2):\n self.x = torch.rand(n, dim).float()\n self.y = torch.clamp(\n (self.x[:, 0]*.75 + self.x[:, 1]*.25).round(), 0, 1\n ).abs().unsqueeze(-1)\n \n def __getitem__(self, i):\n return self.x[i], self.y[i]\n \n def __len__(self):\n return len(self.x)",
"_____no_output_____"
],
[
"class EasyDataset(Dataset):\n \n def __init__(self, n=10, scalar=8):\n \"\"\"Larger scalar makes data easier to classify.\"\"\"\n self.x = torch.rand(n).float().unsqueeze(-1)\n self.y = (self.x + torch.randn_like(self.x)/scalar > 0.5).float()\n \n def __getitem__(self, i):\n return self.x[i], self.y[i]\n \n def __len__(self):\n return len(self.x)",
"_____no_output_____"
],
[
"class MulticlassData(Dataset):\n \n def __init__(self, n=64, dim=2):\n self.x = torch.rand(n, dim).float()\n # Integer labels between 0 and 4, inclusive.\n self.y = torch.clamp(\n torch.round(\n torch.randint(6, (n, 1)).float() \n * (self.x[:, 0]*.75 + self.x[:, 1]*.25).unsqueeze(-1)\n ), 0, 4).long().flatten()\n \n def __getitem__(self, i):\n return self.x[i], self.y[i]\n \n def __len__(self):\n return len(self.x)",
"_____no_output_____"
],
[
"ypred_ = torch.rand(5, 2)\ny_ = torch.tensor([0, 1, 1, 0, 1])\nypred_, y_",
"_____no_output_____"
],
[
"class SimpleModel(BaseModel):\n \n def __init__(self, dim):\n super().__init__() \n self.fc1 = nn.Linear(dim, 2)\n self.fc2 = nn.Linear(2, 1)\n \n def forward(self, x):\n x = F.leaky_relu(self.fc1(x))\n return self.fc2(x)",
"_____no_output_____"
],
[
"class GroupedModel(BaseModel):\n \n def __init__(self, dim):\n super().__init__() \n g1 = nn.Sequential(\n nn.Linear(dim, 8),\n nn.LeakyReLU(),\n nn.Linear(8, 4),\n nn.LeakyReLU()\n )\n g2 = nn.Linear(4, 1)\n self.groups = nn.ModuleList([g1, g2])\n \n def forward(self, x):\n for group in self.groups:\n x = group(x)\n return x",
"_____no_output_____"
],
[
"DIM = 2",
"_____no_output_____"
],
[
"snet = SimpleModel(DIM)\nsnet",
"_____no_output_____"
],
[
"optim = variable_lr_optimizer(snet, 2e-3)\noptim",
"_____no_output_____"
],
[
"with assert_raises(ValueError) as ar:\n optim = variable_lr_optimizer(snet, [3e-3, 1e-1])\n optim",
"As expected, got ValueError(Received more learning rates than layer groups.).\n"
],
[
"update_optimizer(optim, 1e-3, 0.5)\noptim",
"_____no_output_____"
],
[
"snet.freeze()\nfor n in range(5):\n snet.unfreeze(n_layers=n)\n print(n, snet.trainable())",
"0 [((2, 2), False), ((2,), False), ((1, 2), False), ((1,), False)]\n1 [((2, 2), False), ((2,), False), ((1, 2), False), ((1,), True)]\n2 [((2, 2), False), ((2,), False), ((1, 2), True), ((1,), True)]\n3 [((2, 2), False), ((2,), True), ((1, 2), True), ((1,), True)]\n4 [((2, 2), True), ((2,), True), ((1, 2), True), ((1,), True)]\n"
],
[
"snet.freeze()\nwith assert_raises(AttributeError) as ar:\n for n in range(3):\n snet.unfreeze(n_groups=n)\n print(n, snet.trainable())",
"As expected, got AttributeError('SimpleModel' object has no attribute 'groups').\n"
]
],
[
[
"# Training",
"_____no_output_____"
]
],
[
[
"from collections.abc import Iterable, Mapping\nfrom functools import partial\n\nfrom htools import flatten",
"_____no_output_____"
],
[
"def is_builtin(x, drop_callables=True):\n def _builtin(x, drop_callables):\n if callable(x) and drop_callables:\n return False\n return x.__class__.__module__ == 'builtins'\n \n builtin = partial(_builtin, drop_callables=drop_callables)\n # Check mapping before iterable because mappings are iterable.\n if isinstance(x, Mapping):\n return builtin(x) and all(builtin(o) for o in flatten(x.items()))\n elif isinstance(x, Iterable):\n return builtin(x) and all(builtin(o) for o in flatten(x))\n return builtin(x)",
"_____no_output_____"
]
],
[
[
"# TODO:\n-maybe add val batch metrics\n\n-maybe add train metrics (batch and/or epoch)",
"_____no_output_____"
]
],
[
[
"class CometCallback(TorchCallback):\n \n def __init__(self, project_name, order=100):\n # High order so this comes after MetricHandler.\n self.project_name = project_name\n self.order = order\n # Define when training begins so reported time is more meaningful.\n self.exp = None\n \n def on_train_begin(self, trainer, epochs, lrs, lr_mult, **kwargs):\n self.exp = Experiment(project_name=self.project_name)\n params = {k: v for k, v in vars(trainer).items() if is_builtin(v)}\n self.exp.log_parameters(\n dict(**params, **kwargs, epochs=epochs, lrs=lrs, lr_mult=lr_mult)\n )\n\n def on_train_end(self, trainer, epoch, val_stats):\n self.exp.end()\n\n def on_epoch_end(self, trainer, epoch, val_stats):\n self.exp.log_metrics(trainer.stats, prefix='train', epoch=epoch)\n self.exp.log_metrics(val_stats, prefix='val', epoch=epoch)",
"_____no_output_____"
],
[
"DIM = 2\nmetrics = [accuracy_score, \n precision_score, \n recall_score, \n percent_positive,\n mean_soft_prediction\n ]\n\n# Model starts out unfrozen and freezes last group startingn with epoch 3.\n# This is not useful but is done here for testing purposes.\ncallbacks = [EarlyStopper('accuracy', 'max', patience=3),\n PerformanceThreshold('recall', 'max', 0.25, skip_epochs=5),\n MetricHistory(),\n ModelUnfreezer({3:1}, 'groups'),\n ModelCheckpoint(),\n CosineLRScheduler(),\n S3Uploader('gg-datascience', 'hmamin/incendio/v1'),\n# CometCallback('incendio-test')\n ]",
"_____no_output_____"
],
[
"train = Data(n=10_000, dim=DIM)\nval = Data(n=30, dim=DIM)\n\ndl_train = DataLoader(train, batch_size=8, shuffle=True)\ndl_val = DataLoader(val, batch_size=8, shuffle=False)",
"_____no_output_____"
],
[
"gnet = GroupedModel(DIM)\nt = Trainer(gnet, train, val, dl_train, dl_val, F.binary_cross_entropy_with_logits, \n 'binary', '../data/v5', optim_type=torch.optim.RMSprop, \n last_act=torch.sigmoid, metrics=metrics, callbacks=callbacks)\nt",
"_____no_output_____"
],
[
"t.callbacks",
"_____no_output_____"
],
[
"# t.save('tmp.pkl')",
"_____no_output_____"
],
[
"# !ls ../data/v5",
"_____no_output_____"
],
[
"# t.load('tmp.pkl')",
"_____no_output_____"
],
[
"# d = load('../data/v1/trainer.pkl')",
"_____no_output_____"
],
[
"t.fit(2, 3e-1, .1, clean=True)",
"2020-08-26 21:21:54,114 [INFO]: RMSprop (\nParameter Group 0\n alpha: 0.99\n centered: False\n eps: 0.001\n lr: 0.03\n momentum: 0\n weight_decay: 0\n\nParameter Group 1\n alpha: 0.99\n centered: False\n eps: 0.001\n lr: 0.3\n momentum: 0\n weight_decay: 0\n)\n2020-08-26 21:21:54,114 [INFO]: Removing files from output directory.\n"
],
[
"!ls ../data/v5",
"best_val_metrics.json history.png train.log\nhistory.csv lrs.png trainer.pkl\n"
],
[
"t.load('trainer.pkl')",
"_____no_output_____"
],
[
"t2 = Trainer.from_file(os.path.join('..', 'data', 'v1', 'trainer.zip'))\nprint(t2)\ndel t2; gc.collect()",
"Object loaded from ../data/v1/trainer.zip.\nTrainer(criterion='binary_cross_entropy_with_logits', out_dir='../data/v1')\n\nDatasets: 300 train rows, 30 val rows\n\nOptimizer: RMSprop (\nParameter Group 0\n alpha: 0.99\n centered: False\n eps: 0.001\n lr: 0.015052040053751204\n momentum: 0\n weight_decay: 0\n\nParameter Group 1\n alpha: 0.99\n centered: False\n eps: 0.001\n lr: 0.030104080107502408\n momentum: 0\n weight_decay: 0\n)\n\nGroupedModel(\n (groups): ModuleList(\n (0): Sequential(\n (0): Linear(in_features=2, out_features=8, bias=True)\n (1): LeakyReLU(negative_slope=0.01)\n (2): Linear(in_features=8, out_features=4, bias=True)\n (3): LeakyReLU(negative_slope=0.01)\n )\n (1): Linear(in_features=4, out_features=1, bias=True)\n )\n))\n"
],
[
"try:\n for i in range(10):\n time.sleep(1)\n print(i)\nexcept KeyboardInterrupt:\n print('Interrupt')",
"0\n1\nInterrupt\n"
]
],
[
[
"### Test is_builtin",
"_____no_output_____"
]
],
[
[
"is_builtin([{'3': t}])",
"_____no_output_____"
],
[
"is_builtin([2,4])",
"_____no_output_____"
],
[
"# classes have class `type` so are always considered builtin (if we specify\n# drop_callable=False). Can't remember what my original use case was so not\n# sure if this is desired.\nis_builtin(F.relu, False), is_builtin(nn.ReLU(), False)",
"_____no_output_____"
],
[
"print(t.optim_type)\nis_builtin(t.optim_type), is_builtin(t.optim_type, False)",
"<class 'torch.optim.rmsprop.RMSprop'>\n"
],
[
"is_builtin(torch.sigmoid), is_builtin(torch.sigmoid, False)",
"_____no_output_____"
],
[
"is_builtin([1,2,3])",
"_____no_output_____"
],
[
"is_builtin([TorchCallback, Trainer]), is_builtin([TorchCallback, Trainer], False)",
"_____no_output_____"
],
[
"is_builtin({'a': 1, 'c': 33, 'd': [2, 4]})",
"_____no_output_____"
],
[
"is_builtin({'a': 1, 'c': 33, 't': t.optim_type}), is_builtin({'a': 1, 'c': 33, 't': t.optim_type}, False)",
"_____no_output_____"
],
[
"d = {k: v for k, v in vars(t).items() if is_builtin(v)}\nd",
"_____no_output_____"
],
[
"d2 = dict(c=3333, z=[44, 55], x=True)\n{**d, **d2, 'e': 44}",
"_____no_output_____"
],
[
"dict(d, **d2, abc=33, xyz='abc')",
"_____no_output_____"
]
],
[
[
"## Sawtooth Scheduler",
"_____no_output_____"
]
],
[
[
"DIM = 2\nmetrics = [accuracy_score, \n precision_score, \n recall_score]\n\ncallbacks = [MetricHistory(),\n AdaptiveSawtoothScheduler(1e-2, .8)]",
"_____no_output_____"
],
[
"train = EasyDataset(400, 100)\nval = EasyDataset(40, 100)\n\ndl_train = DataLoader(train, batch_size=8, shuffle=True)\ndl_val = DataLoader(val, batch_size=8, shuffle=False)",
"_____no_output_____"
],
[
"snet = SimpleModel(1)\nt = Trainer(snet, train, val, dl_train, dl_val, \n F.binary_cross_entropy_with_logits, 'multiclass', '../data/v1', \n metrics=metrics, callbacks=callbacks)\nt",
"_____no_output_____"
],
[
"t.fit(5, 1e-1, clean=True)",
"2020-03-25 21:17:05,968 [INFO]: Adam (\nParameter Group 0\n amsgrad: False\n betas: (0.9, 0.999)\n eps: 0.001\n lr: 0.1\n weight_decay: 0\n)\n2020-03-25 21:17:05,968 [INFO]: Removing files from output directory.\n"
],
[
"t.callbacks['AdaptiveSawtoothScheduler'].plot_lrs('adaptive_sawtooth_lrs.png')",
"_____no_output_____"
]
],
[
[
"## Multiclass classification",
"_____no_output_____"
]
],
[
[
"class SimpleMulticlassModel(BaseModel):\n \n def __init__(self, dim, classes):\n super().__init__() \n self.fc1 = nn.Linear(dim, 10)\n self.fc2 = nn.Linear(10, classes)\n \n def forward(self, x):\n x = F.leaky_relu(self.fc1(x))\n return self.fc2(x)",
"_____no_output_____"
],
[
"DIM = 2\nmetrics = [accuracy_score,\n mean_soft_prediction\n ]\n\ncallbacks = [\n# EarlyStopper('accuracy', 'max', patience=10),\n PerformanceThreshold('loss', 'min', 2, skip_epochs=5),\n MetricHistory(),\n ModelCheckpoint(),\n MetricHistory(),\n CosineLRScheduler(),\n S3Uploader('gg-datascience', 'hmamin/incendio/v2')\n ]",
"_____no_output_____"
],
[
"train = MulticlassData(n=88, dim=DIM)\nval = MulticlassData(n=40, dim=DIM)\n\ndl_train = DataLoader(train, batch_size=8, shuffle=True)\ndl_val = DataLoader(val, batch_size=8, shuffle=False)",
"_____no_output_____"
],
[
"smnet = SimpleMulticlassModel(DIM, 5)\nt = Trainer(smnet, train, val, dl_train, dl_val, \n F.cross_entropy, 'multiclass', '../data/v1',\n last_act=F.softmax, metrics=metrics, callbacks=callbacks)\nt",
"_____no_output_____"
],
[
"t.fit(20, .3)",
"Adam (\nParameter Group 0\n amsgrad: False\n betas: (0.9, 0.999)\n eps: 0.001\n lr: 0.3\n weight_decay: 0\n)\n"
]
],
[
[
"## Easy binary classification",
"_____no_output_____"
]
],
[
[
"DIM = 2\nmetrics = [accuracy_score,\n mean_soft_prediction\n ]\n\n# Model starts out unfrozen and freezes last group startingn with epoch 3.\n# This is not useful but is done here for testing purposes.\ncallbacks = [\n MetricHistory(),\n ModelCheckpoint(),\n MetricHistory(),\n]",
"_____no_output_____"
],
[
"train = EasyDataset(400, 100)\nval = EasyDataset(40, 100)\n\ndl_train = DataLoader(train, batch_size=8, shuffle=True)\ndl_val = DataLoader(val, batch_size=8, shuffle=False)",
"_____no_output_____"
],
[
"snet = SimpleModel(1)\nt = Trainer(snet, train, val, dl_train, dl_val, \n F.binary_cross_entropy_with_logits, 'multiclass', '../data/v1', \n last_act=torch.sigmoid, metrics=metrics, callbacks=callbacks)\nt",
"_____no_output_____"
],
[
"t.fit(10, .1)",
"Adam (\nParameter Group 0\n amsgrad: False\n betas: (0.9, 0.999)\n eps: 0.001\n lr: 0.1\n weight_decay: 0\n)\n"
]
],
[
[
"### Scratch",
"_____no_output_____"
]
],
[
[
"import inspect",
"_____no_output_____"
],
[
"[getattr(t, k, None) for k in inspect.signature(Trainer).parameters]",
"_____no_output_____"
],
[
"from spellotape.dl import inverse_sigmoid",
"_____no_output_____"
],
[
"inverse_sigmoid(.625)",
"_____no_output_____"
],
[
"*x, y = next(iter(dl_train))\nx, y",
"_____no_output_____"
],
[
"yhat = smnet(*x)\nyhat",
"_____no_output_____"
],
[
"y.shape, yhat.shape",
"_____no_output_____"
],
[
"F.softmax(yhat, dim=-1)",
"_____no_output_____"
],
[
"yhat.shape, y.shape",
"_____no_output_____"
],
[
"F.cross_entropy(yhat, y)",
"_____no_output_____"
],
[
"t = Trainer(smnet, train, val, dl_train, dl_val, F.cross_entropy, 'multiclass',\n '../data/v2', 'datascience-delphi-dev', last_act=partial(F.softmax, dim=-1),\n metrics=metrics, callbacks=callbacks)\nt",
"_____no_output_____"
],
[
"import time\nfrom functools import wraps\n\ndef catch_keyboard_interrupt(func):\n @wraps(func)\n def wrapper(*args, **kwargs):\n try:\n func(*args, **kwargs)\n except KeyboardInterrupt:\n print('interrupt', dir(func))\n # This sets a class variable, not an instance var. Works but not ideal.\n setattr(eval(Foo.bar.__qualname__.split('.')[0]), 'stop', True)\n return\n return wrapper\n\n\ndef catch_method_interrupt(meth_name):\n def decorator(cls):\n func = getattr(cls, meth_name)\n print(func)\n @wraps(func)\n def wrapper(*args, **kwargs):\n print(args, kwargs)\n try:\n func(*args, **kwargs)\n except KeyboardInterrupt:\n print('interrupt', dir(func))\n # This sets a class variable, not an instance var. Works but not ideal.\n setattr(cls, 'stop', True)\n return\n return wrapper\n return decorator\n\n\nclass Foo:\n \n def __init__(self, a):\n self.a = a\n \n @catch_keyboard_interrupt\n def bar(self, b=3):\n for i in range(b):\n time.sleep(1)\n print(self.a)\n \n\n@catch_method_interrupt('train')\nclass Fizz:\n\n def __init__(self, a):\n self.a = a\n \n def walk(self, t=5):\n for i in range(t):\n time.sleep(1)\n print(i)\n \n def train(self, epochs):\n for e in epochs:\n print(e)\n time.sleep(1)",
"<function Fizz.train at 0x14264a0e0>\n"
],
[
"f = Foo(5)\nf.__dict__",
"_____no_output_____"
],
[
"f.bar()",
"5\ninterrupt ['__annotations__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__']\n"
],
[
"f.__dict__",
"_____no_output_____"
],
[
"Foo.stop",
"_____no_output_____"
],
[
"f.stop",
"_____no_output_____"
],
[
"fizz = Fizz(6)\nfizz.walk()",
"(6,) {}\n"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
eca97dcb991bba8f37b060f9fa4f3af2e35ca92e | 19,689 | ipynb | Jupyter Notebook | src/test/ClassificationDeposit.ipynb | giorbernal/dsbase | 1e7ebc61ad19b5da9443cbe493ebfcc95ef87118 | [
"MIT"
] | null | null | null | src/test/ClassificationDeposit.ipynb | giorbernal/dsbase | 1e7ebc61ad19b5da9443cbe493ebfcc95ef87118 | [
"MIT"
] | null | null | null | src/test/ClassificationDeposit.ipynb | giorbernal/dsbase | 1e7ebc61ad19b5da9443cbe493ebfcc95ef87118 | [
"MIT"
] | null | null | null | 20.36091 | 155 | 0.555742 | [
[
[
"# Binary Classification: Deposit Bank - Marketing",
"_____no_output_____"
]
],
[
[
"import sys\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n%matplotlib inline",
"_____no_output_____"
],
[
"from sklearn.metrics import classification_report\nfrom sklearn.metrics import confusion_matrix",
"_____no_output_____"
],
[
"sys.path.append('../main/')",
"_____no_output_____"
],
[
"from sklearn.model_selection import train_test_split\nfrom dsbase.ModelDSBase import ModelDSBaseWrapper",
"_____no_output_____"
],
[
"df = pd.read_csv('../../datasets/deposit_ml.csv')",
"_____no_output_____"
],
[
"df_r = pd.read_csv('../../datasets/deposit_ml_reduced.csv')",
"_____no_output_____"
],
[
"X = df.drop(labels='y', axis=1).values\ny = df['y'].values",
"_____no_output_____"
],
[
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.33, random_state=42)",
"_____no_output_____"
]
],
[
[
"\n## SVM Binary Classifier (It takes too much time, although the results are quite good)",
"_____no_output_____"
]
],
[
[
"# Reduced dataset\nX_r = df_r.drop(labels='y', axis=1).values\ny_r = df_r['y'].values\n\nX_train_r, X_test_r, y_train_r, y_test_r = train_test_split(X_r, y_r, test_size=0.33, random_state=42)",
"_____no_output_____"
],
[
"from dsbase.models.classification.SVMClassificationDSBase import SVMClassificationDSBaseModelParamsToMap\nfrom dsbase.models.classification.SVMClassificationDSBase import SVMClassificationDSBaseModel",
"_____no_output_____"
],
[
"params = SVMClassificationDSBaseModelParamsToMap()\nsvmc = ModelDSBaseWrapper('SVM',X_train_r,y_train_r,X_test_r,y_test_r,[5,10,15],SVMClassificationDSBaseModel, params)",
"_____no_output_____"
],
[
"svmc.train()",
"_____no_output_____"
],
[
"lcsvmc = svmc.getLearningCurves()",
"_____no_output_____"
],
[
"plt.plot(lcsvmc[0,:],'b',lcsvmc[1,:],'r')",
"_____no_output_____"
],
[
"svmc.getScore()",
"_____no_output_____"
],
[
"svmc.save()",
"_____no_output_____"
],
[
"svmc.close()",
"_____no_output_____"
],
[
"recoveredSvmc = SVMClassificationDSBaseModel('SVM2',None,None,None,None,None)",
"_____no_output_____"
],
[
"recoveredSvmc.load()",
"_____no_output_____"
],
[
"recoveredSvmc.predict(X_r[510:515,:])",
"_____no_output_____"
],
[
"y_r[510:515]",
"_____no_output_____"
],
[
"recoveredSvmc.close()",
"_____no_output_____"
]
],
[
[
"## Random Forest Classificator",
"_____no_output_____"
]
],
[
[
"from dsbase.models.classification.RandomForestClassificationDSBase import RandomForestClassificationDSBaseModel\nfrom dsbase.models.classification.RandomForestClassificationDSBase import RandomForestClassificationDSBaseModelParamsToMap",
"_____no_output_____"
],
[
"params = RandomForestClassificationDSBaseModelParamsToMap(100,15)\nrfc = ModelDSBaseWrapper('RF',X_train,y_train,X_test,y_test,[70,75,80,85,90,95,100],RandomForestClassificationDSBaseModel,params)",
"_____no_output_____"
],
[
"rfc.train()",
"_____no_output_____"
],
[
"lcrfc = rfc.getLearningCurves()",
"_____no_output_____"
],
[
"plt.plot(lcrfc[0,:],'b',lcrfc[1,:],'r')",
"_____no_output_____"
]
],
[
[
"Quite Overfitting!!",
"_____no_output_____"
]
],
[
[
"rfc.getScore()",
"_____no_output_____"
],
[
"rfc.save()",
"_____no_output_____"
],
[
"rfc.close()",
"_____no_output_____"
],
[
"recoveredRfc = RandomForestClassificationDSBaseModel('RF6',None,None,None,None,None)",
"_____no_output_____"
],
[
"recoveredRfc.load()",
"_____no_output_____"
],
[
"recoveredRfc.predict(X[510:515,:])",
"_____no_output_____"
],
[
"y[510:515]",
"_____no_output_____"
],
[
"print(classification_report(rfc.model.y_test,rfc.predict(rfc.model.X_test)))",
"_____no_output_____"
],
[
"print(confusion_matrix(rfc.model.y_test,rfc.predict(rfc.model.X_test)))",
"_____no_output_____"
]
],
[
[
"## Ada Boosting Classificator",
"_____no_output_____"
]
],
[
[
"from dsbase.models.classification.AdaBoostClassificationDSBase import AdaBoostClassificationDSBaseModelParamsToMap\nfrom dsbase.models.classification.AdaBoostClassificationDSBase import AdaBoostClassificationDSBaseModel",
"_____no_output_____"
],
[
"params = AdaBoostClassificationDSBaseModelParamsToMap(100,1.0)\nabc = ModelDSBaseWrapper('AB',X_train,y_train,X_test,y_test,[70,75,80,85,90,95,100],AdaBoostClassificationDSBaseModel,params)",
"_____no_output_____"
],
[
"abc.train()",
"_____no_output_____"
],
[
"lcabc = abc.getLearningCurves()",
"_____no_output_____"
],
[
"plt.plot(lcabc[0,:],'b',lcabc[1,:],'r')",
"_____no_output_____"
],
[
"abc.getScore()",
"_____no_output_____"
],
[
"abc.save()",
"_____no_output_____"
],
[
"abc.close()",
"_____no_output_____"
],
[
"recoveredAbc = AdaBoostClassificationDSBaseModel('AB6',None,None,None,None,None)",
"_____no_output_____"
],
[
"recoveredAbc.load()",
"_____no_output_____"
],
[
"recoveredAbc.predict(X[510:515,:])",
"_____no_output_____"
],
[
"y[510:515]",
"_____no_output_____"
],
[
"print(classification_report(abc.model.y_test,abc.predict(abc.model.X_test)))",
"_____no_output_____"
],
[
"print(confusion_matrix(abc.model.y_test,abc.predict(abc.model.X_test)))",
"_____no_output_____"
]
],
[
[
"# XGradient Boosting Classification ",
"_____no_output_____"
]
],
[
[
"from dsbase.models.classification.XGradientBoostingClassificationDSBase import XGradientBoostingClassificationDSBaseModelParamsToMap\nfrom dsbase.models.classification.XGradientBoostingClassificationDSBase import XGradientBoostingClassificationDSBaseModel",
"_____no_output_____"
],
[
"params = XGradientBoostingClassificationDSBaseModelParamsToMap()\nxgbc = ModelDSBaseWrapper('XGBC',X_train,y_train,X_test,y_test,[70,75,80,85,90,95,100],XGradientBoostingClassificationDSBaseModel,params)",
"_____no_output_____"
],
[
"xgbc.train()",
"_____no_output_____"
],
[
"lcxgbc=xgbc.getLearningCurves()",
"_____no_output_____"
],
[
"plt.plot(lcxgbc[0,:],'b',lcxgbc[1,:],'r')",
"_____no_output_____"
],
[
"xgbc.getScore()",
"_____no_output_____"
],
[
"xgbc.save()",
"_____no_output_____"
],
[
"xgbc.close()",
"_____no_output_____"
],
[
"recoveredXgbc = XGradientBoostingClassificationDSBaseModel('XGBC6',None,None,None,None,None)",
"_____no_output_____"
],
[
"recoveredXgbc.load()",
"_____no_output_____"
],
[
"recoveredXgbc.predict(X[510:515,:])",
"_____no_output_____"
],
[
"y[510:515]",
"_____no_output_____"
],
[
"print(classification_report(xgbc.model.y_test,xgbc.predict(xgbc.model.X_test)))",
"_____no_output_____"
],
[
"print(confusion_matrix(xgbc.model.y_test,xgbc.predict(xgbc.model.X_test)))",
"_____no_output_____"
]
],
[
[
"# Light Gradient Boosting Classification",
"_____no_output_____"
]
],
[
[
"from dsbase.models.classification.LightGradientBoostingClassificationDSBase import LightGradientBoostingClassificationDSBaseModelParamsToMap\nfrom dsbase.models.classification.LightGradientBoostingClassificationDSBase import LightGradientBoostingClassificationDSBaseModel",
"_____no_output_____"
],
[
"params = LightGradientBoostingClassificationDSBaseModelParamsToMap()\nlgbc = ModelDSBaseWrapper('LGBC',X_train,y_train,X_test,y_test,[70,75,80,85,90,95,100],LightGradientBoostingClassificationDSBaseModel,params)",
"_____no_output_____"
],
[
"lgbc.train()",
"_____no_output_____"
],
[
"lclgbc=lgbc.getLearningCurves()",
"_____no_output_____"
],
[
"plt.plot(lclgbc[0,:],'b',lclgbc[1,:],'r')",
"_____no_output_____"
],
[
"lgbc.getScore()",
"_____no_output_____"
],
[
"lgbc.save()",
"_____no_output_____"
],
[
"lgbc.close()",
"_____no_output_____"
],
[
"recoveredlgbc = LightGradientBoostingClassificationDSBaseModel('LGBC6',None,None,None,None,None)",
"_____no_output_____"
],
[
"recoveredlgbc.load()",
"_____no_output_____"
],
[
"recoveredlgbc.predict(X[510:515,:])",
"_____no_output_____"
],
[
"y[510:515]",
"_____no_output_____"
],
[
"print(classification_report(lgbc.model.y_test,lgbc.predict(lgbc.model.X_test)))",
"_____no_output_____"
],
[
"print(confusion_matrix(lgbc.model.y_test,lgbc.predict(lgbc.model.X_test)))",
"_____no_output_____"
]
],
[
[
"## DNN Classification (Keras)",
"_____no_output_____"
]
],
[
[
"from sklearn.preprocessing import MinMaxScaler\n\n# Normalizing\nscalerX=MinMaxScaler()\nX_s = scalerX.fit_transform(X)\nscalery=MinMaxScaler()\ny_s = scalery.fit_transform(y.reshape(-1, 1))\n\nX_s_train, X_s_test, y_s_train, y_s_test = train_test_split(X_s, y_s, test_size=0.33, random_state=42)",
"_____no_output_____"
],
[
"from dsbase.models.classification.DNNClassificationKerasDSBase import DNNClassificationKerasDSBaseParamsToMap\nfrom dsbase.models.classification.DNNClassificationKerasDSBase import DNNClassificationKerasDSBaseModel",
"_____no_output_____"
],
[
"params = DNNClassificationKerasDSBaseParamsToMap(layers=[40,20,10,5], alpha=1e-2, beta1=0.9, beta2=0.999, epsilon=1e-9, batch_size=64, epochs=150)\ndnnkc = ModelDSBaseWrapper('DNNKC',X_s_train,y_s_train,X_s_test,y_s_test,[70,80,90,100],DNNClassificationKerasDSBaseModel,params)",
"_____no_output_____"
],
[
"dnnkc.train()",
"_____no_output_____"
],
[
"lcdnnkc=dnnkc.getLearningCurves()",
"_____no_output_____"
],
[
"plt.plot(lcdnnkc[0,:],'b',lcdnnkc[1,:],'r')",
"_____no_output_____"
],
[
"dnnkc.getScore()",
"_____no_output_____"
],
[
"dnnkc.save()",
"_____no_output_____"
],
[
"dnnkc.close()",
"_____no_output_____"
],
[
"recoveredDnnkc = DNNClassificationKerasDSBaseModel('DNNKC6',None,None,None,None,None)",
"_____no_output_____"
],
[
"recoveredDnnkc.load()",
"_____no_output_____"
],
[
"recoveredDnnkc.predict(X_s[510:515,:])",
"_____no_output_____"
],
[
"y_s[510:515]",
"_____no_output_____"
],
[
"print(classification_report(dnnkc.model.y_s_test,dnnkc.predict(dnnkc.model.X_s_test)))",
"_____no_output_____"
],
[
"print(confusion_matrix(dnnkc.model.y_s_test,dnnkc.predict(dnnkc.model.X_s_test)))",
"_____no_output_____"
]
],
[
[
"# End of Evaluation! ",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
]
] |
eca97e5f80a6119a1742849773ef6631aefe5ad4 | 148,428 | ipynb | Jupyter Notebook | content/ch-appendix/qiskit.ipynb | daiki0623/qiskit-textbook | 9a87613ced3d2a9decfa41fd4656342bd57509e6 | [
"Apache-2.0"
] | null | null | null | content/ch-appendix/qiskit.ipynb | daiki0623/qiskit-textbook | 9a87613ced3d2a9decfa41fd4656342bd57509e6 | [
"Apache-2.0"
] | null | null | null | content/ch-appendix/qiskit.ipynb | daiki0623/qiskit-textbook | 9a87613ced3d2a9decfa41fd4656342bd57509e6 | [
"Apache-2.0"
] | null | null | null | 39.070282 | 1,259 | 0.5134 | [
[
[
"## Qiskitの文法の基礎",
"_____no_output_____"
],
[
"### インストール\n\nQiskitは、あなたが量子コンピューティングで必要とするすべてを実行してくれるPythonのパッケージです。\n\nもしまだお持ちでないのなら、インストールする必要があります。インストールしてあるのなら、インポートする必要があります。\n\n一般的に、Qiskitをインストールするには2つのステップが必要です。最初のステップは、Anacondaのインストールです。Anacondaは、あなたが必要とするほぼすべての依存関係を搭載したのPythonパッケージです。Anacondaをインストールすれば、ターミナルで以下のコマンドを実行することでQiskitをインストールできます。\n```\npip install qiskit\n```\nインストール方法の詳細については、 [この文書](https://qiskit.org/documentation/install.html) を参照してください。\n\n**注:この後のセクションは、既に量子コンピューティングの基礎を知っている人向けです。** 後続の章に直ぐに移動してそのコンセプトを利用したい読者が利用できるものです。その他の読者は、まず[Introduction to Python and Jupyter notebooks](../ch-prerequisites/python-and-jupyter-notebooks.html) を読み、次に [Chapter 1](../ch-states/introduction.html) の最初に直接移動すべきです。",
"_____no_output_____"
],
[
"### 量子回路",
"_____no_output_____"
]
],
[
[
"from qiskit import *",
"_____no_output_____"
]
],
[
[
"Qiskitの心臓部といえるオブジェクトは量子回路です。作り方は以下の通りです。ここでは `qc` としましょう。",
"_____no_output_____"
]
],
[
[
"qc = QuantumCircuit()",
"_____no_output_____"
]
],
[
[
"この回路は、量子ビットも出力もなく、現時点で完全に空です。",
"_____no_output_____"
],
[
"### 量子レジスター",
"_____no_output_____"
],
[
"回路を意味あるものにするためには、量子ビットのレジスタを定義する必要があります。これには、`QuantumRegister` オブジェクトを使用します。 例えば、2つの量子ビットで構成されるレジスターを定義し、それを `qr` としましょう。",
"_____no_output_____"
]
],
[
[
"qr = QuantumRegister(2,'a')",
"_____no_output_____"
]
],
[
[
"オプションで、 レジスタに`'a'` といった名前をつけることもできます。\n\n`add_register` メソッドを使うことで、レジスタを回路に追加できます。また、回路オブジェクトの `qregs` 変数をチェックすることで、追加されたことを確認できます。このガイドは [Jupyter notebook](https://jupyter.org/) を使用しています。Jupyter notebookでは、セルの最終行の出力がセルの下に表示されます:",
"_____no_output_____"
]
],
[
[
"qc.add_register( qr )\n\nqc.qregs",
"_____no_output_____"
]
],
[
[
"回路はいくつかの量子ビットを持っていますので、別の属性 `draw()`、を使って、回路がどの様に見えるか確認しましょう。",
"_____no_output_____"
]
],
[
[
"qc.draw()",
"_____no_output_____"
]
],
[
[
"量子ビットは彼らの旅を始める準備ができましたが、今は単純に状態 $\\left|0\\right\\rangle$ にいるだけです。",
"_____no_output_____"
],
[
"#### ゲートの適用",
"_____no_output_____"
],
[
"何かを起こさせるには、ゲートを追加する必要があります。例えば、 `h()` を試してみましょう。",
"_____no_output_____"
]
],
[
[
"qc.h()",
"_____no_output_____"
]
],
[
[
"この操作をどの量子ビットに作用させるか指定しなかったため、エラーが発生しました。レジスタ `qr` 内の2つの量子ビットは、`qr[0]` と `qr[1]` として別々にアクセスできます。",
"_____no_output_____"
]
],
[
[
"qc.h(qr[0])",
"_____no_output_____"
]
],
[
[
"上記出力は無視してください。セルの最終行に `=` がない場合、Jupyter notebookはこの様な出力をします。上の場合、QiskitにてHadamard が定義されていることを伝えています。この出力を抑制したい場合は、 `;` を使用します。\n\n`cx` を使って、制御NOTを追加することもできます。これは2つの引数、制御量子ビットとターゲット量子ビットを必要とします。",
"_____no_output_____"
]
],
[
[
"qc.cx(qr[0], qr[1]);",
"_____no_output_____"
]
],
[
[
"回路を表示させましょう。",
"_____no_output_____"
]
],
[
[
"qc.draw()",
"_____no_output_____"
]
],
[
[
"### Statevector simulator",
"_____no_output_____"
],
[
"回路の出力を実際に見ることができるステージにやってきました。具体的には、'statevector simulator' を使用して、2つの量子ビットの状態ベクトルに何が起きているのかを見てみます。\n\n次の行を使用して、シミュレーターを準備します。",
"_____no_output_____"
]
],
[
[
"vector_sim = Aer.get_backend('statevector_simulator')",
"_____no_output_____"
]
],
[
[
"Qiskitでは、量子プログラムを実際に実行するもの(シミュレータもしくは実量子デバイス)を *バックエンド* と呼びます。バックエンドに対しジョブを指定するには、対応するバックエンド・オブジェクトを設定する必要があります。\n\n必要なシミュレータは、Qiskitの`Aer`と呼ばれる部分に定義されています。Aerの`get_backend()` メソッドに必要なシミュレータ名を与えることで、必要なバックエンド・オブジェクトを取得できます。今回の名前は `'statevector_simulator'` です。\n\nAerで利用可能な全シミュレータのリストは、以下の様に取得できます。",
"_____no_output_____"
]
],
[
[
"Aer.backends()",
"_____no_output_____"
]
],
[
[
"これらのシミュレータは全部 'ローカル' 、つまりQiskitがインストールされたマシン上で実行されます。あなたのマシン上で使う場合、IBMQのユーザー同意書に同意せずに実行することができます。\n\nQiskitの `execute` コマンドでシミュレーションを実行できます。このコマンドには、実行される回路と実行する「バックエンド」(今回はシミュレータ)が必要です。",
"_____no_output_____"
]
],
[
[
"job = execute(qc, vector_sim)",
"_____no_output_____"
]
],
[
[
"このコマンドは、`job`と呼ばれるこの実行を操作するオブジェクトを生成します。我々が必要なのは、結果を抽出することです。具体的には、状態ベクトルが欲しいのです。",
"_____no_output_____"
]
],
[
[
"ket = job.result().get_statevector()\nfor amplitude in ket:\n print(amplitude)",
"(0.7071067811865476+0j)\n0j\n0j\n(0.7071067811865475+0j)\n"
]
],
[
[
"これはBell状態 $\\left( \\left|00\\right\\rangle + \\left|11\\right\\rangle \\right)/\\sqrt{2}$ に対するベクトルで、私たちがこの回路から期待するものです。",
"_____no_output_____"
],
[
"私たちはうまく状態ベクトルを定義できましたが、Qiskitの別の特徴をお見せしましょう。それは次の様に、任意の純粋状態で回路を初期化することが可能なのです。",
"_____no_output_____"
]
],
[
[
"new_qc = QuantumCircuit(qr)\n\nnew_qc.initialize(ket, qr)",
"_____no_output_____"
]
],
[
[
"### 古典レジスタと qasm simulator",
"_____no_output_____"
],
[
"上のシミュレーションでは、statevectorを取り上げました。これは本物の量子コンピューターから得られるものではありません。本物には測定が必要です。測定を操作するためには、結果がどこに保存されるか定義する必要があります。これを実現するのが `ClassicalRegister` です。2つの量子ビットを測定するため、2ビットの古典レジスタを定義しましょう:",
"_____no_output_____"
]
],
[
[
"cr = ClassicalRegister(2,'creg')\n\nqc.add_register(cr)",
"_____no_output_____"
]
],
[
[
"ここで、量子回路の`measure` メソッドを使用します。このメソッドは、測定される量子ビットと結果が書き込まれるビットの、2つの引数が必要です。\n\n両方の量子ビットを測定し、その結果を別々のビットに書き込みましょう。",
"_____no_output_____"
]
],
[
[
"qc.measure(qr[0],cr[0])\nqc.measure(qr[1],cr[1])\n\nqc.draw()",
"_____no_output_____"
]
],
[
[
"本物の量子装置をエミュレートする効果のあるローカル・シミュレータ上で、この回路を実行できます このためには、`execute` 関数に別の入力`shots`を追加する必要があります。`shots` は、統計を取るためにこの回路を実行する回数を指定します。指定しない場合は、デフォルトの1024が使用されます。",
"_____no_output_____"
]
],
[
[
"emulator = Aer.get_backend('qasm_simulator')\n\njob = execute( qc, emulator, shots=8192 )",
"_____no_output_____"
]
],
[
[
"本質的な結果は、Pythonのdictionary形式のオブジェクトになります。`print`を使用すると、これを表示できます。",
"_____no_output_____"
]
],
[
[
"hist = job.result().get_counts()\nprint(hist)",
"{'00': 4136, '11': 4056}\n"
]
],
[
[
"Qiskitにこの結果をヒストグラムとしてプロットさせることもできます。",
"_____no_output_____"
]
],
[
[
"from qiskit.visualization import plot_histogram\n\nplot_histogram(hist)",
"_____no_output_____"
]
],
[
[
"互換性のあるバックエンドに対しては、結果を並べたリストを要求し、取得することもできます。",
"_____no_output_____"
]
],
[
[
"job = execute(qc, emulator, shots=10, memory=True)\nsamples = job.result().get_memory()\nprint(samples)",
"['00', '11', '00', '11', '00', '00', '11', '11', '00', '11']\n"
]
],
[
[
"ビットには右から左にラベルが付いていることに注意してください。従って、`cr[0]` は最も右端にあるものになります。 次の例は、`7`と番号付けされた量子ビットだけにPauli $X$ ゲートがあり、`7` と番号付けされたビットに出力が格納される、8量子ビットの回路です。",
"_____no_output_____"
]
],
[
[
"qubit = QuantumRegister(8)\nbit = ClassicalRegister(8)\ncircuit = QuantumCircuit(qubit,bit)\n\ncircuit.x(qubit[7])\ncircuit.measure(qubit,bit) # this is a way to do all the qc.measure(qr8[j],cr8[j]) at once\n\nexecute(circuit, emulator, shots=8192).result().get_counts()",
"_____no_output_____"
]
],
[
[
"`1` は左に出現します。\n\nこの番号付けは、整数を表現する時のビットの役割を反映しています。\n\n\n\n$$ b_{n-1} ~ b_{n-2} ~ \\ldots ~ b_1 ~ b_0 = \\sum_j ~ b_j ~ 2^j $$\n\n\n\nつまり、結果として得られた文字列は、`7`と番号付けされたビットに`1` があるので、 $2^7$ のバイナリ表現です。",
"_____no_output_____"
],
[
"### 簡略表記",
"_____no_output_____"
],
[
"複数の量子・古典レジスターを回路に追加することができます。しかし、それぞれが一つしか必要ない場合は、簡略表記を使うことができます。\n\n例えば、次を考えましょう。",
"_____no_output_____"
]
],
[
[
"qc = QuantumCircuit(3)",
"_____no_output_____"
]
],
[
[
"`QuantumCircuit` の単独引数は、必要な量子ビットの数と解釈されます。つまり、これは、3量子ビットを含む単一量子レジスタを持ち、古典レジスタを持たない回路です。\n\nゲートを追加する時、3つの量子ビットは、インデックス、0、1、2で参照できます。以下は、Hadamardを量子ビット1に追加した例です。",
"_____no_output_____"
]
],
[
[
"qc.h(1)\n\nqc.draw()",
"_____no_output_____"
]
],
[
[
"量子レジスタと古典レジスタを両方回路に定義するためには、 `QuantumCircuit` に2つの引数を与えます。最初の引数は量子ビットの数として、2番目はビットの数として解釈されます。以下は、出力に単一古典ビットを持つ2量子ビット回路の例です。",
"_____no_output_____"
]
],
[
[
"qc = QuantumCircuit(2,1)",
"_____no_output_____"
]
],
[
[
"これを実際に見てみるために、単純な回路を使用します。測定を行う際には、インデックスを使って古典レジスタのビットを参照することに注意してください。",
"_____no_output_____"
]
],
[
[
"qc.h(0)\nqc.cx(0,1)\nqc.measure(1,0)\n\nqc.draw()",
"_____no_output_____"
]
],
[
[
"### カスタム・ゲートの作成",
"_____no_output_____"
],
[
"これまで見てきたように、異なる回路を組み合わせてより大きな回路を作成することができます。また、より洗練されたバージョンとして、カスタムゲートを作成することもできます。例えば、量子ビット1にプロセスを仲介させて、量子ビット0と2の間で `cx` を実装する回路を次に示します。",
"_____no_output_____"
]
],
[
[
"sub_circuit = QuantumCircuit(3, name='toggle_cx')\nsub_circuit.cx(0,1)\nsub_circuit.cx(1,2)\nsub_circuit.cx(0,1)\nsub_circuit.cx(1,2)\n\nsub_circuit.draw()",
"_____no_output_____"
]
],
[
[
"これを1つのゲートに変換して:",
"_____no_output_____"
]
],
[
[
"toggle_cx = sub_circuit.to_instruction()",
"_____no_output_____"
]
],
[
[
"その後、選択した量子ビットのセットを使って、別な回路に挿入できます。",
"_____no_output_____"
]
],
[
[
"qr = QuantumRegister(4)\nnew_qc = QuantumCircuit(qr)\n\nnew_qc.append(toggle_cx, [qr[1],qr[2],qr[3]])\n\nnew_qc.draw()",
"_____no_output_____"
]
],
[
[
"### 実量子ハードウェアへのアクセス",
"_____no_output_____"
],
[
"`IBMQ` パッケージを使用して、バックエンド・オブジェクトを設定することもできます。 これらを使用するには、[IBMQアカウントで署名する](https://qiskit.org/documentation/install.html#access-ibm-q-systems) 必要があります。資格情報が既にコンピューターに読み込まれていると仮定して、サインインします。",
"_____no_output_____"
]
],
[
[
"IBMQ.load_account()",
"_____no_output_____"
]
],
[
[
"次に、使用可能な追加のバックエンドを見てみましょう。",
"_____no_output_____"
]
],
[
[
"provider = IBMQ.get_provider(hub='ibm-q')\nprovider.backends()",
"_____no_output_____"
]
],
[
[
"一つのシミュレーター、そして残りは量子デバイスのプロトタイプです。\n\n`status()` メソッドを使用すると、それらの状態を確認できます。",
"_____no_output_____"
]
],
[
[
"for backend in provider.backends():\n print(backend.status().to_dict())",
"{'backend_name': 'ibmq_qasm_simulator', 'backend_version': '0.1.547', 'operational': True, 'pending_jobs': 1, 'status_msg': 'active'}\n"
]
],
[
[
"最大のパブリック・デバイスに対するバックエンド・オブジェクトを取得しましょう。",
"_____no_output_____"
]
],
[
[
"real_device = provider.get_backend('ibmq_16_melbourne')",
"_____no_output_____"
]
],
[
[
"これを使用して、エミュレーターと全く同じ方法でデバイス上でジョブを実行できます。\n\nプロパティの一部を抽出することもできます。",
"_____no_output_____"
]
],
[
[
"properties = real_device.properties()\ncoupling_map = real_device.configuration().coupling_map",
"_____no_output_____"
]
],
[
[
"これから、デバイスのノイズを模倣するノイズ・モデルを構築できます(ノイズ・モデルについては本教科書にて後述します)。",
"_____no_output_____"
]
],
[
[
"from qiskit.providers.aer.noise import NoiseModel\n\nnoise_model = NoiseModel.from_backend(properties)",
"_____no_output_____"
]
],
[
[
"そして、エミュレータでジョブを実行し、実デバイスのこれらの機能をすべて再現します。 以下は、ノイズのない場合に `'10'` を出力する回路の例です。",
"_____no_output_____"
]
],
[
[
"qc = QuantumCircuit(2,2)\nqc.x(1)\nqc.measure(0,0)\nqc.measure(1,1)\n\njob = execute(qc, emulator, shots=1024, noise_model=noise_model,\n coupling_map=coupling_map,\n basis_gates=noise_model.basis_gates)\n\njob.result().get_counts()",
"_____no_output_____"
]
],
[
[
"以上で非常に基本的なことを説明しましたので、量子ビットと量子回路とは何か、さらに学んでいきましょう。",
"_____no_output_____"
]
],
[
[
"import qiskit\nqiskit.__qiskit_version__",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
eca9827f5fa0cf678725c0514cbb1363d8e4369d | 6,426 | ipynb | Jupyter Notebook | Torrent_to_Google_Drive.ipynb | Sivateja997/Torrent-to-Google-Drive | 8aaf59393322f9379029fef5cd34b8f4bc60fb39 | [
"MIT"
] | 1 | 2020-06-01T16:31:48.000Z | 2020-06-01T16:31:48.000Z | Torrent_to_Google_Drive.ipynb | Sivateja997/Torrent-to-Google-Drive | 8aaf59393322f9379029fef5cd34b8f4bc60fb39 | [
"MIT"
] | null | null | null | Torrent_to_Google_Drive.ipynb | Sivateja997/Torrent-to-Google-Drive | 8aaf59393322f9379029fef5cd34b8f4bc60fb39 | [
"MIT"
] | null | null | null | 27 | 257 | 0.429505 | [
[
[
"<a href=\"https://colab.research.google.com/github/Sivateja997/Torrent-to-Google-Drive/blob/master/Torrent_to_Google_Drive.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
],
[
"# **Torrent To Google Drive Downloader**",
"_____no_output_____"
],
[
"**Install Libtorrent and Initialize Session**",
"_____no_output_____"
]
],
[
[
"!apt install python3-libtorrent\n\nimport libtorrent as lt\n\nses = lt.session()\nses.listen_on(6881, 6891)\ndownloads = []",
"_____no_output_____"
]
],
[
[
"**Mount Google Drive**",
"_____no_output_____"
]
],
[
[
"from google.colab import drive\n\ndrive.mount(\"/content/drive\")",
"_____no_output_____"
]
],
[
[
"**Add From Torrent File**\n\nYou can run this cell to add more files as many times as you want",
"_____no_output_____"
]
],
[
[
"from google.colab import files\n\nsource = files.upload()\nparams = {\n \"save_path\": \"/content/drive/My Drive/Torrent\",\n \"ti\": lt.torrent_info(list(source.keys())[0]),\n}\ndownloads.append(ses.add_torrent(params))",
"_____no_output_____"
]
],
[
[
"**Add From Magnetic Link**\n\nYou can run this cell to add more files as many times as you want",
"_____no_output_____"
]
],
[
[
"params = {\"save_path\": \"/content/drive/My Drive/Torrent\"}\n\nwhile True:\n magnet_link = input(\"Enter Magnet Link Or Type Exit: \")\n if magnet_link.lower() == \"exit\":\n break\n downloads.append(\n lt.add_magnet_uri(ses, magnet_link, params)\n )",
"_____no_output_____"
]
],
[
[
"**Start Download**",
"_____no_output_____"
]
],
[
[
"import time\nfrom IPython.display import display\nimport ipywidgets as widgets\n\nstate_str = [\n \"queued\",\n \"checking\",\n \"downloading metadata\",\n \"downloading\",\n \"finished\",\n \"seeding\",\n \"allocating\",\n \"checking fastresume\",\n]\n\nlayout = widgets.Layout(width=\"auto\")\nstyle = {\"description_width\": \"initial\"}\ndownload_bars = [\n widgets.FloatSlider(\n step=0.01, disabled=True, layout=layout, style=style\n )\n for _ in downloads\n]\ndisplay(*download_bars)\n\nwhile downloads:\n next_shift = 0\n for index, download in enumerate(downloads[:]):\n bar = download_bars[index + next_shift]\n if not download.is_seed():\n s = download.status()\n\n bar.description = \" \".join(\n [\n download.name(),\n str(s.download_rate / 1000),\n \"kB/s\",\n state_str[s.state],\n ]\n )\n bar.value = s.progress * 100\n else:\n next_shift -= 1\n ses.remove_torrent(download)\n downloads.remove(download)\n bar.close() # Seems to be not working in Colab (see https://github.com/googlecolab/colabtools/issues/726#issue-486731758)\n download_bars.remove(bar)\n print(download.name(), \"complete\")\n time.sleep(1)",
"_____no_output_____"
]
],
[
[
"** **bold text**",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
eca989da9cc2add6ae171576bbeb93506fe6dce7 | 7,844 | ipynb | Jupyter Notebook | Final Project.ipynb | wemionasanya/wemionasanya.github.io | 2ff1ffc3da2c5f989e41b5176de383e16000a4bf | [
"Unlicense"
] | null | null | null | Final Project.ipynb | wemionasanya/wemionasanya.github.io | 2ff1ffc3da2c5f989e41b5176de383e16000a4bf | [
"Unlicense"
] | null | null | null | Final Project.ipynb | wemionasanya/wemionasanya.github.io | 2ff1ffc3da2c5f989e41b5176de383e16000a4bf | [
"Unlicense"
] | null | null | null | 35.333333 | 89 | 0.403621 | [
[
[
"import math as m\nimport numpy as np\nimport pandas as pd\nfrom scipy.stats import norm\n\nimport pathlib\n\ndef bls_euro_van(S_spot,K_strike,T_term,r_rate,sigma_vol,P_product, call_put):\n S_K = np.log(S_spot/K_strike)\n sqrt_T = np.sqrt(T_term)\n ert = np.exp(-r_rate * T_term)\n sigma_T = sigma_vol * sqrt_T\n sigma_T_S = sigma_T * S_spot\n bls_euro_van_d1 = (S_K + (r_rate + 0.5 * sigma_vol * sigma_vol)\n * T_term) / (sigma_T)\n bls_euro_van_d2 = bls_euro_van_d1 - sigma_T\n bls_N_d1 = norm.cdf(bls_euro_van_d1)\n bls_N_d2 = norm.cdf(bls_euro_van_d2)\n bls_e_d2 = norm.pdf(bls_euro_van_d2)\n \n call_price = (S_spot * bls_N_d1 - K_strike * ert * bls_N_d2)\n put_price = (K_strike * ert - S_spot + call_price)\n call_delta = bls_N_d1\n put_delta = bls_N_d1 - 1.0\n exotic_price = ert * bls_N_d2\n exotic_delta = (ert * bls_e_d2) / (sigma_T_S)\n if P_product == 'Vanilla European':\n if call_put == 'Call':\n name = 'Vanilla European Option Pricer'\n return (call_price,call_delta,name)\n elif call_put == 'Put':\n name = 'Vanilla European Option Pricer'\n return (put_price, put_delta,name)\n if P_product == 'Binary Option':\n name = 'Binary Option Pricer'\n return (exotic_price, exotic_delta,name)\n \ninput_dir = pathlib.Path( 'Input Files' )\noutput_dir = pathlib.Path ('Output Files')\n\npricing_data = pd.read_excel(input_dir / 'PricingData-1.xls', na_filter = False)\n\npricing_model= lambda x : bls_euro_van(x['Spot']\n ,x['Strike']\n ,x['Maturity']\n ,x['Rate']\n ,x['Volatility']\n ,x['Product']\n ,x['OptionType'])[2]\nprice = lambda x : bls_euro_van(x['Spot']\n ,x['Strike']\n ,x['Maturity']\n ,x['Rate']\n ,x['Volatility']\n ,x['Product']\n ,x['OptionType'])[0]\n\ndelta = lambda x : bls_euro_van(x['Spot']\n ,x['Strike']\n ,x['Maturity']\n ,x['Rate']\n ,x['Volatility']\n ,x['Product']\n ,x['OptionType'])[1]\npricing_data['Pricing Model'] = pricing_data.apply(pricing_model, axis =1)\npricing_data['Price'] = pricing_data.apply(price, axis =1)\npricing_data['Delta'] = pricing_data.apply(delta, axis =1)\n\npricing_data.to_excel( output_dir / 'Trade Prices and Deltas.xls', index=False)\n\npricing_data",
"_____no_output_____"
],
[
"price_data = pd.read\n\n",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code"
]
] |
eca9a9483f14525962451475b97a4a1249f18af4 | 21,237 | ipynb | Jupyter Notebook | Viny_Code_Files/TweetAnalysis.ipynb | jake-viss/UWFintech_Project1 | fc66d1de41d26e9e6345652d974e35df734ea3e3 | [
"MIT"
] | 1 | 2021-10-07T02:51:44.000Z | 2021-10-07T02:51:44.000Z | Viny_Code_Files/TweetAnalysis.ipynb | jake-viss/UWFintech_Project1 | fc66d1de41d26e9e6345652d974e35df734ea3e3 | [
"MIT"
] | null | null | null | Viny_Code_Files/TweetAnalysis.ipynb | jake-viss/UWFintech_Project1 | fc66d1de41d26e9e6345652d974e35df734ea3e3 | [
"MIT"
] | 1 | 2021-12-13T02:21:27.000Z | 2021-12-13T02:21:27.000Z | 31.369276 | 140 | 0.532514 | [
[
[
"import pandas as pd\nfrom pathlib import Path\nfrom collections import Counter\nimport hvplot.pandas\nimport os\nfrom dotenv import load_dotenv\nimport alpaca_trade_api as tradeapi\nimport sqlalchemy",
"_____no_output_____"
],
[
"#Import tweet date csv files as dataframes.\ndates_df = pd.read_csv(Path(\"duoldates.csv\"),)\ndates_df2 = pd.read_csv(Path(\"vtexdates.csv\"),)\ndates_df3 = pd.read_csv(Path(\"skyadates.csv\"),)\ndates_df4 = pd.read_csv(Path(\"cpngdates.csv\"),)\ndates_df5 = pd.read_csv(Path(\"vziodates.csv\"),)\n\n",
"_____no_output_____"
],
[
"#Create dataframes with just the date column from the csv read, and run the counter function to get a count of Tweets on each date.\n#Create a dictionary from the counter object, and create a dataframe for each ticker.\ndate_count = dates_df[\"date\"]\ndate_count = Counter(date_count)\ndate_dict = dict(date_count)\ndate_dict = pd.DataFrame(date_dict.items(), columns = ['Date', 'TweetCount'])\n\ndate_count2 = dates_df2[\"date\"]\ndate_count2 = Counter(date_count2)\ndate_dict2 = dict(date_count2)\ndate_dict2 = pd.DataFrame(date_dict2.items(), columns = ['Date', 'TweetCount'])\n\ndate_count3 = dates_df3[\"date\"]\ndate_count3 = Counter(date_count3)\ndate_dict3 = dict(date_count3)\ndate_dict3 = pd.DataFrame(date_dict3.items(), columns = ['Date', 'TweetCount'])\n\ndate_count4 = dates_df4[\"date\"]\ndate_count4 = Counter(date_count4)\ndate_dict4 = dict(date_count4)\ndate_dict4 = pd.DataFrame(date_dict4.items(), columns = ['Date', 'TweetCount'])\n\ndate_count5 = dates_df5[\"date\"]\ndate_count5 = Counter(date_count5)\ndate_dict5 = dict(date_count5)\ndate_dict5 = pd.DataFrame(date_dict5.items(), columns = ['Date', 'TweetCount'])\n",
"_____no_output_____"
],
[
"#Load Alpaca and env file information.\nload_dotenv()\nalpaca_api_key = os.getenv(\"ALPACA_API_KEY\")\nalpaca_secret_key = os.getenv(\"ALPACA_SECRET_KEY\")\n\n# Check the values were imported correctly by evaluating the type of each\ndisplay(type(alpaca_api_key))\ndisplay(type(alpaca_secret_key))",
"_____no_output_____"
],
[
"# Create your Alpaca API REST object by calling Alpaca's tradeapi.REST function\n# Set the parameters to your alpaca_api_key, alpaca_secret_key and api_version=\"v2\" \nalpaca = tradeapi.REST(\n alpaca_api_key,\n alpaca_secret_key,\n api_version=\"v2\")",
"_____no_output_____"
],
[
"#Set 1 Day increments and limit return to 1000 rows.\ntimeframe = \"1D\"\nlimit_rows = 1000\n#Set start and end dates to match tweet information\nstart_date = pd.Timestamp(\"2021-07-27\", tz=\"America/New_York\").isoformat()\nend_date = pd.Timestamp(\"2021-10-27\", tz=\"America/New_York\").isoformat()\nstart_date2 = pd.Timestamp(\"2021-07-20\", tz=\"America/New_York\").isoformat()\nend_date2 = pd.Timestamp(\"2021-10-20\", tz=\"America/New_York\").isoformat()\nstart_date3 = pd.Timestamp(\"2021-05-18\", tz=\"America/New_York\").isoformat()\nend_date3 = pd.Timestamp(\"2021-08-18\", tz=\"America/New_York\").isoformat()\nstart_date4 = pd.Timestamp(\"2021-03-10\", tz=\"America/New_York\").isoformat()\nend_date4 = pd.Timestamp(\"2021-06-10\", tz=\"America/New_York\").isoformat()\nstart_date5 = pd.Timestamp(\"2021-03-24\", tz=\"America/New_York\").isoformat()\nend_date5 = pd.Timestamp(\"2021-06-24\", tz=\"America/New_York\").isoformat()\n",
"_____no_output_____"
],
[
"#Pull Alpaca Data for each ticker and timeset.\nprices_df = alpaca.get_barset(\n \"DUOL\",\n timeframe,\n start=start_date,\n end=end_date,\n limit=limit_rows\n).df\n\nprices_df2 = alpaca.get_barset(\n \"VTEX\",\n timeframe,\n start=start_date2,\n end=end_date2,\n limit=limit_rows\n).df\n\nprices_df3 = alpaca.get_barset(\n \"SKYA\",\n timeframe,\n start=start_date3,\n end=end_date3,\n limit=limit_rows\n).df\n\nprices_df4 = alpaca.get_barset(\n \"CPNG\",\n timeframe,\n start=start_date4,\n end=end_date4,\n limit=limit_rows\n).df\n\nprices_df5 = alpaca.get_barset(\n \"VZIO\",\n timeframe,\n start=start_date5,\n end=end_date5,\n limit=limit_rows\n).df\n\n",
"_____no_output_____"
],
[
"#Remove timestamp from alapaca dataframe time column. Create new dataframe with time, close, and volume.\nprices_df.reset_index(level=0, inplace=True)\nprices_df[\"time\"] = pd.to_datetime(prices_df[\"time\"]).dt.date\nprices_df = [prices_df[\"time\"], prices_df[\"DUOL\", \"close\"], prices_df[\"DUOL\", \"volume\"]]\nprices_df = pd.DataFrame(prices_df)\nprices_df = prices_df.T\nprices_df.columns = [\"Time\", \"Close\", \"Volume\"]\n\nprices_df2.reset_index(level=0, inplace=True)\nprices_df2[\"time\"] = pd.to_datetime(prices_df2[\"time\"]).dt.date\nprices_df2 = [prices_df2[\"time\"], prices_df2[\"VTEX\", \"close\"], prices_df2[\"VTEX\", \"volume\"]]\nprices_df2 = pd.DataFrame(prices_df2)\nprices_df2 = prices_df2.T\nprices_df2.columns = [\"Time\", \"Close\", \"Volume\"]\n\n\nprices_df3.reset_index(level=0, inplace=True)\nprices_df3[\"time\"] = pd.to_datetime(prices_df3[\"time\"]).dt.date\nprices_df3 = [prices_df3[\"time\"], prices_df3[\"SKYA\", \"close\"], prices_df3[\"SKYA\", \"volume\"]]\nprices_df3 = pd.DataFrame(prices_df3)\nprices_df3 = prices_df3.T\nprices_df3.columns = [\"Time\", \"Close\", \"Volume\"]\n\n\nprices_df4.reset_index(level=0, inplace=True)\nprices_df4[\"time\"] = pd.to_datetime(prices_df4[\"time\"]).dt.date\nprices_df4 = [prices_df4[\"time\"], prices_df4[\"CPNG\", \"close\"], prices_df4[\"CPNG\", \"volume\"]]\nprices_df4 = pd.DataFrame(prices_df4)\nprices_df4 = prices_df4.T\nprices_df4.columns = [\"Time\", \"Close\", \"Volume\"]\n\n\nprices_df5.reset_index(level=0, inplace=True)\nprices_df5[\"time\"] = pd.to_datetime(prices_df5[\"time\"]).dt.date\nprices_df5 = [prices_df5[\"time\"], prices_df5[\"VZIO\", \"close\"], prices_df5[\"VZIO\", \"volume\"]]\nprices_df5 = pd.DataFrame(prices_df5)\nprices_df5 = prices_df5.T\nprices_df5.columns = [\"Time\", \"Close\", \"Volume\"]\n\n",
"_____no_output_____"
],
[
"#Create SQL database to join price and tweet dataframes for each ticker.\n# Create the connection string for your SQLite database\ndatabase_connection_string = 'sqlite:///'\n\n# Pass the connection string to the SQLAlchemy create_engine function\nengine = sqlalchemy.create_engine(database_connection_string)\n\n# Confirm that the database engine was created.\nengine",
"_____no_output_____"
],
[
"#Import each price and tweet count table into the database.\ndate_dict.to_sql(\n 'date', \n engine, \n index=False, \n if_exists='replace'\n)\ndate_dict2.to_sql(\n 'date2', \n engine, \n index=False, \n if_exists='replace'\n)\ndate_dict3.to_sql(\n 'date3', \n engine, \n index=False, \n if_exists='replace'\n)\ndate_dict4.to_sql(\n 'date4', \n engine, \n index=False, \n if_exists='replace'\n)\ndate_dict5.to_sql(\n 'date5', \n engine, \n index=False, \n if_exists='replace'\n)\nprices_df.to_sql(\n 'prices', \n engine, \n index=False, \n if_exists='replace'\n)\nprices_df2.to_sql(\n 'prices2', \n engine, \n index=False, \n if_exists='replace'\n)\nprices_df3.to_sql(\n 'prices3', \n engine, \n index=False, \n if_exists='replace'\n)\nprices_df4.to_sql(\n 'prices4', \n engine, \n index=False, \n if_exists='replace'\n)\nprices_df5.to_sql(\n 'prices5', \n engine, \n index=False, \n if_exists='replace'\n)\n",
"_____no_output_____"
],
[
"#Create queries to join price and tweet count tables for each ticker by date.\nquery = \"\"\"\nSELECT date.Date, date.TweetCount, prices.Close, prices.Volume\nFROM prices\nJOIN date ON date.Date = prices.Time\n\"\"\"\n\nquery2 = \"\"\"\nSELECT date2.Date, date2.TweetCount, prices2.Close, prices2.Volume\nFROM prices2\nJOIN date2 ON date2.Date = prices2.Time\n\"\"\"\n\nquery3 = \"\"\"\nSELECT date3.Date, date3.TweetCount, prices3.Close, prices3.Volume\nFROM prices3\nJOIN date3 ON date3.Date = prices3.Time\n\"\"\"\n\nquery4 = \"\"\"\nSELECT date4.Date, date4.TweetCount, prices4.Close, prices4.Volume\nFROM prices4\nJOIN date4 ON date4.Date = prices4.Time\n\"\"\"\n\nquery5 = \"\"\"\nSELECT date5.Date, date5.TweetCount, prices5.Close, prices5.Volume\nFROM prices5\nJOIN date5 ON date5.Date = prices5.Time\n\"\"\"",
"_____no_output_____"
],
[
"#Run SQL queries and create dataframe for each ticker.\nDUOL_df = pd.read_sql_query(query, con=engine)\nVTEX_df = pd.read_sql_query(query2, con=engine)\nSKYA_df = pd.read_sql_query(query3, con=engine)\nCPNG_df = pd.read_sql_query(query4, con=engine)\nVZIO_df = pd.read_sql_query(query5, con=engine)",
"_____no_output_____"
],
[
"#Sort by date, create perent change columes, and set the index as the Date for each of the ticker dataframes\nDUOL_df = DUOL_df.sort_values('Date')\nDUOL_df[\"count_pct_chg\"] = DUOL_df[\"TweetCount\"].pct_change()\nDUOL_df[\"close_pct_chg\"] = DUOL_df[\"Close\"].pct_change()\nDUOL_df[\"vol_pct_chg\"] = DUOL_df[\"Volume\"].pct_change()\nDUOL_df = DUOL_df.set_index(\"Date\")\nDUOL_df = DUOL_df.dropna()\nDUOL_df\n\nVTEX_df = VTEX_df.sort_values('Date')\nVTEX_df[\"count_pct_chg\"] = VTEX_df[\"TweetCount\"].pct_change()\nVTEX_df[\"close_pct_chg\"] = VTEX_df[\"Close\"].pct_change()\nVTEX_df[\"vol_pct_chg\"] = VTEX_df[\"Volume\"].pct_change()\nVTEX_df = VTEX_df.set_index(\"Date\")\nVTEX_df = VTEX_df.dropna()\n\n\nSKYA_df = SKYA_df.sort_values('Date')\nSKYA_df[\"count_pct_chg\"] = SKYA_df[\"TweetCount\"].pct_change()\nSKYA_df[\"close_pct_chg\"] = SKYA_df[\"Close\"].pct_change()\nSKYA_df[\"vol_pct_chg\"] = SKYA_df[\"Volume\"].pct_change()\nSKYA_df = SKYA_df.set_index(\"Date\")\nSKYA_df = SKYA_df.dropna()\nSKYA_df\n\nCPNG_df = CPNG_df.sort_values('Date')\nCPNG_df[\"count_pct_chg\"] = CPNG_df[\"TweetCount\"].pct_change()\nCPNG_df[\"close_pct_chg\"] = CPNG_df[\"Close\"].pct_change()\nCPNG_df[\"vol_pct_chg\"] = CPNG_df[\"Volume\"].pct_change()\nCPNG_df = CPNG_df.set_index(\"Date\")\nCPNG_df = CPNG_df.dropna()\nCPNG_df\n\nVZIO_df = VZIO_df.sort_values('Date')\nVZIO_df[\"count_pct_chg\"] = VZIO_df[\"TweetCount\"].pct_change()\nVZIO_df[\"close_pct_chg\"] = VZIO_df[\"Close\"].pct_change()\nVZIO_df[\"vol_pct_chg\"] = VZIO_df[\"Volume\"].pct_change()\nVZIO_df = VZIO_df.set_index(\"Date\")\nVZIO_df = VZIO_df.dropna()\n",
"_____no_output_____"
],
[
"#Get Tweet Count correlation to close price and volume for 1 ticker.\nVZIO_corr = VZIO_df.corr()\nVZIO = [VZIO_corr.iloc[1,0], VZIO_corr.iloc[2,0]]\nVZIO",
"_____no_output_____"
],
[
"#Convert resulting data into dataframe, transpose, and rename colums\ncorrelations = pd.DataFrame(VZIO)\ncorrelations = correlations.T\ncorrelations\ncorrelations.rename(columns = {0 : \"Close_Corr\", 1 : \"Vol_Corr\"}, index = {0 : \"VZIO\"}, inplace = True)\ncorrelations\n",
"_____no_output_____"
],
[
"CPNG_corr = CPNG_df.corr()\nCPNG = [CPNG_corr.iloc[1,0], CPNG_corr.iloc[2,0]]\nCPNG = pd.DataFrame(CPNG)\nCPNG = CPNG.T\nCPNG.rename(columns = {0 : \"Close_Corr\", 1 : \"Vol_Corr\"}, index = {0 : \"CPNG\"}, inplace = True)\ncorrelations = correlations.append(CPNG)\n\nSKYA_corr = SKYA_df.corr()\nSKYA = [SKYA_corr.iloc[1,0], SKYA_corr.iloc[2,0]]\nSKYA = pd.DataFrame(SKYA)\nSKYA = SKYA.T\nSKYA.rename(columns = {0 : \"Close_Corr\", 1 : \"Vol_Corr\"}, index = {0 : \"SKYA\"}, inplace = True)\ncorrelations = correlations.append(SKYA)\n\nVTEX_corr = VTEX_df.corr()\nVTEX = [VTEX_corr.iloc[1,0], VTEX_corr.iloc[2,0]]\nVTEX = pd.DataFrame(VTEX)\nVTEX = VTEX.T\nVTEX.rename(columns = {0 : \"Close_Corr\", 1 : \"Vol_Corr\"}, index = {0 : \"VTEX\"}, inplace = True)\ncorrelations = correlations.append(VTEX)\n\nDUOL_corr = DUOL_df.corr()\nDUOL_corr\nDUOL = [DUOL_corr.iloc[1,0], DUOL_corr.iloc[2,0]]\nDUOL = pd.DataFrame(DUOL)\nDUOL = DUOL.T\nDUOL.rename(columns = {0 : \"Close_Corr\", 1 : \"Vol_Corr\"}, index = {0 : \"DUOL\"}, inplace = True)\ncorrelations = correlations.append(DUOL)\ncorrelations",
"_____no_output_____"
],
[
"correlations.to_csv('vncorrelations.csv')\nCPNG_df.to_csv('CPNGStockData.csv')",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
eca9afba8a44b3f5a0e417154a097fc17df3f09a | 10,401 | ipynb | Jupyter Notebook | jupyter/jupyter_phase1-2.ipynb | jfklorenz/Python-RMedian | 8c490e003459e94b73fa2a4f51019d880dbb80b2 | [
"MIT"
] | 1 | 2020-10-27T19:58:31.000Z | 2020-10-27T19:58:31.000Z | jupyter/jupyter_phase1-2.ipynb | jfklorenz/Python-RMedian | 8c490e003459e94b73fa2a4f51019d880dbb80b2 | [
"MIT"
] | null | null | null | jupyter/jupyter_phase1-2.ipynb | jfklorenz/Python-RMedian | 8c490e003459e94b73fa2a4f51019d880dbb80b2 | [
"MIT"
] | null | null | null | 28.418033 | 100 | 0.322277 | [
[
[
"RMedian : Phase 1 & 2",
"_____no_output_____"
]
],
[
[
"import math\nimport random\nimport statistics",
"_____no_output_____"
]
],
[
[
"Testfall :",
"_____no_output_____"
]
],
[
[
"# User input\nn = 2**14 + 1\ncase = 1\n\n# Cases\nif case == 1: #\n k = int(n ** (2 / 3))\n d = int(n ** (1 / 12))\nelif case == 2:\n k = int(n / (math.log(n) / math.log(2)))\n d = int(math.log(n) / math.log(2))\n \n# Automatic\nX = [i for i in range(n)]\ncnt = [0 for _ in range(n)]\n\n# Print\nprint(n, k, d)",
"16385 645 2\n"
]
],
[
[
"Algorithmus : Phase 1 & 2",
"_____no_output_____"
]
],
[
[
"def phase1(X, k, d):\n\n n = len(X)\n med = statistics.median(X)\n\n random.shuffle(X)\n S = X[:k]\n XS = X[k:]\n\n S.sort()\n\n if 2*(k*math.log2(n))**0.5 < k/2:\n lst = [2*(k*math.log2(n))**0.5]\n if 3*(k*math.log2(n))**0.5 < k/2:\n lst.append(3*(k*math.log2(n))**0.5)\n while d*lst[len(lst) - 1] < k/2:\n lst.append(d*lst[len(lst) - 1])\n lst.append(k/2)\n else:\n lst = [k/2]\n\n L = [[] for _ in range(len(lst) - 1)]\n R = [[] for _ in range(len(lst) - 1)]\n C = []\n\n for s in S[math.floor(k / 2 - lst[0]): math.ceil(k / 2 + lst[0])]:\n C.append(s)\n\n for i in range(1, len(lst)):\n for s in S[math.floor(k / 2 - lst[i]): math.floor(k / 2 - lst[i - 1])]:\n L[i - 1].append(s)\n for s in S[math.ceil(k / 2 + lst[i - 1]): math.ceil(k / 2 + lst[i])]:\n R[i - 1].append(s)\n\n return S, XS, L, C, R, lst\n\n# ========================================\ndef phase2(S, XS, L, C, R, cnt):\n mark = [False for _ in range(2**20)]\n b = len(L)\n\n random.shuffle(XS)\n for x_i in XS:\n med = 0\n for j in reversed(range(0, b - 1)):\n \n current = 2**50\n random.shuffle(L[j])\n for l in L[j]:\n if cnt[l] < current:\n x_A = l\n\n if mark[x_A] == True:\n c = 1\n \n else:\n c = 2\n\n cnt[x_i] += 1\n cnt[x_A] += 1\n \n if x_i < x_A:\n if j + c < b:\n mark[x_i] = True\n L[j + c].append(x_i)\n med = -1\n else:\n med = -2\n break\n\n current2 = 2**50\n random.shuffle(R[j])\n for r in R[j]:\n if cnt[r] < current2:\n x_B = r\n\n if mark[x_B] == True:\n c = 1\n else:\n c = 2\n\n cnt[x_i] += 1\n cnt[x_B] += 1\n \n if x_i > x_B:\n if j + c < b:\n mark[x_i] = True\n R[j + c].append(x_i)\n med = 1\n else:\n med = 2\n break\n if med == 0:\n C.append(x_i)\n elif med == -2:\n L[len(L) - 1].append(x_i)\n elif med == 2:\n R[len(R) - 1].append(x_i)\n \n \n sumL, sumR = 0, 0\n for l in L:\n sumL += len(l)\n for r in R:\n sumR += len(r)\n\n s = sumL - sumR\n \n # Expand\n if s < 0:\n rs = []\n for r in R:\n rs += r\n random.shuffle(rs)\n for i in range(-s):\n C.append(rs[i])\n for r in R:\n if rs[i] in r:\n r.remove(rs[i])\n else:\n ls = []\n for l in L:\n ls += l\n random.shuffle(ls)\n for i in range(s):\n C.append(ls[i])\n for l in L:\n if ls[i] in l:\n l.remove(ls[i])\n \n return S, XS, L, C, R, cnt\n\n# ========================================\n# Testfall\nS, XS, L, C, R, lst = phase1(X, k, d)\nS, XS, L, C, R, cnt = phase2(S, XS, L, C, R, cnt)\n\nS, XS, L, C, R, lst = phase1(C, k, d)\nS, XS, L, C, R, cnt = phase2(S, XS, L, C, R, cnt)\n\nS, XS, L, C, R, lst = phase1(C, k, d)\nS, XS, L, C, R, cnt = phase2(S, XS, L, C, R, cnt)\nS, XS, L, C, R, lst = phase1(C, k, d)\nS, XS, L, C, R, cnt = phase2(S, XS, L, C, R, cnt)\nS, XS, L, C, R, lst = phase1(C, k, d)\nS, XS, L, C, R, cnt = phase2(S, XS, L, C, R, cnt)\nprint('done')",
"done\n"
]
],
[
[
"Resultat :",
"_____no_output_____"
]
],
[
[
"def test(X, k, d, S, XS, L, C, R, lst, cnt):\n X.sort()\n med = statistics.median(X)\n n, s, xs, l, c, r, sumL, sumR = len(X), len(S), len(XS), len(L), len(C), len(R), 0, 0\n \n for i in range(len(lst)):\n lst[i] = round(lst[i], 2)\n \n for i in range(len(L)):\n sumL += len(L[i])\n sumR += len(R[i])\n C.sort()\n \n print('')\n print('Testfall n / k / d:', n, '/', k, '/', d)\n print('=======================================')\n print('|S| / |XS| :', s, '/', xs)\n print('=======================================')\n print('n_i :', lst)\n for i in reversed(range(len(lst) - 1)):\n print('L' +str(i+1), ' :', '[', int(k/2 - lst[i + 1]), ',', int(k/2 - lst[i]), ']')\n print('C :', '[', int(k/2 - lst[0]), ',', int(k/2 + lst[0]), ']')\n for i in range(len(lst) - 1):\n print('R' +str(i+1), ' :', '[', int(k/2 + lst[i]), ',', int(k/2 + lst[i + 1]), ']')\n print('---------------------------------------')\n print('||L|| :', sumL)\n for i in reversed(range(len(L))):\n print('|L'+str(i+1)+'| :', len(L[i]))\n print('|C| :', c)\n for i in range(len(L)):\n print('|R'+str(i+1)+'| :', len(R[i]))\n print('||R|| :', sumR)\n print('---------------------------------------')\n print('|L + C + R| :', sumL + c + sumR)\n print('=======================================')\n print('Median :', med)\n print('Med in C:', med in C)\n print('Med is Median from C :', statistics.median(C) == med)\n print(med)\n print(statistics.median(C))\n print('=======================================')\n print('max(cnt) :', max(cnt))\n return\n\n# Testfall\ntest(X, k, d, S, XS, L, C, R, lst, cnt)",
"\nTestfall n / k / d: 16385 / 645 / 2\n=======================================\n|S| / |XS| : 645 / 3788\n=======================================\nn_i : [176.79, 265.18, 322.5]\nL2 : [ 0 , 57 ]\nL1 : [ 57 , 145 ]\nC : [ 145 , 499 ]\nR1 : [ 499 , 587 ]\nR2 : [ 587 , 645 ]\n---------------------------------------\n||L|| : 657\n|L2| : 569\n|L1| : 88\n|C| : 3119\n|R1| : 82\n|R2| : 575\n||R|| : 657\n---------------------------------------\n|L + C + R| : 4433\n=======================================\nMedian : 8192\nMed in C: True\nMed is Median from C : True\n8192\n8192\n=======================================\nmax(cnt) : 189\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
eca9c71e4eebd25d5150d3cb7c66939935071c7d | 1,240 | ipynb | Jupyter Notebook | packages/galata/tests/notebooks/example.ipynb | fcollonval/galata | 5789f1d2404e586bd7f271d1f575cc3017b45e5a | [
"BSD-3-Clause"
] | 11,496 | 2016-10-12T21:02:20.000Z | 2022-03-31T17:09:23.000Z | packages/galata/tests/notebooks/example.ipynb | fcollonval/galata | 5789f1d2404e586bd7f271d1f575cc3017b45e5a | [
"BSD-3-Clause"
] | 10,587 | 2016-10-12T21:22:34.000Z | 2022-03-31T22:44:58.000Z | packages/galata/tests/notebooks/example.ipynb | fcollonval/galata | 5789f1d2404e586bd7f271d1f575cc3017b45e5a | [
"BSD-3-Clause"
] | 2,612 | 2016-10-13T12:56:28.000Z | 2022-03-30T17:03:04.000Z | 16.315789 | 42 | 0.495968 | [
[
[
"from IPython.display import Image\nImage('./jupyter.png', width=80)",
"_____no_output_____"
]
],
[
[
"A calculation",
"_____no_output_____"
]
],
[
[
"2 + 2",
"_____no_output_____"
]
],
[
[
"Another calculation",
"_____no_output_____"
]
],
[
[
"import math\nmath.pi / 2",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
eca9d7dd06f692de0993e2a4fc0664dd2591de2c | 1,279 | ipynb | Jupyter Notebook | notebooks/Chapter 10 - Web Applications.ipynb | kozo2/Py4Bio | e67d73b18e34c884c741d2e88a8ae6617b3b03d8 | [
"MIT"
] | null | null | null | notebooks/Chapter 10 - Web Applications.ipynb | kozo2/Py4Bio | e67d73b18e34c884c741d2e88a8ae6617b3b03d8 | [
"MIT"
] | null | null | null | notebooks/Chapter 10 - Web Applications.ipynb | kozo2/Py4Bio | e67d73b18e34c884c741d2e88a8ae6617b3b03d8 | [
"MIT"
] | 1 | 2020-07-23T17:12:29.000Z | 2020-07-23T17:12:29.000Z | 22.839286 | 219 | 0.542611 | [
[
[
"Python for Bioinformatics\n-----------------------------\n\n\n\nThis Jupyter notebook is intented to be used alongside the book [Python for Bioinformatics](http://py3.us/)\n\n",
"_____no_output_____"
],
[
"Chapter 10: Web Applications\n----------------------------",
"_____no_output_____"
],
[
"**Note:** All code in this chapter is made to be used in a web server, they can't run in a Jupyter Notebook. To run these programs, run it in your own machine or in a web hosting using the instructions in the book",
"_____no_output_____"
]
]
] | [
"markdown"
] | [
[
"markdown",
"markdown",
"markdown"
]
] |
eca9ebe9b0287dd9ffb286708a48dc76bba18cc9 | 28,629 | ipynb | Jupyter Notebook | analysis/Analysis.ipynb | cogtoolslab/projection_block_construction | faae126fbb7da45f2c5f4df05a2ff606a2b86d59 | [
"MIT"
] | null | null | null | analysis/Analysis.ipynb | cogtoolslab/projection_block_construction | faae126fbb7da45f2c5f4df05a2ff606a2b86d59 | [
"MIT"
] | 1 | 2022-02-19T00:04:14.000Z | 2022-02-19T00:04:14.000Z | analysis/Analysis.ipynb | cogtoolslab/tools_block_construction | e573b28b2a53d27268414dab17b9be4dda257230 | [
"MIT"
] | null | null | null | 29.213265 | 410 | 0.603549 | [
[
[
"# Block construction agents",
"_____no_output_____"
],
[
"This is the main general analysis file for the [block construction task](https://github.com/cogtoolslab/block_construction). \n\nThe data should be loaded in by a dataframe produced by experiment_runner.py",
"_____no_output_____"
]
],
[
[
"# set up imports\nimport os\nimport sys\n__file__ = os.getcwd()\nproj_dir = os.path.dirname(os.path.realpath(__file__))\nsys.path.append(proj_dir)\nutils_dir = os.path.join(proj_dir,'utils')\nsys.path.append(utils_dir)\nanalysis_dir = os.path.join(proj_dir,'analysis')\nanalysis_utils_dir = os.path.join(analysis_dir,'utils')\nsys.path.append(analysis_utils_dir)\nagent_dir = os.path.join(proj_dir,'model')\nsys.path.append(agent_dir)\nagent_util_dir = os.path.join(agent_dir,'utils')\nsys.path.append(agent_util_dir)\nexperiments_dir = os.path.join(proj_dir,'experiments')\nsys.path.append(experiments_dir)\ndf_dir = os.path.join(proj_dir,'results/dataframes')",
"_____no_output_____"
],
[
"from analysis.utils.analysis_helper import *\nfrom analysis.utils.analysis_graphs import *\nfrom analysis.utils.analysis_figures import *\nimport utils.blockworld as bw",
"_____no_output_____"
],
[
"import model.utils.decomposition_functions",
"_____no_output_____"
],
[
"import random",
"_____no_output_____"
],
[
"#inline plots\n%matplotlib inline\n%config InlineBackend.figure_format = 'retina'",
"_____no_output_____"
],
[
"plt.rcParams[\"figure.figsize\"] = (40,7)\nplt.rcParams.update({'font.size': 22})",
"_____no_output_____"
],
[
"#display all columns\npd.set_option('display.max_columns', None)\npd.set_option('display.width', 20)\npd.set_option('display.max_colwidth', 100)\npd.set_option('display.min_rows', 40)",
"_____no_output_____"
]
],
[
[
"Let's load the results of the experiment",
"_____no_output_____"
]
],
[
[
"df_paths = ['subgoal planning full BFS3.pkl']",
"_____no_output_____"
],
[
"#load all experiments as one dataframe\ndf = pd.concat([pd.read_pickle(os.path.join(df_dir,l)) for l in df_paths])\nprint(\"Loaded dataframe\")",
"_____no_output_____"
],
[
"# preprocess the data\npreprocess_df(df)",
"_____no_output_____"
],
[
"# consider saving the costly preprocessing\ndf.to_pickle(os.path.join(df_dir,str(df_paths)+\"_preprocessed.pkl\"))",
"_____no_output_____"
],
[
"display(df)",
"_____no_output_____"
]
],
[
[
"We'll have data for the following agents, agent configurations and on the following silhouettes:",
"_____no_output_____"
]
],
[
[
"list(smart_short_agent_names(df['agent_attributes'].unique()))",
"_____no_output_____"
],
[
"df['agent_attributes'].unique()",
"_____no_output_____"
],
[
"df[['agent_label','decomposed_silhouette']]",
"_____no_output_____"
],
[
"type(df.iloc[7]['decomposed_silhouette'][0]['decomposition'])",
"_____no_output_____"
],
[
"list(df['world'].unique())",
"_____no_output_____"
],
[
"df.columns",
"_____no_output_____"
]
],
[
[
"Let's add human readable labels for nice plotting if the smart labels aren't good enough:",
"_____no_output_____"
]
],
[
[
"df['agent_attributes_string'] = df['agent_attributes'].astype(str)",
"_____no_output_____"
],
[
"#produce dict for agent naming\nagents = df['agent_attributes_string'].unique()\nagent_labels = dict(zip(list(agents),[\"XXX\"]*len(agents)))\n#now manually add names and save back\nagent_labels",
"_____no_output_____"
],
[
"#save back into agent_labels (just copy and paste...)\nagent_labels = {\"{'agent_type': 'BFS_Agent', 'scoring_function': 'F1score', 'horizon': 1, 'scoring_type': 'Average'}\": '1',\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'random_scoring', 'horizon': 1, 'scoring_type': 'Average'}\": 'random',\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'F1score', 'horizon': 2, 'scoring_type': 'Average'}\": '2',\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'F1score', 'horizon': 3, 'scoring_type': 'Average'}\": '3',\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'F1score', 'horizon': 4, 'scoring_type': 'Average'}\": '4'}",
"_____no_output_____"
],
[
"#write to dataframe\ndf['agent_label'] = df['agent_attributes_string'].replace(agent_labels)",
"_____no_output_____"
],
[
"#only include big silhouettes\ndf = df[df['world'].str.contains('int_struct')]",
"_____no_output_____"
]
],
[
[
"A graphical illustration of the silhouettes used in the dataframe:",
"_____no_output_____"
]
],
[
[
"illustrate_worlds(df.sort_values('world'))",
"_____no_output_____"
]
],
[
[
"## Overview over agents\nAll agents use pure F1 score to judge the value of intermediate states.\n\n| Agent | | Parameters |\n|:--|:--|:--|\n| Random (special case of BFS) | Randomly chooses a legal action. | *None* |\n| Breadth first search | Agent performs breadth first search on the tree of all possible actions and chooses the sequence of actions that has the highest average reward over the next *planning depth* steps | Horizon: how many steps in advance is the tree of possible actions searched? |\n| MCTS | Implements Monte Carlo Tree Search | Horizon: the number of rollouts per run |\n| Naive Q learning | Implements naive Q learning with an epsilon-greedy exploration policy | Maximum number of episodes: how many episodes per run |\n| A* search | Implements A* search algorithm. Runs until winning state is found or an upper limit of steps is reached. Is determininistic.| *None* |\n| Beam search | Implements beam search: searches tree of possible action, but only keeps the best *beam size* actions at each iteration. Is determininistic. | Beam size: the number of states kept under consideration at every step |\n| Construction paper agent | Implements the construction paper agent: it occludes part of the silhuouette, uses a lower level agent to build the remainder, then 'slides up' the occluder and builds again... | Lower level agent: the lower level planning agent together with its parameters |\n| Subgoal planning agent | Implements planning over `lookahead` many subgoals akin to Correa and Ho and then acts the first one, plans again.| Lookahead: how many subgoals to plan into the Future. \\ c_weight: how to weigh cost against reward |\n| Full Subgoal planning agent | Implements planning over all possible subgoals akin to Correa and Ho and then acts all of them.| c_weight: how to weigh cost against reward |\n\n### Glossary\n\n**Run**: training (if applicable) and running one agent on one particular silhouette.\n\n**Silhouette**: the particular outline (and set of baseblocks) that the agent has to reconstruct.\n\n**State**: state of the blockworld environment consisting of the blocks that have already been placed in it.",
"_____no_output_____"
],
[
"## Qualitative visualizations",
"_____no_output_____"
],
[
"### Build animation",
"_____no_output_____"
]
],
[
[
"#parameters for random run\nagent_type = 'Subgoal_Planning_Agent'\nlookahead = 1\nc_weight = 0.1",
"_____no_output_____"
],
[
"for c in range(10):\n a_w_df = df.query(\"lookeahead == @lookahead and c_weight == @c_weight and world == 'int_struct_11' and agent_type == @agent_type\")\n r_ID = random.choice(a_w_df['run_ID'].unique())\n random_run = a_w_df[a_w_df['run_ID']==r_ID]\n print(random_run.tail(1)['world_failure_reason'].item())\n build_animation(random_run,agent_type+\" la: \"+str(lookahead)+\" cw: \"+str(c_weight)+\" nr. \"+str(c+1))",
"_____no_output_____"
]
],
[
[
"## Success",
"_____no_output_____"
],
[
"### Success vs effiency\nHow does the success of an agent relate to it's computational efficiency?",
"_____no_output_____"
]
],
[
[
"scatter_success_cost(df)",
"_____no_output_____"
]
],
[
[
"### Rate of perfect reconstruction per agent",
"_____no_output_____"
],
[
"How often does an agent succeed in getting a perfect reconstruction?",
"_____no_output_____"
]
],
[
[
"mean_win_per_agent(df)",
"_____no_output_____"
]
],
[
[
"### Rate of perfect reconstruction per agent over silhouettes\nHow often does an agent achieve a perfect reconstruction in a particular world?",
"_____no_output_____"
]
],
[
[
"mean_win_per_agent_over_worlds(df)",
"_____no_output_____"
]
],
[
[
"### F1 score\nWhat [F1 score](https://en.wikipedia.org/wiki/F1_score) does the agent achieve? Since F1 score decreases if an agent keeps building after being unable to perfectly recreate the structure, we look at the peak of F1 score for every run. \n\nSo here is the average peak F1 score per agent conditioned on outcome of the run.",
"_____no_output_____"
]
],
[
[
"mean_peak_score_per_agent(df)",
"_____no_output_____"
]
],
[
[
"#### F1 score over silhouettes\nWhat is the peak F1 score for a particular silhouette?",
"_____no_output_____"
]
],
[
[
"mean_peak_F1_per_agent_over_worlds(df)",
"_____no_output_____"
]
],
[
[
"## Failure kinds\nIn run where the agent fails to achieve perfect reconstruction, what is the reason for the failure?\n\n**Full** indicates that no further block can be placed.\n**Unstable** indicates the structure has collapsed.\n**Did not finish** means that the agent hasn't finished building either because it terminated or it reached the limit on number of steps (40). ",
"_____no_output_____"
]
],
[
[
"mean_failure_reason_per_agent(df)",
"_____no_output_____"
]
],
[
[
"### Failure kinds over silhouettes\nIn kinds of failure does a certain agent on a certain silhouette tend to make?",
"_____no_output_____"
]
],
[
[
"mean_failure_reason_per_agent_over_worlds(df)",
"_____no_output_____"
]
],
[
[
"### Holes\nThe most common failure mode is leaving holes in the structure that should be covered with a block, but that the agent can't get to because a block has been above. Here, the measure is defined as the number of grid cells that are in the silhouette, not built on, but the cell right above is built. The higher this number, the more or the larger the holes are that the agent builds.",
"_____no_output_____"
]
],
[
[
"mean_score_per_agent(df,scoring_function=bw.holes)",
"_____no_output_____"
]
],
[
[
"### Heatmaps\nTo get a qualitative sense of what the agents are doing, let's look at the heatmap of all runs of an agent on a particular silhouette at the moment of peak F1. Looking at final states will include many runs in which the agent has simply filled the entire area. \nBrighter colors indicate higher average occupancy of a cell. The target is shown on the left.\n\nNote that if the final block placed was unstable it is still included here.",
"_____no_output_____"
]
],
[
[
"heatmaps_at_peak_per_agent_over_world(df)",
"_____no_output_____"
],
[
"heatmaps_per_agent_over_world(df)",
"_____no_output_____"
]
],
[
[
"## Greediness\nDo agents prefer a greedy policy (using large blocks to cover much area) or a conservative policy of using smaller blocks and more steps?",
"_____no_output_____"
],
[
"### Number of steps taken\nOn average, how many steps does an agent take before the end of the run? \n\nLooking at the average number of steps for runs with perfect reconstruction (\"win\") tells us whether an agent builds with larger or smaller blocks. \n\nLooking at the average number of steps for runs with failed reconstructions (\"fail\") tells whether the failures occur early or late in the process. Since many failures are due to the agent simply filling everything with blocks this number is likely high and not very informative.",
"_____no_output_____"
]
],
[
[
"avg_steps_to_end_per_agent(df)",
"_____no_output_____"
]
],
[
[
"### Growth rate of F1 score\nOn average, what is the average F1 score taken over every action up to the peak of F1 score for a particular run? For runs conditioned on perfect reconstructions, what is the growth rate of F1?\n\nThe higher this number is, the more F1 score is gained early on in the run (ie. a logaritmic looking curve of F1 score). \nNote that the bars conditioned on winning runs all have a peak F1 score of 1 and are thus directly comparable.",
"_____no_output_____"
]
],
[
[
"mean_avg_area_under_curve_to_peakF1_per_agent(df)",
"_____no_output_____"
]
],
[
[
"### Average F1 score over time\nWhat is the average F1 score over time? \n\nDecreasing line indicates the behavior of the agent to keep choosing the least-worst action if a perfect reconstruction is no longer possible.\n\nFor runs that terminate early, the last F1 score is kept as to not show outliers in the later part of the graph. Thus, a perfect reconstruction at step 8 is counted as a score of 1 for the last 12 steps. ",
"_____no_output_____"
]
],
[
[
"graph_mean_F1_over_time_per_agent(df)",
"_____no_output_____"
]
],
[
[
"### Average block size over time\nWhat is the average size of the block placed at a certain step?\n\nNote that only runs that aren't finished at a given step are included in the calculation of the mean/std, so later steps might be less informative.",
"_____no_output_____"
]
],
[
[
"graph_avg_blocksize_over_time_per_agent(df.query(\"lookeahead == 1\"))",
"_____no_output_____"
]
],
[
[
"## Consistency\n### Average pairwise Euclidean distance of block placements\nHow consistent are different runs of the same agent on the same silhouette?\n\nHere, we measure the average pairwise distance for an agent across runs on the same silhouette. A lower score indicates higher similarity. A score of 0 indicates that all runs were identical—this occurs when the agent is deterministic.\n\n>For any pair of action sequences, we define the “raw action dissimilarity” as the mean Euclidean distance between corresponding pairs of [x, y, w, h] action vectors. When two sequences are of different lengths, we evaluate this metric over the first k actions in both, where k represents the length of the shorter sequence",
"_____no_output_____"
]
],
[
[
"#This scales exponentially and takes a really long time\nmean_pairwise_raw_euclidean_distance_between_runs(df)",
"_____no_output_____"
]
],
[
[
"### Trajectory graph\nThe trajectory graph (adopted from [block_construction](https://github.com/cogtoolslab/block_construction)) shows the path all runs from a single agent on a particular value take through state space. The y axis orders states by F1 score. The size of nodes indicates how common a certain state is. The color indicates whether the coloured edge ends in failure (red) or at least one perfect reconstruction.",
"_____no_output_____"
]
],
[
[
"trajectory_per_agent_over_world(df)",
"_____no_output_____"
]
],
[
[
"## Locality bias\n### Proportion of local block placements\nDoes the agent prefer to place a block on top of or next to the last placed block?\n\nThe score is calculated by looking at what percentage of blocks placed during a run touch (either top/bottom or sides, not corners) the block placed immediately before. \nA score of 1 indicates that all blocks were placed on the last one, a score of 0 indicates that the agent switched to a different location to build at every opportunity.",
"_____no_output_____"
]
],
[
[
"mean_touching_last_block_per_agent(df)",
"_____no_output_____"
]
],
[
[
"## Order\nDo agents show a bias in which order different parts of the structure are built? To analyze this, here are the heatmaps per silhouette and per agent that show for each cell the average index of the block in that cell. A value of 3.2 would indicate that the block in that cell was placed on average as the 3.2rd block in that run.",
"_____no_output_____"
]
],
[
[
"heatmaps_block_index_per_agent_over_world(df)",
"_____no_output_____"
]
],
[
[
"## Planning cost\n### How many states are evaluated during planning?\nHow many states are evaluated during planning? This is a proxy for how expensive and effective the planning of an agent is. \n\nLow scores for the runs conditioned on perfect reconstructions indicate that often when a solution can be found, it can be found quickly.",
"_____no_output_____"
]
],
[
[
"total_avg_states_evaluated_per_agent(df)",
"_____no_output_____"
]
],
[
[
"## The effect of tool use\nWhat effect does the use of a tool have?",
"_____no_output_____"
],
[
"### Pairwise efficiency\nIf we run an agent with and without tools, what is the rate of perfect reconstructions it achieves?",
"_____no_output_____"
]
],
[
[
"#manually fill the list of agent pairs with (tool, no tool, label)\nagent_pairs = (\n [\n (\n \"{'agent_type': 'Construction_Paper_Agent', 'decomposition_function': 'random_1_4', 'lower level: agent_type': 'BFS_Agent', 'lower level: scoring_function': 'random_scoring', 'lower level: horizon': 1, 'lower level: scoring_type': 'Final_state', 'lower level: random_seed': None}\",\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'random_scoring', 'horizon': 1, 'scoring_type': 'Final_state'}\",\n \"Random\"),\n (\n \"{'agent_type': 'Construction_Paper_Agent', 'decomposition_function': 'random_1_4', 'lower level: agent_type': 'BFS_Agent', 'lower level: scoring_function': 'silhouette_score', 'lower level: horizon': 1, 'lower level: scoring_type': 'Final_state', 'lower level: random_seed': None}\",\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'silhouette_score', 'horizon': 1, 'scoring_type': 'Final_state'}\",\n \"Horizon 1\"),\n (\n \"{'agent_type': 'Construction_Paper_Agent', 'decomposition_function': 'random_1_4', 'lower level: agent_type': 'BFS_Agent', 'lower level: scoring_function': 'silhouette_score', 'lower level: horizon': 2, 'lower level: scoring_type': 'Final_state', 'lower level: random_seed': None}\",\n \"{'agent_type': 'BFS_Agent', 'scoring_function': 'silhouette_score', 'horizon': 2, 'scoring_type': 'Final_state'}\",\n \"Horizon 2\")]\n)",
"_____no_output_____"
],
[
"scatter_success_pairs(df,agent_pairs)",
"_____no_output_____"
]
],
[
[
"## Subgoal planning",
"_____no_output_____"
],
[
"### How many subgoals are found?\nThis graphs displays the mean number of actual subgoals per run (as in: subgoals passed to the lower level agent, ignoring lookahead) per agent. Note that this only works for agents that act out one subgoal before having to plan again. ",
"_____no_output_____"
]
],
[
[
"mean_num_subgoals_per_agent(df)",
"_____no_output_____"
]
],
[
[
"### What is the cost of subgoal planning?",
"_____no_output_____"
]
],
[
[
"#TODO subgoal planning bar graph",
"_____no_output_____"
],
[
"df",
"_____no_output_____"
],
[
"df['ratio_successful'] = df['_all_sequences'].apply(lambda x:len([s for s in x if s.complete()])/len(x))",
"_____no_output_____"
],
[
"df[['world','all_sequences_planning_cost','lower level: horizon','lower level: scoring_function','ratio_successful']].sort_values(by=['world','lower level: scoring_function','lower level: horizon'])",
"_____no_output_____"
],
[
"seqs = df.query(\"all_sequences_planning_cost == 0\")['_all_sequences'].head(1).item()",
"_____no_output_____"
],
[
"df.columns",
"_____no_output_____"
],
[
"df['seq_names'] = df['_chosen_subgoal_sequence'].apply(get_names)",
"_____no_output_____"
],
[
"def get_names(x):\n try:\n return x.names()\n except:\n return x",
"_____no_output_____"
],
[
"df.query(\"c_weight == 0\")",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
eca9f9224e74ac4440d47b7ca099b15dfb0bf5fa | 25,053 | ipynb | Jupyter Notebook | Practise notebook on Creating Numpy arrays.ipynb | anushka-DS/NUMPY | f1c8f1bfa23263ca29fa6012feec195672e9379c | [
"MIT"
] | null | null | null | Practise notebook on Creating Numpy arrays.ipynb | anushka-DS/NUMPY | f1c8f1bfa23263ca29fa6012feec195672e9379c | [
"MIT"
] | null | null | null | Practise notebook on Creating Numpy arrays.ipynb | anushka-DS/NUMPY | f1c8f1bfa23263ca29fa6012feec195672e9379c | [
"MIT"
] | null | null | null | 26.343849 | 124 | 0.442741 | [
[
[
"import numpy as np\nimport pandas as pd\nimport seaborn as sns\nimport matplotlib.pyplot as plt\n%matplotlib inline",
"_____no_output_____"
],
[
"arr= np.ones(5,dtype= int)\narr",
"_____no_output_____"
],
[
"arr.dtype",
"_____no_output_____"
]
],
[
[
"#### Create an array of 5X3 ones",
"_____no_output_____"
]
],
[
[
"np.ones((5,3),dtype = int) \n# Note: Inside the paranthesis of np.ones(), the format is (row,columns). Hence we have 5 rows and 3 columns in output",
"_____no_output_____"
],
[
"np.ones((4,1),dtype = int).reshape(2,2) ",
"_____no_output_____"
],
[
"np.ones(9,dtype = int).reshape(3,3)",
"_____no_output_____"
],
[
"import random\nnp.random.randint(5,size=10)",
"_____no_output_____"
],
[
"np.random.random(1)",
"_____no_output_____"
],
[
"np.random.random(2)",
"_____no_output_____"
],
[
"np.random.random([3,4])",
"_____no_output_____"
],
[
"np.random.random(4)",
"_____no_output_____"
]
],
[
[
"#### Generate 100 random numbers between 0 and 1",
"_____no_output_____"
]
],
[
[
"np.random.random(100) ",
"_____no_output_____"
]
],
[
[
"#### Create an array of first 10 multiples of 5 using the 'arange' function.",
"_____no_output_____"
]
],
[
[
"np.arange(5,51,5)",
"_____no_output_____"
],
[
"np.arange(3,35,2) #3 to 35 with a step of 2",
"_____no_output_____"
]
],
[
[
"#### Create an array of odd numbers between 1 and 100",
"_____no_output_____"
]
],
[
[
"odd = np.arange(1,101,2)\nodd",
"_____no_output_____"
],
[
"len(odd)",
"_____no_output_____"
]
],
[
[
"#### Create an array of even numbers between 0 and 100",
"_____no_output_____"
]
],
[
[
"np.arange(0,101,2)",
"_____no_output_____"
],
[
"help(np.linspace)",
"Help on function linspace in module numpy:\n\nlinspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0)\n Return evenly spaced numbers over a specified interval.\n \n Returns `num` evenly spaced samples, calculated over the\n interval [`start`, `stop`].\n \n The endpoint of the interval can optionally be excluded.\n \n .. versionchanged:: 1.16.0\n Non-scalar `start` and `stop` are now supported.\n \n Parameters\n ----------\n start : array_like\n The starting value of the sequence.\n stop : array_like\n The end value of the sequence, unless `endpoint` is set to False.\n In that case, the sequence consists of all but the last of ``num + 1``\n evenly spaced samples, so that `stop` is excluded. Note that the step\n size changes when `endpoint` is False.\n num : int, optional\n Number of samples to generate. Default is 50. Must be non-negative.\n endpoint : bool, optional\n If True, `stop` is the last sample. Otherwise, it is not included.\n Default is True.\n retstep : bool, optional\n If True, return (`samples`, `step`), where `step` is the spacing\n between samples.\n dtype : dtype, optional\n The type of the output array. If `dtype` is not given, infer the data\n type from the other input arguments.\n \n .. versionadded:: 1.9.0\n \n axis : int, optional\n The axis in the result to store the samples. Relevant only if start\n or stop are array-like. By default (0), the samples will be along a\n new axis inserted at the beginning. Use -1 to get an axis at the end.\n \n .. versionadded:: 1.16.0\n \n Returns\n -------\n samples : ndarray\n There are `num` equally spaced samples in the closed interval\n ``[start, stop]`` or the half-open interval ``[start, stop)``\n (depending on whether `endpoint` is True or False).\n step : float, optional\n Only returned if `retstep` is True\n \n Size of spacing between samples.\n \n \n See Also\n --------\n arange : Similar to `linspace`, but uses a step size (instead of the\n number of samples).\n geomspace : Similar to `linspace`, but with numbers spaced evenly on a log\n scale (a geometric progression).\n logspace : Similar to `geomspace`, but with the end points specified as\n logarithms.\n \n Examples\n --------\n >>> np.linspace(2.0, 3.0, num=5)\n array([2. , 2.25, 2.5 , 2.75, 3. ])\n >>> np.linspace(2.0, 3.0, num=5, endpoint=False)\n array([2. , 2.2, 2.4, 2.6, 2.8])\n >>> np.linspace(2.0, 3.0, num=5, retstep=True)\n (array([2. , 2.25, 2.5 , 2.75, 3. ]), 0.25)\n \n Graphical illustration:\n \n >>> import matplotlib.pyplot as plt\n >>> N = 8\n >>> y = np.zeros(N)\n >>> x1 = np.linspace(0, 10, N, endpoint=True)\n >>> x2 = np.linspace(0, 10, N, endpoint=False)\n >>> plt.plot(x1, y, 'o')\n [<matplotlib.lines.Line2D object at 0x...>]\n >>> plt.plot(x2, y + 0.5, 'o')\n [<matplotlib.lines.Line2D object at 0x...>]\n >>> plt.ylim([-0.5, 1])\n (-0.5, 1)\n >>> plt.show()\n\n"
]
],
[
[
"#### Array of length 20 equally spaced between 1 and 10",
"_____no_output_____"
]
],
[
[
"np.linspace(1,10,20) # default data type is float",
"_____no_output_____"
],
[
"np.linspace(1,10,20,dtype = int)",
"_____no_output_____"
]
],
[
[
"Create border array\nDescription\nGiven a single integer n, create an (n x n) 2D array with 1 on the border and 0 on the inside.\n\nNote: Make sure the array is of type int.\n\nExample:\n\nInput 1:\n\n4\n\nOutput 1:\n\n[[1 1 1 1]\n\n[1 0 0 1]\n\n[1 0 0 1]\n\n[1 1 1 1]]\n\nInput 2:\n\n2\n\nOutput 2:\n\n[[1 1] \n\n [1 1]] ",
"_____no_output_____"
]
],
[
[
"n = int(input())\n\nimport numpy as np\n\n# Create an 'n*n' array of all ones\nborder_array = np.ones((n,n),dtype = int)\n\n# Fill the array with zeroes from second index (i.e. index 1) to second last index.\n\n# Do this for both row indices and column indices\nborder_array[1:-1, 1:-1] = 0 #[row,column]\n# Print the array created\nprint(border_array)",
"4\n[[1 1 1 1]\n [1 0 0 1]\n [1 0 0 1]\n [1 1 1 1]]\n"
],
[
"n= int(input())\nborder = np.ones((n,n),dtype = int)\nborder[1:-1,1:-1] = 0\nprint(border)",
"6\n[[1 1 1 1 1 1]\n [1 0 0 0 0 1]\n [1 0 0 0 0 1]\n [1 0 0 0 0 1]\n [1 0 0 0 0 1]\n [1 1 1 1 1 1]]\n"
],
[
"help(np.full)",
"Help on function full in module numpy:\n\nfull(shape, fill_value, dtype=None, order='C')\n Return a new array of given shape and type, filled with `fill_value`.\n \n Parameters\n ----------\n shape : int or sequence of ints\n Shape of the new array, e.g., ``(2, 3)`` or ``2``.\n fill_value : scalar or array_like\n Fill value.\n dtype : data-type, optional\n The desired data-type for the array The default, None, means\n `np.array(fill_value).dtype`.\n order : {'C', 'F'}, optional\n Whether to store multidimensional data in C- or Fortran-contiguous\n (row- or column-wise) order in memory.\n \n Returns\n -------\n out : ndarray\n Array of `fill_value` with the given shape, dtype, and order.\n \n See Also\n --------\n full_like : Return a new array with shape of input filled with value.\n empty : Return a new uninitialized array.\n ones : Return a new array setting values to one.\n zeros : Return a new array setting values to zero.\n \n Examples\n --------\n >>> np.full((2, 2), np.inf)\n array([[inf, inf],\n [inf, inf]])\n >>> np.full((2, 2), 10)\n array([[10, 10],\n [10, 10]])\n \n >>> np.full((2, 2), [1, 2])\n array([[1, 2],\n [1, 2]])\n\n"
],
[
"help(np.tile)",
"Help on function tile in module numpy:\n\ntile(A, reps)\n Construct an array by repeating A the number of times given by reps.\n \n If `reps` has length ``d``, the result will have dimension of\n ``max(d, A.ndim)``.\n \n If ``A.ndim < d``, `A` is promoted to be d-dimensional by prepending new\n axes. So a shape (3,) array is promoted to (1, 3) for 2-D replication,\n or shape (1, 1, 3) for 3-D replication. If this is not the desired\n behavior, promote `A` to d-dimensions manually before calling this\n function.\n \n If ``A.ndim > d``, `reps` is promoted to `A`.ndim by pre-pending 1's to it.\n Thus for an `A` of shape (2, 3, 4, 5), a `reps` of (2, 2) is treated as\n (1, 1, 2, 2).\n \n Note : Although tile may be used for broadcasting, it is strongly\n recommended to use numpy's broadcasting operations and functions.\n \n Parameters\n ----------\n A : array_like\n The input array.\n reps : array_like\n The number of repetitions of `A` along each axis.\n \n Returns\n -------\n c : ndarray\n The tiled output array.\n \n See Also\n --------\n repeat : Repeat elements of an array.\n broadcast_to : Broadcast an array to a new shape\n \n Examples\n --------\n >>> a = np.array([0, 1, 2])\n >>> np.tile(a, 2)\n array([0, 1, 2, 0, 1, 2])\n >>> np.tile(a, (2, 2))\n array([[0, 1, 2, 0, 1, 2],\n [0, 1, 2, 0, 1, 2]])\n >>> np.tile(a, (2, 1, 2))\n array([[[0, 1, 2, 0, 1, 2]],\n [[0, 1, 2, 0, 1, 2]]])\n \n >>> b = np.array([[1, 2], [3, 4]])\n >>> np.tile(b, 2)\n array([[1, 2, 1, 2],\n [3, 4, 3, 4]])\n >>> np.tile(b, (2, 1))\n array([[1, 2],\n [3, 4],\n [1, 2],\n [3, 4]])\n \n >>> c = np.array([1,2,3,4])\n >>> np.tile(c,(4,1))\n array([[1, 2, 3, 4],\n [1, 2, 3, 4],\n [1, 2, 3, 4],\n [1, 2, 3, 4]])\n\n"
],
[
"help(np.eye)",
"Help on function eye in module numpy:\n\neye(N, M=None, k=0, dtype=<class 'float'>, order='C')\n Return a 2-D array with ones on the diagonal and zeros elsewhere.\n \n Parameters\n ----------\n N : int\n Number of rows in the output.\n M : int, optional\n Number of columns in the output. If None, defaults to `N`.\n k : int, optional\n Index of the diagonal: 0 (the default) refers to the main diagonal,\n a positive value refers to an upper diagonal, and a negative value\n to a lower diagonal.\n dtype : data-type, optional\n Data-type of the returned array.\n order : {'C', 'F'}, optional\n Whether the output should be stored in row-major (C-style) or\n column-major (Fortran-style) order in memory.\n \n .. versionadded:: 1.14.0\n \n Returns\n -------\n I : ndarray of shape (N,M)\n An array where all elements are equal to zero, except for the `k`-th\n diagonal, whose values are equal to one.\n \n See Also\n --------\n identity : (almost) equivalent function\n diag : diagonal 2-D array from a 1-D array specified by the user.\n \n Examples\n --------\n >>> np.eye(2, dtype=int)\n array([[1, 0],\n [0, 1]])\n >>> np.eye(3, k=1)\n array([[0., 1., 0.],\n [0., 0., 1.],\n [0., 0., 0.]])\n\n"
],
[
"np.eye(3)",
"_____no_output_____"
],
[
"np.eye(3,dtype = int)",
"_____no_output_____"
],
[
"np.eye(4,dtype = int)",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
eca9f95cdd5434ca194da9065a777cb234da59ba | 18,527 | ipynb | Jupyter Notebook | Scrape Newsday.ipynb | kyledef/jammerwebscraper | bf7f9fbb2ccd3547f6d1af31ead92e0cb14641df | [
"MIT"
] | null | null | null | Scrape Newsday.ipynb | kyledef/jammerwebscraper | bf7f9fbb2ccd3547f6d1af31ead92e0cb14641df | [
"MIT"
] | null | null | null | Scrape Newsday.ipynb | kyledef/jammerwebscraper | bf7f9fbb2ccd3547f6d1af31ead92e0cb14641df | [
"MIT"
] | null | null | null | 31.888124 | 1,271 | 0.569223 | [
[
[
"# Web Scraping in Python Series\n\n## Introduction\nThe system will provide a simple example of using python to extract information from a website. Note this is part 1 of 4. Participants are not expected to have any experience in python or background in web scraping. However, some understanding of HTML will be useful.\n\nThis draws inspiration from http://web.stanford.edu/~zlotnick/TextAsData/Web_Scraping_with_Beautiful_Soup.html",
"_____no_output_____"
]
],
[
[
"# Import dependencies (i.e. packages that extend the standard language to perform specific [advance] functionality)\nimport urllib\nimport urllib2\nfrom datetime import datetime, date, timedelta\nfrom bs4 import BeautifulSoup",
"_____no_output_____"
]
],
[
[
"From analysing the newsday archieve website we see that the URL follows a parsable convention\nhttp://www.newsday.co.tt/archives/YYYY-M-DD.html \nSo our general approach will be as follows:\n 1. Generate date in the expected form between an ending and starting date\n 2. Test to ensure the dates generated are valid. (refine step1 based on results)\n 3. Read the content and process based on our goal for scaping the page",
"_____no_output_____"
]
],
[
[
"# Step 1 - create a function to generates a list(array) of dates\ndef genDatesNewsDay(start_date = date.today(), num_days = 3):\n # date_list = [start - timedelta(days=x) for x in range(0, num_days)] # generate a list of dates\n # While we expand the above line for beginners understanding \n date_list = []\n for d in range(0, num_days):\n temp = start_date - timedelta(days=d)\n date_list.append(temp.strftime('%Y-%-m-%d'))# http://strftime.org/ used a reference\n return date_list",
"_____no_output_____"
],
[
"# Step 2 -Test the generated URL to ensure they point to \ndef traverseDatesNewsDay(func, start_date = date.today(), num_days = 3):\n base_url=\"http://www.newsday.co.tt/archives/\"\n dates_str_list = genDatesNewsDay(start_date, num_days)\n for date in dates_str_list:\n url = base_url + date\n func(url)\n \ndef printDate(date):\n print(date)\n \ntraverseDatesNewsDay(printDate)",
"_____no_output_____"
],
[
"from dateutil.relativedelta import relativedelta\n# http://www.guardian.co.tt/archive/2017-02?page=3\nbase_url = \"http://www.guardian.co.tt/archive/\"\n# print date.today().strftime(\"%Y-%-m\")\ndates_str_list = []\npage_content_list = []\nfor i in range(0, 12):\n d = date.today() - relativedelta(months=+i)\n page_url = base_url + d.strftime(\"%Y-%-m\")\n dates_str_list.append(page_url)\n try:\n page_content_list.append( urllib.urlopen(page_url).read() )\n except:\n print \"Unable to find content for {0}\".format(page_url)",
"_____no_output_____"
],
[
"print \"Generated {0} urls and retrieved {1} pages\".format(len(dates_str_list), len(page_content_list))",
"Generated 12 urls and retrieved 12 pages\n"
],
[
"url = dates_str_list[0]\nrequest = urllib2.Request(\"http://www.guardian.co.tt/archive/2017-2\")\nrequest.add_header('User-Agent', user_agent)\nrequest.add_header('Accept-Language', accept_language)\ncontent = urllib2.build_opener().open(request).read()",
"http://www.guardian.co.tt/archive/2017-2\n"
],
[
"def fetch_content(url):\n user_agent=\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3004.3 Safari/537.36\"\n accept_language=\"en-GB,en-US;q=0.8,en;q=0.6\"\n request = urllib2.Request(url)\n request.add_header('User-Agent', user_agent)\n request.add_header('Accept-Language', accept_language)\n content = urllib2.build_opener().open(request).read()\n return content",
"_____no_output_____"
],
[
"beau = BeautifulSoup(content, \"html5lib\")\nmain_block = beau.find(id=\"block-system-main\")\nlinks = main_block.find_all(\"div\", class_=\"view-content\")[0].find_all('a')\nlast = main_block.find(\"li\", class_=\"pager-last last\")\nmax_pages = int(last.find(\"a\")['href'].split(\"=\")[1])\npages_list = range(1, max_pages+1)\n# len(links)",
"_____no_output_____"
],
[
"# url = \"http://www.guardian.co.tt/archive/2017-2\"\n# page = pages_list[0]\n# url = \"{0}?page={1}\".format(url, page)\n# content = fetch_content(url)",
"_____no_output_____"
],
[
"base_url = \"http://www.guardian.co.tt/\"\nstories = []\nstories_links = []\nfor pg in links:\n url = base_url + pg['href']\n stories_links.append(url)\n stories.append( fetch_content(url) )",
"_____no_output_____"
],
[
"first = True\nemo_count = {\n \"anger\" : 0,\n \"disgust\": 0,\n \"fear\" : 0,\n \"joy\" : 0,\n \"sadness\": 0\n}\nsocio_count = {\n \"openness_big5\": 0,\n \"conscientiousness_big5\": 0,\n \"extraversion_big5\" : 0,\n \"agreeableness_big5\" : 0,\n \"emotional_range_big5\": 0\n}",
"_____no_output_____"
],
[
"for story in stories:\n beau = BeautifulSoup(story, \"html5lib\")\n # main_block = beau.find(\"h1\", class_=\"title\")\n paragraphs = beau.find(id=\"block-system-main\").find_all(\"p\")\n page_text = \"\"\n for p in paragraphs:\n page_text += p.get_text()\n\n tone_analyzer = getAnalyser()\n res = tone_analyzer.tone(page_text)\n tone = res['document_tone']['tone_categories']\n emo = tone[0]['tones'] # we want the emotional tone\n soci= tone[2]['tones'] # we also want the social tone\n\n e_res = processTone(emo)\n emo_count[e_res['tone_id']] += 1\n\n s_res = processTone(soci)\n socio_count[s_res['tone_id']] += 1",
"_____no_output_____"
],
[
"for e in emo_count:\n print(\"{0} articles were classified with the emotion {1}\".format(emo_count[e], e))\n\nfor s in socio_count:\n print(\"{0} articles were classified as {1}\".format(socio_count[s], s))",
"4 articles were classified with the emotion anger\n4 articles were classified with the emotion joy\n9 articles were classified with the emotion fear\n15 articles were classified with the emotion sadness\n18 articles were classified with the emotion disgust\n4 articles were classified as extraversion_big5\n9 articles were classified as openness_big5\n22 articles were classified as conscientiousness_big5\n5 articles were classified as agreeableness_big5\n10 articles were classified as emotional_range_big5\n"
],
[
"# Step 3 - Read content and process page\ndef processPage(page_url):\n print(\"Attempting to read content from {0}\".format(page_url))\n page_content = urllib.urlopen(page_url).read()\n beau = BeautifulSoup(page_content, \"html5lib\")\n tables = beau.find_all(\"table\") #https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find-all\n for i in range(0,13):\n named_sec = tables[i].h3\n if named_sec:\n print(\"i {0} produced {1}\".format(i,named_sec))\n article_links = beau.find_all(\"a\", 'title')\n print(\"Found {0} tables and {1} articles\".format(len(tables), len(article_links)))",
"_____no_output_____"
],
[
"# traverseDatesNewsDay(processPage,num_days = 1)",
"_____no_output_____"
]
],
[
[
"\n## The Purpose (Goal) of Scraping\nOur main purpose of developing this exercise was to determine if the statement that the majority of the news published was negative. To do this we need to capture the sentiment of the information extracted from the link. While we can develop sentiment analysis tools using python, the process of training and validating is too much work at this time. Therefore, we utilize the IBM Watson Tone Analyzer API. We selected this API because it provides a greater amount of detail rather than a binary positive or negative result.\n\nTo use the watson api for python:\n\n1. We installed the pip pacakge\n ```bash\n pip install --upgrade watson-developer-cloud\n ```\n2. We created an account (free for 30 days)\n https://tone-analyzer-demo.mybluemix.net/\n \n3. Use the API referene to build application\n http://www.ibm.com/watson/developercloud/tone-analyzer/api/v3/?python#\n4. Created a local_settings.py file that contains the credentials retrieved from signing up",
"_____no_output_____"
]
],
[
[
"# Integrating IBM Watson\nimport json\nfrom watson_developer_cloud import ToneAnalyzerV3\nfrom local_settings import *",
"_____no_output_____"
],
[
"def getAnalyser():\n tone_analyzer = ToneAnalyzerV3(\n username= WATSON_CREDS['username'],\n password= WATSON_CREDS['password'],\n version='2016-05-19')\n return tone_analyzer\n",
"_____no_output_____"
],
[
"# tone_analyzer = getAnalyser()\n# tone_analyzer.tone(text='A word is dead when it is said, some say. Emily Dickinson')",
"_____no_output_____"
],
[
"def analysePage(page_url):\n page_content = urllib.urlopen(page_url).read()\n beau = BeautifulSoup(page_content, \"html5lib\")\n tables = beau.find_all(\"table\") #https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find-all\n article_links = beau.find_all(\"a\", 'title')\n print(\"Found {0} tables and {1} articles\".format(len(tables), len(article_links)))\n for i in article_links:\n print i",
"_____no_output_____"
],
[
"# traverseDatesNewsDay(analysePage,num_days = 1)",
"_____no_output_____"
],
[
"page_content = urllib.urlopen(\"http://www.newsday.co.tt/archives/2017-2-2\").read()\nbeau = BeautifulSoup(page_content, \"html5lib\")\ntables = beau.find_all(\"table\") #https://www.crummy.com/software/BeautifulSoup/bs4/doc/#find-all\narticle_links = beau.find_all(\"a\", 'title')\nprint(\"Found {0} tables and {1} articles\".format(len(tables), len(article_links)))",
"Found 13 tables and 50 articles\n"
],
[
"def processTone(tone):\n large = tone[0]['score']\n large_i = 0\n for i in range(1, len(tone)):\n if tone[i]['score'] > large:\n large = tone[i]['score']\n large_i = i\n return tone[large_i]",
"_____no_output_____"
]
],
[
[
"The Understanding of the structure of the response is provided in the API reference\n\nhttps://www.ibm.com/watson/developercloud/tone-analyzer/api/v3/?python#post-tone",
"_____no_output_____"
]
],
[
[
"first = True\nemo_count = {\n \"anger\" : 0,\n \"disgust\": 0,\n \"fear\" : 0,\n \"joy\" : 0,\n \"sadness\": 0\n}\nsocio_count = {\n \"openness_big5\": 0,\n \"conscientiousness_big5\": 0,\n \"extraversion_big5\" : 0,\n \"agreeableness_big5\" : 0,\n \"emotional_range_big5\": 0\n}\nfor i in article_links:\n res = tone_analyzer.tone(i['title'])\n tone = res['document_tone']['tone_categories']\n emo = tone[0]['tones'] # we want the emotional tone\n soci= tone[2]['tones'] # we also want the social tone\n \n e_res = processTone(emo)\n emo_count[e_res['tone_id']] += 1\n \n s_res = processTone(soci)\n socio_count[s_res['tone_id']] += 1",
"_____no_output_____"
],
[
"for e in emo_count:\n print(\"{0} articles were classified with the emotion {1}\".format(emo_count[e], e))",
"_____no_output_____"
],
[
"for s in socio_count:\n print(\"{0} articles were classified as {1}\".format(socio_count[s], s))",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
]
] |
ecaa035350010c347624ff059ea2315f44b18bfa | 3,959 | ipynb | Jupyter Notebook | Unit3-sprint1-module1.ipynb | ekoly/lambdata-1 | 55e0238cf06ff09c5f4d246c5d96b8d446c5237f | [
"MIT"
] | null | null | null | Unit3-sprint1-module1.ipynb | ekoly/lambdata-1 | 55e0238cf06ff09c5f4d246c5d96b8d446c5237f | [
"MIT"
] | 4 | 2020-03-24T18:23:52.000Z | 2021-06-02T01:16:54.000Z | Unit3-sprint1-module1.ipynb | ekoly/lambdata-1 | 55e0238cf06ff09c5f4d246c5d96b8d446c5237f | [
"MIT"
] | 1 | 2020-01-14T21:32:13.000Z | 2020-01-14T21:32:13.000Z | 23.706587 | 241 | 0.455923 | [
[
[
"<a href=\"https://colab.research.google.com/github/ethanmjansen/lambdata/blob/master/Unit3-sprint1-module1.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
]
],
[
[
"#Initial Imports\nfrom google.colab import files\nimport pandas as pd\nfrom sklearn.model_selection import train_test_split\nfrom scipy.stats import ttest_ind\n!pip install -i https://test.pypi.org/simple/ lambdata-ethanmjansen==0.1.4",
"_____no_output_____"
],
[
"import lambdata_ethanmjansen",
"_____no_output_____"
],
[
"from lambdata_ethanmjansen import df_utils",
"_____no_output_____"
],
[
"uploaded = files.upload()",
"_____no_output_____"
],
[
"df = pd.read_csv('2018_Central_Park_Squirrel_Census_-_Squirrel_Data.csv')",
"_____no_output_____"
],
[
"train, test = df_utils.split(df)",
"_____no_output_____"
],
[
"train.shape, test.shape",
"_____no_output_____"
],
[
"df_utils.ttester(df, 'X', 'Y')",
"Ttest_indResult(statistic=-490443.1749942101, pvalue=0.0)\n"
]
]
] | [
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaa05c7b03f532907ca08258e301052e66766e3 | 132,205 | ipynb | Jupyter Notebook | Predicting1DFunctions.ipynb | kovasb/tutorials | d797d2753d43e79f9cdc75bc58176759553798dc | [
"Apache-2.0"
] | null | null | null | Predicting1DFunctions.ipynb | kovasb/tutorials | d797d2753d43e79f9cdc75bc58176759553798dc | [
"Apache-2.0"
] | null | null | null | Predicting1DFunctions.ipynb | kovasb/tutorials | d797d2753d43e79f9cdc75bc58176759553798dc | [
"Apache-2.0"
] | null | null | null | 85.959038 | 20,260 | 0.773821 | [
[
[
"[View in Colaboratory](https://colab.research.google.com/github/kovasb/tutorials/blob/master/Predicting1DFunctions.ipynb)",
"_____no_output_____"
]
],
[
[
"import tensorflow as tf\nimport numpy as np\n%matplotlib inline\nimport matplotlib.pyplot as plt",
"_____no_output_____"
],
[
"!pip install XXX",
"_____no_output_____"
],
[
"!pip install tf-nightly",
"Collecting tf-nightly\n Downloading tf_nightly-1.5.0.dev20171227-cp27-cp27mu-manylinux1_x86_64.whl (44.4MB)\n\u001b[K 100% |████████████████████████████████| 44.4MB 25kB/s \n\u001b[?25hRequirement already satisfied: mock>=2.0.0 in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nRequirement already satisfied: protobuf>=3.4.0 in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nRequirement already satisfied: wheel in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nCollecting absl-py>=0.1.6 (from tf-nightly)\n Downloading absl-py-0.1.7.tar.gz (78kB)\n\u001b[K 100% |████████████████████████████████| 81kB 7.1MB/s \n\u001b[?25hRequirement already satisfied: backports.weakref>=1.0rc1 in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nRequirement already satisfied: enum34>=1.1.6 in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nRequirement already satisfied: six>=1.10.0 in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nCollecting tb-nightly<1.6.0a0,>=1.5.0a0 (from tf-nightly)\n Downloading tb_nightly-1.5.0a20171227-py2-none-any.whl (3.0MB)\n\u001b[K 100% |████████████████████████████████| 3.0MB 377kB/s \n\u001b[?25hRequirement already satisfied: numpy>=1.12.1 in /usr/local/lib/python2.7/dist-packages (from tf-nightly)\nRequirement already satisfied: funcsigs>=1; python_version < \"3.3\" in /usr/local/lib/python2.7/dist-packages (from mock>=2.0.0->tf-nightly)\nRequirement already satisfied: pbr>=0.11 in /usr/local/lib/python2.7/dist-packages (from mock>=2.0.0->tf-nightly)\nRequirement already satisfied: setuptools in /usr/local/lib/python2.7/dist-packages (from protobuf>=3.4.0->tf-nightly)\nRequirement already satisfied: bleach==1.5.0 in /usr/local/lib/python2.7/dist-packages (from tb-nightly<1.6.0a0,>=1.5.0a0->tf-nightly)\nCollecting futures>=3.1.1; python_version < \"3.2\" (from tb-nightly<1.6.0a0,>=1.5.0a0->tf-nightly)\n Downloading futures-3.2.0-py2-none-any.whl\nRequirement already satisfied: html5lib==0.9999999 in /usr/local/lib/python2.7/dist-packages (from tb-nightly<1.6.0a0,>=1.5.0a0->tf-nightly)\nRequirement already satisfied: werkzeug>=0.11.10 in /usr/local/lib/python2.7/dist-packages (from tb-nightly<1.6.0a0,>=1.5.0a0->tf-nightly)\nRequirement already satisfied: markdown>=2.6.8 in /usr/local/lib/python2.7/dist-packages (from tb-nightly<1.6.0a0,>=1.5.0a0->tf-nightly)\nBuilding wheels for collected packages: absl-py\n Running setup.py bdist_wheel for absl-py ... \u001b[?25l-\b \bdone\n\u001b[?25h Stored in directory: /content/.cache/pip/wheels/c4/71/71/7bd70f858f062d3f99990dcbc3f45b795bde057a42f971537f\nSuccessfully built absl-py\nInstalling collected packages: absl-py, futures, tb-nightly, tf-nightly\n Found existing installation: futures 3.0.5\n Uninstalling futures-3.0.5:\n Successfully uninstalled futures-3.0.5\nSuccessfully installed absl-py-0.1.7 futures-3.2.0 tb-nightly-1.5.0a20171227 tf-nightly-1.5.0.dev20171227\n"
],
[
"import tensorflow as tf",
"_____no_output_____"
],
[
"tf.__version__",
"_____no_output_____"
],
[
"import tensorflow.contrib.eager as tfe\n",
"_____no_output_____"
],
[
"tfe.enable_eager_execution()\n",
"_____no_output_____"
],
[
"tf.matmul([[1, 2],\n [3, 4]],\n [[4, 5],\n [6, 7]])",
"_____no_output_____"
],
[
"y = tf.add(x, 1)",
"_____no_output_____"
],
[
"y",
"_____no_output_____"
]
],
[
[
"## Step 1: Acquire data\n\nWe want to start with some data.\n\n",
"_____no_output_____"
]
],
[
[
"# set of x coordinates\nx = np.arange(0,100).astype(np.float32)\nslope = 3\nintercept = 10\n# corresponding y values at given x's\ny = slope*x+intercept",
"_____no_output_____"
],
[
"x[:10]",
"_____no_output_____"
],
[
"y[:10]",
"_____no_output_____"
]
],
[
[
"## now we turn this into a \"Dataset\" that tf can read",
"_____no_output_____"
]
],
[
[
"input_fn = tf.estimator.inputs.numpy_input_fn({'data':x}, y, batch_size=1, shuffle=False)",
"_____no_output_____"
],
[
"input_fn_2 = tf.estimator.inputs.numpy_input_fn({'data':x}, None, batch_size=1, shuffle=False)",
"_____no_output_____"
]
],
[
[
"## create an estimator",
"_____no_output_____"
]
],
[
[
"estimator = tf.estimator.LinearRegressor(\n feature_columns = [tf.feature_column.numeric_column('data',[1])])",
"INFO:tensorflow:Using default config.\nWARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpOSm9uY\nINFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_task_type': 'worker', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fb0c00799d0>, '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_service': None, '_num_ps_replicas': 0, '_tf_random_seed': None, '_master': '', '_num_worker_replicas': 1, '_task_id': 0, '_log_step_count_steps': 100, '_model_dir': '/tmp/tmpOSm9uY', '_save_summary_steps': 100}\n"
],
[
"estimator.train(input_fn=input_fn, steps=2)",
"INFO:tensorflow:Create CheckpointSaverHook.\nINFO:tensorflow:Saving checkpoints for 1 into /tmp/tmpOSm9uY/model.ckpt.\nINFO:tensorflow:loss = 100.0, step = 1\nINFO:tensorflow:Saving checkpoints for 2 into /tmp/tmpOSm9uY/model.ckpt.\nINFO:tensorflow:Loss for final step: 163.841.\n"
]
],
[
[
"## look at predictions",
"_____no_output_____"
]
],
[
[
"def make_predictions(estimator, input_fn):\n y = np.concatenate(list(x['predictions'] for x in estimator.predict(input_fn=input_fn)))\n return y",
"_____no_output_____"
],
[
"estimator.train(input_fn=input_fn, steps=2)",
"_____no_output_____"
],
[
"predictions = make_predictions(estimator, input_fn)",
"INFO:tensorflow:Restoring parameters from /tmp/tmpOSm9uY/model.ckpt-2\n"
],
[
"\n",
"_____no_output_____"
],
[
"\nplt.plot(predictions)\nplt.ylabel('some numbers')\nplt.show()",
"_____no_output_____"
]
],
[
[
"# Sin",
"_____no_output_____"
]
],
[
[
"# set of x coordinates\nx = np.arange(0,10,0.001).astype(np.float32)\ny = np.sin(x)+1",
"_____no_output_____"
],
[
"x.shape",
"_____no_output_____"
],
[
"plt.plot(y)\nplt.show()",
"_____no_output_____"
],
[
"estimator = tf.estimator.LinearRegressor(\n feature_columns = [tf.feature_column.numeric_column('data',[1])])",
"INFO:tensorflow:Using default config.\nWARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpLQsHEY\nINFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_task_type': 'worker', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fc2e04acf10>, '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_service': None, '_num_ps_replicas': 0, '_tf_random_seed': None, '_master': '', '_num_worker_replicas': 1, '_task_id': 0, '_log_step_count_steps': 100, '_model_dir': '/tmp/tmpLQsHEY', '_save_summary_steps': 100}\n"
],
[
"estimator.train(input_fn=input_fn)",
"_____no_output_____"
],
[
"predictions = make_predictions(estimator, input_fn_2)",
"INFO:tensorflow:Restoring parameters from /tmp/tmpLQsHEY/model.ckpt-62500\n"
],
[
"plt.plot(predictions)\nplt.show()",
"_____no_output_____"
],
[
"input_fn = tf.estimator.inputs.numpy_input_fn({'data':x}, y, batch_size=8, num_epochs=10, shuffle=True)\ninput_fn_2 = tf.estimator.inputs.numpy_input_fn({'data':x}, None, batch_size=1, shuffle=False)",
"_____no_output_____"
],
[
"deep_estimator = tf.estimator.DNNRegressor(\n feature_columns = [tf.feature_column.numeric_column('data',[1])],\n hidden_units = [100,100],\n activation_fn=tf.nn.tanh)",
"INFO:tensorflow:Using default config.\nWARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpF3cqGV\nINFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_task_type': 'worker', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fc2e03ccdd0>, '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_service': None, '_num_ps_replicas': 0, '_tf_random_seed': None, '_master': '', '_num_worker_replicas': 1, '_task_id': 0, '_log_step_count_steps': 100, '_model_dir': '/tmp/tmpF3cqGV', '_save_summary_steps': 100}\n"
],
[
"deep_estimator.train(input_fn=input_fn)",
"_____no_output_____"
],
[
"predictions = make_predictions(deep_estimator, input_fn_2)",
"INFO:tensorflow:Restoring parameters from /tmp/tmpF3cqGV/model.ckpt-12500\n"
],
[
"plt.plot(predictions)\nplt.show()",
"_____no_output_____"
]
],
[
[
"# Sqrt",
"_____no_output_____"
]
],
[
[
"x = np.arange(0,100,0.001).astype(np.float32)\ny = np.sqrt(x)",
"_____no_output_____"
],
[
"plt.plot(y)\nplt.show()",
"_____no_output_____"
],
[
"input_fn = tf.estimator.inputs.numpy_input_fn({'data':x}, y, batch_size=8, num_epochs=10, shuffle=True)\ninput_fn_2 = tf.estimator.inputs.numpy_input_fn({'data':x}, None, batch_size=1, shuffle=False)",
"_____no_output_____"
],
[
"deep_estimator = tf.estimator.DNNRegressor(\n feature_columns = [tf.feature_column.numeric_column('data',[1])],\n hidden_units = [100,100],\n activation_fn=tf.nn.tanh)",
"INFO:tensorflow:Using default config.\nWARNING:tensorflow:Using temporary folder as model directory: /tmp/tmpDW3QLk\nINFO:tensorflow:Using config: {'_save_checkpoints_secs': 600, '_session_config': None, '_keep_checkpoint_max': 5, '_task_type': 'worker', '_is_chief': True, '_cluster_spec': <tensorflow.python.training.server_lib.ClusterSpec object at 0x7fc2e1e9ad10>, '_save_checkpoints_steps': None, '_keep_checkpoint_every_n_hours': 10000, '_service': None, '_num_ps_replicas': 0, '_tf_random_seed': None, '_master': '', '_num_worker_replicas': 1, '_task_id': 0, '_log_step_count_steps': 100, '_model_dir': '/tmp/tmpDW3QLk', '_save_summary_steps': 100}\n"
],
[
"deep_estimator.train(input_fn=input_fn)",
"INFO:tensorflow:Create CheckpointSaverHook.\nINFO:tensorflow:Saving checkpoints for 1 into /tmp/tmpDW3QLk/model.ckpt.\nINFO:tensorflow:loss = 57.4163, step = 1\nINFO:tensorflow:global_step/sec: 681.757\nINFO:tensorflow:loss = 0.0656684, step = 101 (0.151 sec)\nINFO:tensorflow:global_step/sec: 942.453\nINFO:tensorflow:loss = 0.0353383, step = 201 (0.106 sec)\nINFO:tensorflow:global_step/sec: 999.81\nINFO:tensorflow:loss = 0.035398, step = 301 (0.099 sec)\nINFO:tensorflow:global_step/sec: 955.475\nINFO:tensorflow:loss = 0.0181717, step = 401 (0.104 sec)\nINFO:tensorflow:global_step/sec: 915.449\nINFO:tensorflow:loss = 0.0513462, step = 501 (0.109 sec)\nINFO:tensorflow:global_step/sec: 833.917\nINFO:tensorflow:loss = 0.00407947, step = 601 (0.122 sec)\nINFO:tensorflow:global_step/sec: 727.69\nINFO:tensorflow:loss = 0.0145971, step = 701 (0.136 sec)\nINFO:tensorflow:global_step/sec: 791.409\nINFO:tensorflow:loss = 0.0021857, step = 801 (0.129 sec)\nINFO:tensorflow:global_step/sec: 646.864\nINFO:tensorflow:loss = 0.00188054, step = 901 (0.155 sec)\nINFO:tensorflow:global_step/sec: 900.025\nINFO:tensorflow:loss = 0.0455865, step = 1001 (0.116 sec)\nINFO:tensorflow:global_step/sec: 784.123\nINFO:tensorflow:loss = 0.0393134, step = 1101 (0.123 sec)\nINFO:tensorflow:global_step/sec: 697.486\nINFO:tensorflow:loss = 0.0122443, step = 1201 (0.143 sec)\nINFO:tensorflow:global_step/sec: 684.829\nINFO:tensorflow:loss = 0.0286727, step = 1301 (0.147 sec)\nINFO:tensorflow:global_step/sec: 598.058\nINFO:tensorflow:loss = 0.00265724, step = 1401 (0.166 sec)\nINFO:tensorflow:global_step/sec: 556.619\nINFO:tensorflow:loss = 0.00475991, step = 1501 (0.180 sec)\nINFO:tensorflow:global_step/sec: 775.332\nINFO:tensorflow:loss = 0.0136908, step = 1601 (0.129 sec)\nINFO:tensorflow:global_step/sec: 596.445\nINFO:tensorflow:loss = 0.00307145, step = 1701 (0.165 sec)\nINFO:tensorflow:global_step/sec: 638.884\nINFO:tensorflow:loss = 0.025036, step = 1801 (0.157 sec)\nINFO:tensorflow:global_step/sec: 579.327\nINFO:tensorflow:loss = 0.00299198, step = 1901 (0.172 sec)\nINFO:tensorflow:global_step/sec: 606.337\nINFO:tensorflow:loss = 0.000102676, step = 2001 (0.165 sec)\nINFO:tensorflow:global_step/sec: 681.361\nINFO:tensorflow:loss = 0.000738918, step = 2101 (0.147 sec)\nINFO:tensorflow:global_step/sec: 619.276\nINFO:tensorflow:loss = 0.000402727, step = 2201 (0.164 sec)\nINFO:tensorflow:global_step/sec: 585.226\nINFO:tensorflow:loss = 0.000368859, step = 2301 (0.174 sec)\nINFO:tensorflow:global_step/sec: 758.702\nINFO:tensorflow:loss = 0.00358442, step = 2401 (0.125 sec)\nINFO:tensorflow:global_step/sec: 581.45\nINFO:tensorflow:loss = 0.000319641, step = 2501 (0.174 sec)\nINFO:tensorflow:global_step/sec: 828.631\nINFO:tensorflow:loss = 0.0102386, step = 2601 (0.120 sec)\nINFO:tensorflow:global_step/sec: 812.651\nINFO:tensorflow:loss = 0.000266438, step = 2701 (0.122 sec)\nINFO:tensorflow:global_step/sec: 555.047\nINFO:tensorflow:loss = 0.00203519, step = 2801 (0.184 sec)\nINFO:tensorflow:global_step/sec: 577.721\nINFO:tensorflow:loss = 0.00307979, step = 2901 (0.172 sec)\nINFO:tensorflow:global_step/sec: 582.289\nINFO:tensorflow:loss = 0.00824898, step = 3001 (0.170 sec)\n"
],
[
"predictions = make_predictions(deep_estimator, input_fn_2)",
"INFO:tensorflow:Restoring parameters from /tmp/tmpDW3QLk/model.ckpt-12500\n"
],
[
"plt.plot(predictions)\nplt.show()",
"_____no_output_____"
]
],
[
[
"# conversions",
"_____no_output_____"
]
],
[
[
"# features, labels = input_fn()\n# estimator_spec = estimator.model_fn(features, labels, tf.estimator.ModeKeys.PREDICT, {})",
"_____no_output_____"
],
[
"def input_fn_to_generator(input_fn, sess):\n data, labels = input_fn()\n while True:\n try:\n yield sess.run([data, labels])\n except tf.errors.OutOfRangeError:\n raise StopIteration",
"_____no_output_____"
],
[
"# dont work\n# g1 = input_fn_to_generator(input_fn, sess)\n# g1.next()",
"_____no_output_____"
],
[
"def dataset_to_generator(ds, sess):\n iter = ds.make_one_shot_iterator().get_next()\n while True:\n try:\n yield sess.run([iter])\n except tf.errors.OutOfRangeError:\n raise StopIteration",
"_____no_output_____"
],
[
"def dataset_to_numpy(ds, sess):\n gen = dataset_to_generator(ds, sess)\n return np.concatenate(list(gen))",
"_____no_output_____"
],
[
"\n ",
"_____no_output_____"
],
[
"dataset_to_numpy(ds, sess)",
"_____no_output_____"
],
[
"ds = tf.data.Dataset.from_tensor_slices([1,2,3,4])\nsess = tf.Session()",
"_____no_output_____"
],
[
"",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaa0c4d964f0fb3db18e61bfc6f04bdcbec3383 | 22,414 | ipynb | Jupyter Notebook | Big-Data-Clusters/CU4/Public/content/install/sop040-upgrade-pip.ipynb | gantz-at-incomm/tigertoolbox | 9ea80d39a3c5e0c77553fc851c5ee787fbf9291d | [
"MIT"
] | 541 | 2019-05-07T11:41:25.000Z | 2022-03-29T17:33:19.000Z | Big-Data-Clusters/CU4/Public/content/install/sop040-upgrade-pip.ipynb | gantz-at-incomm/tigertoolbox | 9ea80d39a3c5e0c77553fc851c5ee787fbf9291d | [
"MIT"
] | 89 | 2019-05-09T14:23:52.000Z | 2022-01-13T20:21:04.000Z | Big-Data-Clusters/CU4/Public/content/install/sop040-upgrade-pip.ipynb | gantz-at-incomm/tigertoolbox | 9ea80d39a3c5e0c77553fc851c5ee787fbf9291d | [
"MIT"
] | 338 | 2019-05-08T05:45:16.000Z | 2022-03-28T15:35:03.000Z | 57.619537 | 318 | 0.402829 | [
[
[
"SOP040 - Upgrade pip in ADS Python sandbox\n==========================================\n\nSteps\n-----\n\n### Common functions\n\nDefine helper functions used in this notebook.",
"_____no_output_____"
]
],
[
[
"# Define `run` function for transient fault handling, hyperlinked suggestions, and scrolling updates on Windows\nimport sys\nimport os\nimport re\nimport json\nimport platform\nimport shlex\nimport shutil\nimport datetime\n\nfrom subprocess import Popen, PIPE\nfrom IPython.display import Markdown\n\nretry_hints = {} # Output in stderr known to be transient, therefore automatically retry\nerror_hints = {} # Output in stderr where a known SOP/TSG exists which will be HINTed for further help\ninstall_hint = {} # The SOP to help install the executable if it cannot be found\n\nfirst_run = True\nrules = None\ndebug_logging = False\n\ndef run(cmd, return_output=False, no_output=False, retry_count=0):\n \"\"\"Run shell command, stream stdout, print stderr and optionally return output\n\n NOTES:\n\n 1. Commands that need this kind of ' quoting on Windows e.g.:\n\n kubectl get nodes -o jsonpath={.items[?(@.metadata.annotations.pv-candidate=='data-pool')].metadata.name}\n\n Need to actually pass in as '\"':\n\n kubectl get nodes -o jsonpath={.items[?(@.metadata.annotations.pv-candidate=='\"'data-pool'\"')].metadata.name}\n\n The ' quote approach, although correct when pasting into Windows cmd, will hang at the line:\n \n `iter(p.stdout.readline, b'')`\n\n The shlex.split call does the right thing for each platform, just use the '\"' pattern for a '\n \"\"\"\n MAX_RETRIES = 5\n output = \"\"\n retry = False\n\n global first_run\n global rules\n\n if first_run:\n first_run = False\n rules = load_rules()\n\n # When running `azdata sql query` on Windows, replace any \\n in \"\"\" strings, with \" \", otherwise we see:\n #\n # ('HY090', '[HY090] [Microsoft][ODBC Driver Manager] Invalid string or buffer length (0) (SQLExecDirectW)')\n #\n if platform.system() == \"Windows\" and cmd.startswith(\"azdata sql query\"):\n cmd = cmd.replace(\"\\n\", \" \")\n\n # shlex.split is required on bash and for Windows paths with spaces\n #\n cmd_actual = shlex.split(cmd)\n\n # Store this (i.e. kubectl, python etc.) to support binary context aware error_hints and retries\n #\n user_provided_exe_name = cmd_actual[0].lower()\n\n # When running python, use the python in the ADS sandbox ({sys.executable})\n #\n if cmd.startswith(\"python \"):\n cmd_actual[0] = cmd_actual[0].replace(\"python\", sys.executable)\n\n # On Mac, when ADS is not launched from terminal, LC_ALL may not be set, which causes pip installs to fail\n # with:\n #\n # UnicodeDecodeError: 'ascii' codec can't decode byte 0xc5 in position 4969: ordinal not in range(128)\n #\n # Setting it to a default value of \"en_US.UTF-8\" enables pip install to complete\n #\n if platform.system() == \"Darwin\" and \"LC_ALL\" not in os.environ:\n os.environ[\"LC_ALL\"] = \"en_US.UTF-8\"\n\n # When running `kubectl`, if AZDATA_OPENSHIFT is set, use `oc`\n #\n if cmd.startswith(\"kubectl \") and \"AZDATA_OPENSHIFT\" in os.environ:\n cmd_actual[0] = cmd_actual[0].replace(\"kubectl\", \"oc\")\n\n # To aid supportabilty, determine which binary file will actually be executed on the machine\n #\n which_binary = None\n\n # Special case for CURL on Windows. The version of CURL in Windows System32 does not work to\n # get JWT tokens, it returns \"(56) Failure when receiving data from the peer\". If another instance\n # of CURL exists on the machine use that one. (Unfortunately the curl.exe in System32 is almost\n # always the first curl.exe in the path, and it can't be uninstalled from System32, so here we\n # look for the 2nd installation of CURL in the path)\n if platform.system() == \"Windows\" and cmd.startswith(\"curl \"):\n path = os.getenv('PATH')\n for p in path.split(os.path.pathsep):\n p = os.path.join(p, \"curl.exe\")\n if os.path.exists(p) and os.access(p, os.X_OK):\n if p.lower().find(\"system32\") == -1:\n cmd_actual[0] = p\n which_binary = p\n break\n\n # Find the path based location (shutil.which) of the executable that will be run (and display it to aid supportability), this\n # seems to be required for .msi installs of azdata.cmd/az.cmd. (otherwise Popen returns FileNotFound) \n #\n # NOTE: Bash needs cmd to be the list of the space separated values hence shlex.split.\n #\n if which_binary == None:\n which_binary = shutil.which(cmd_actual[0])\n\n if which_binary == None:\n if user_provided_exe_name in install_hint and install_hint[user_provided_exe_name] is not None:\n display(Markdown(f'HINT: Use [{install_hint[user_provided_exe_name][0]}]({install_hint[user_provided_exe_name][1]}) to resolve this issue.'))\n\n raise FileNotFoundError(f\"Executable '{cmd_actual[0]}' not found in path (where/which)\")\n else: \n cmd_actual[0] = which_binary\n\n start_time = datetime.datetime.now().replace(microsecond=0)\n\n print(f\"START: {cmd} @ {start_time} ({datetime.datetime.utcnow().replace(microsecond=0)} UTC)\")\n print(f\" using: {which_binary} ({platform.system()} {platform.release()} on {platform.machine()})\")\n print(f\" cwd: {os.getcwd()}\")\n\n # Command-line tools such as CURL and AZDATA HDFS commands output\n # scrolling progress bars, which causes Jupyter to hang forever, to\n # workaround this, use no_output=True\n #\n\n # Work around a infinite hang when a notebook generates a non-zero return code, break out, and do not wait\n #\n wait = True \n\n try:\n if no_output:\n p = Popen(cmd_actual)\n else:\n p = Popen(cmd_actual, stdout=PIPE, stderr=PIPE, bufsize=1)\n with p.stdout:\n for line in iter(p.stdout.readline, b''):\n line = line.decode()\n if return_output:\n output = output + line\n else:\n if cmd.startswith(\"azdata notebook run\"): # Hyperlink the .ipynb file\n regex = re.compile(' \"(.*)\"\\: \"(.*)\"') \n match = regex.match(line)\n if match:\n if match.group(1).find(\"HTML\") != -1:\n display(Markdown(f' - \"{match.group(1)}\": \"{match.group(2)}\"'))\n else:\n display(Markdown(f' - \"{match.group(1)}\": \"[{match.group(2)}]({match.group(2)})\"'))\n\n wait = False\n break # otherwise infinite hang, have not worked out why yet.\n else:\n print(line, end='')\n if rules is not None:\n apply_expert_rules(line)\n\n if wait:\n p.wait()\n except FileNotFoundError as e:\n if install_hint is not None:\n display(Markdown(f'HINT: Use {install_hint} to resolve this issue.'))\n\n raise FileNotFoundError(f\"Executable '{cmd_actual[0]}' not found in path (where/which)\") from e\n\n exit_code_workaround = 0 # WORKAROUND: azdata hangs on exception from notebook on p.wait()\n\n if not no_output:\n for line in iter(p.stderr.readline, b''):\n try:\n line_decoded = line.decode()\n except UnicodeDecodeError:\n # NOTE: Sometimes we get characters back that cannot be decoded(), e.g.\n #\n # \\xa0\n #\n # For example see this in the response from `az group create`:\n #\n # ERROR: Get Token request returned http error: 400 and server \n # response: {\"error\":\"invalid_grant\",# \"error_description\":\"AADSTS700082: \n # The refresh token has expired due to inactivity.\\xa0The token was \n # issued on 2018-10-25T23:35:11.9832872Z\n #\n # which generates the exception:\n #\n # UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 179: invalid start byte\n #\n print(\"WARNING: Unable to decode stderr line, printing raw bytes:\")\n print(line)\n line_decoded = \"\"\n pass\n else:\n\n # azdata emits a single empty line to stderr when doing an hdfs cp, don't\n # print this empty \"ERR:\" as it confuses.\n #\n if line_decoded == \"\":\n continue\n \n print(f\"STDERR: {line_decoded}\", end='')\n\n if line_decoded.startswith(\"An exception has occurred\") or line_decoded.startswith(\"ERROR: An error occurred while executing the following cell\"):\n exit_code_workaround = 1\n\n # inject HINTs to next TSG/SOP based on output in stderr\n #\n if user_provided_exe_name in error_hints:\n for error_hint in error_hints[user_provided_exe_name]:\n if line_decoded.find(error_hint[0]) != -1:\n display(Markdown(f'HINT: Use [{error_hint[1]}]({error_hint[2]}) to resolve this issue.'))\n\n # apply expert rules (to run follow-on notebooks), based on output\n #\n if rules is not None:\n apply_expert_rules(line_decoded)\n\n # Verify if a transient error, if so automatically retry (recursive)\n #\n if user_provided_exe_name in retry_hints:\n for retry_hint in retry_hints[user_provided_exe_name]:\n if line_decoded.find(retry_hint) != -1:\n if retry_count < MAX_RETRIES:\n print(f\"RETRY: {retry_count} (due to: {retry_hint})\")\n retry_count = retry_count + 1\n output = run(cmd, return_output=return_output, retry_count=retry_count)\n\n if return_output:\n return output\n else:\n return\n\n elapsed = datetime.datetime.now().replace(microsecond=0) - start_time\n\n # WORKAROUND: We avoid infinite hang above in the `azdata notebook run` failure case, by inferring success (from stdout output), so\n # don't wait here, if success known above\n #\n if wait: \n if p.returncode != 0:\n raise SystemExit(f'Shell command:\\n\\n\\t{cmd} ({elapsed}s elapsed)\\n\\nreturned non-zero exit code: {str(p.returncode)}.\\n')\n else:\n if exit_code_workaround !=0 :\n raise SystemExit(f'Shell command:\\n\\n\\t{cmd} ({elapsed}s elapsed)\\n\\nreturned non-zero exit code: {str(exit_code_workaround)}.\\n')\n\n print(f'\\nSUCCESS: {elapsed}s elapsed.\\n')\n\n if return_output:\n return output\n\ndef load_json(filename):\n \"\"\"Load a json file from disk and return the contents\"\"\"\n\n with open(filename, encoding=\"utf8\") as json_file:\n return json.load(json_file)\n\ndef load_rules():\n \"\"\"Load any 'expert rules' from the metadata of this notebook (.ipynb) that should be applied to the stderr of the running executable\"\"\"\n\n # Load this notebook as json to get access to the expert rules in the notebook metadata.\n #\n try:\n j = load_json(\"sop040-upgrade-pip.ipynb\")\n except:\n pass # If the user has renamed the book, we can't load ourself. NOTE: Is there a way in Jupyter, to know your own filename?\n else:\n if \"metadata\" in j and \\\n \"azdata\" in j[\"metadata\"] and \\\n \"expert\" in j[\"metadata\"][\"azdata\"] and \\\n \"expanded_rules\" in j[\"metadata\"][\"azdata\"][\"expert\"]:\n\n rules = j[\"metadata\"][\"azdata\"][\"expert\"][\"expanded_rules\"]\n\n rules.sort() # Sort rules, so they run in priority order (the [0] element). Lowest value first.\n\n # print (f\"EXPERT: There are {len(rules)} rules to evaluate.\")\n\n return rules\n\ndef apply_expert_rules(line):\n \"\"\"Determine if the stderr line passed in, matches the regular expressions for any of the 'expert rules', if so\n inject a 'HINT' to the follow-on SOP/TSG to run\"\"\"\n\n global rules\n\n for rule in rules:\n notebook = rule[1]\n cell_type = rule[2]\n output_type = rule[3] # i.e. stream or error\n output_type_name = rule[4] # i.e. ename or name \n output_type_value = rule[5] # i.e. SystemExit or stdout\n details_name = rule[6] # i.e. evalue or text \n expression = rule[7].replace(\"\\\\*\", \"*\") # Something escaped *, and put a \\ in front of it!\n\n if debug_logging:\n print(f\"EXPERT: If rule '{expression}' satisfied', run '{notebook}'.\")\n\n if re.match(expression, line, re.DOTALL):\n\n if debug_logging:\n print(\"EXPERT: MATCH: name = value: '{0}' = '{1}' matched expression '{2}', therefore HINT '{4}'\".format(output_type_name, output_type_value, expression, notebook))\n\n match_found = True\n\n display(Markdown(f'HINT: Use [{notebook}]({notebook}) to resolve this issue.'))\n\n\n\nprint('Common functions defined successfully.')\n\n# Hints for binary (transient fault) retry, (known) error and install guide\n#\nretry_hints = {'python': []}\nerror_hints = {'python': [['Library not loaded: /usr/local/opt/unixodbc', 'SOP012 - Install unixodbc for Mac', '../install/sop012-brew-install-odbc-for-sql-server.ipynb'], ['WARNING: You are using pip version', 'SOP040 - Upgrade pip in ADS Python sandbox', '../install/sop040-upgrade-pip.ipynb']]}\ninstall_hint = {'python': []}",
"_____no_output_____"
]
],
[
[
"### Upgrade pip",
"_____no_output_____"
]
],
[
[
"import sys\n\nrun(f'python -m pip install --upgrade pip')",
"_____no_output_____"
],
[
"print('Notebook execution complete.')",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
]
] |
ecaa0eeed26865e739204c8166db4f306af12bb5 | 12,975 | ipynb | Jupyter Notebook | tutorials/nonlinear_program.ipynb | RobotLocomotion/drake-python3.7 | ae397a4c6985262d23e9675b9bf3927c08d027f5 | [
"BSD-3-Clause"
] | 2 | 2021-02-25T02:01:02.000Z | 2021-03-17T04:52:04.000Z | tutorials/nonlinear_program.ipynb | RobotLocomotion/drake-python3.7 | ae397a4c6985262d23e9675b9bf3927c08d027f5 | [
"BSD-3-Clause"
] | null | null | null | tutorials/nonlinear_program.ipynb | RobotLocomotion/drake-python3.7 | ae397a4c6985262d23e9675b9bf3927c08d027f5 | [
"BSD-3-Clause"
] | 1 | 2021-06-13T12:05:39.000Z | 2021-06-13T12:05:39.000Z | 34.6 | 516 | 0.574181 | [
[
[
"# Nonlinear Program (NLP) Tutorial\nFor instructions on how to run these tutorial notebooks, please see the [README](https://github.com/RobotLocomotion/drake/blob/master/tutorials/README.md).\n\n## Important Note\nPlease refer to the [MathematicalProgram Tutorial](./mathematical_program.ipynb) for constructing and solving a general optimization program in Drake.\n\n## Nonlinear Program\nA Nonlinear Programming (NLP) problem is a special type of optimization problem. The cost and/or constraints in an NLP are nonlinear functions of decision variables. The mathematical formulation of a general NLP is\n\\begin{align}\n\\min_x&\\; f(x)\\\\\n\\text{subject to }& g_i(x)\\leq 0\n\\end{align}\nwhere $f(x)$ is the cost function, and $g_i(x)$ is the i'th constraint.\n\nAn NLP is typically solved through gradient-based optimization (like gradient descent, SQP, interior point methods, etc). These methods rely on the gradient of the cost/constraints $\\partial f/\\partial x, \\partial g_i/\\partial x$. pydrake can compute the gradient of many functions through automatic differentiation, so very often the user doesn't need to manually provide the gradient.\n\n## Setting the objective\nThe user can call `AddCost` function to add a nonlinear cost into the program. Note that the user can call `AddCost` repeatedly, and the program will evaluate the *summation* of each individual cost as the total cost.",
"_____no_output_____"
],
[
"### Adding a cost through a python function\nWe can define a cost through a python function, and then add this python function to the objective through `AddCost` function. When adding a cost, we should provide the variable associated with that cost, the syntax is `AddCost(cost_evaluator, vars=associated_variables)`, which means the cost is evaluated on the `associated_variables`.In the code example below, We first demonstrate how to construct an optimization program with 3 decision variables, then we show how to add a cost through a python function.",
"_____no_output_____"
]
],
[
[
"from pydrake.solvers.mathematicalprogram import MathematicalProgram, Solve\nimport numpy as np\n\n# Create an empty MathematicalProgram named prog (with no decision variables,\n# constraints or costs)\nprog = MathematicalProgram()\n# Add three decision variables x[0], x[1], x[2]\nx = prog.NewContinuousVariables(3, \"x\")",
"_____no_output_____"
],
[
"def cost_fun(z):\n cos_z = np.cos(z[0] + z[1])\n sin_z = np.sin(z[0] + z[1])\n return cos_z**2 + cos_z + sin_z\n# Add the cost evaluated with x[0] and x[1].\ncost1 = prog.AddCost(cost_fun, vars=[x[0], x[1]])\nprint(cost1)",
"_____no_output_____"
]
],
[
[
"Notice that by changing the argument `vars` in `AddCost` function, we can add the cost to a different set of variables. In the code example below, we use the same python function `cost_fun`, but impose this cost on the variable `x[0], x[2]`.",
"_____no_output_____"
]
],
[
[
"cost2 = prog.AddCost(cost_fun, vars=[x[0], x[2]])\nprint(cost2)",
"_____no_output_____"
]
],
[
[
"### Adding cost through a lambda function\nA more compact approach to add a cost is through a lambda function. For example, the code below adds a cost $x[1]^2 + x[0]$ to the optimization program.",
"_____no_output_____"
]
],
[
[
"# Add a cost x[1]**2 + x[0] using a lambda function.\ncost3 = prog.AddCost(lambda z: z[0]**2 + z[1], vars = [x[1], x[0]])\nprint(cost3)",
"_____no_output_____"
]
],
[
[
"If we change the associated variables, then it represents a different cost. For example, we can use the same lambda function, but add the cost $x[1]^2 + x[2]$ to the program by changing the argument to `vars`",
"_____no_output_____"
]
],
[
[
"cost4 = prog.AddCost(lambda z: z[0]**2 + z[1], vars = x[1:])\nprint(cost4)",
"_____no_output_____"
]
],
[
[
"## Adding quadratic cost\nIn NLP, adding a quadratic cost $0.5x^TQx+ b'x+c$ is very common. pydrake provides multiple functions to add quadratic cost, including\n- `AddQuadraticCost`\n- `AddQuadraticErrorCost`\n- `AddL2NormCost`\n\n### AddQuadraticCost\nWe can add a simple quadratic expression as a cost.",
"_____no_output_____"
]
],
[
[
"cost4 = prog.AddQuadraticCost(x[0]**2 + 3 * x[1]**2 + 2*x[0]*x[1] + 2*x[1] * x[0] + 1)\nprint(cost4)",
"_____no_output_____"
]
],
[
[
"If the user knows the matrix form of `Q` and `b`, then it is faster to pass in these matrices to `AddQuadraticCost`, instead of using the symbolic quadratic expression as above.",
"_____no_output_____"
]
],
[
[
"# Add a cost x[0]**2 + 2*x[1]**2 + x[0]*x[1] + 3*x[1] + 1.\ncost5 = prog.AddQuadraticCost(\n Q=np.array([[2., 1], [1., 4.]]),\n b=np.array([0., 3.]),\n c=1.,\n vars=x[:2])\nprint(cost5)",
"_____no_output_____"
]
],
[
[
"### AddQuadraticErrorCost\nThis function adds a cost of the form $(x - x_{des})^TQ(x-x_{des})$.",
"_____no_output_____"
]
],
[
[
"cost6 = prog.AddQuadraticErrorCost(\n Q=np.array([[1, 0.5], [0.5, 1]]),\n x_desired=np.array([1., 2.]),\n vars=x[1:])\nprint(cost6)",
"_____no_output_____"
]
],
[
[
"### AddL2NormCost\nThis function adds a quadratic cost of the form $(Ax-b)^T(Ax-b)$",
"_____no_output_____"
]
],
[
[
"# Add the L2 norm cost on (A*x[:2] - b).dot(A*x[:2]-b)\ncost7 = prog.AddL2NormCost(\n A=np.array([[1., 2.], [2., 3], [3., 4]]),\n b=np.array([2, 3, 1.]),\n vars=x[:2])\nprint(cost7)",
"_____no_output_____"
]
],
[
[
"## Adding constraints\n\nDrake supports adding constraints in the following form\n\\begin{align}\nlower \\leq g(x) \\leq upper\n\\end{align}\nwhere $g(x)$ returns a numpy vector.\n\nThe user can call `AddConstraint(g, lower, upper, vars=x)` to add the constraint. Here `g` must be a python function (or a lambda function).",
"_____no_output_____"
]
],
[
[
"## Define a python function to add the constraint x[0]**2 + 2x[1]<=1, -0.5<=sin(x[1])<=0.5\ndef constraint_evaluator1(z):\n return np.array([z[0]**2+2*z[1], np.sin(z[1])])\n\nconstraint1 = prog.AddConstraint(\n constraint_evaluator1,\n lb=np.array([-np.inf, -0.5]),\n ub=np.array([1., 0.5]),\n vars=x[:2])\nprint(constraint1)\n\n# Add another constraint using lambda function.\nconstraint2 = prog.AddConstraint(\n lambda z: np.array([z[0]*z[1]]),\n lb=[0.],\n ub=[1.],\n vars=[x[2]])\nprint(constraint2)",
"_____no_output_____"
]
],
[
[
"## Solving the nonlinear program\n\nOnce all the constraints and costs are added to the program, we can call the `Solve` function to solve the program and call `GetSolution` to obtain the results. Solving an NLP requires an initial guess on all the decision variables. If the user doesn't specify an initial guess, we will use a zero vector by default.",
"_____no_output_____"
]
],
[
[
"## Solve a simple nonlinear \n# min -x0\n# subject to x1 - exp(x0) >= 0\n# x2 - exp(x1) >= 0\n# 0 <= x0 <= 100\n# 0 <= x1 <= 100\n# 0 <= x2 <= 10\nprog = MathematicalProgram()\nx = prog.NewContinuousVariables(3)\n# The cost is a linear function, so we call AddLinearCost\nprog.AddLinearCost(-x[0])\n# Now add the constraint x1-exp(x0)>=0 and x2-exp(x1)>=0\nprog.AddConstraint(\n lambda z: np.array([z[1]-np.exp(z[0]), z[2]-np.exp(z[1])]),\n lb=[0, 0],\n ub=[np.inf, np.inf],\n vars=x)\n# Add the bounding box constraint 0<=x0<=100, 0<=x1<=100, 0<=x2<=10\nprog.AddBoundingBoxConstraint(0, 100, x[:2])\nprog.AddBoundingBoxConstraint(0, 10, x[2])\n\n# Now solve the program with initial guess x=[1, 2, 3]\nresult = Solve(prog, np.array([1.,2.,3.]))\nprint(f\"Is optimization successful? {result.is_success()}\")\nprint(f\"Solution to x: {result.GetSolution(x)}\")\nprint(f\"optimal cost: {result.get_optimal_cost()}\")",
"_____no_output_____"
]
],
[
[
"### Setting the initial guess\nSome NLPs might have many decision variables. In order to set the initial guess for these decision variables, we provide a function `SetInitialGuess` to set the initial guess of a subset of decision variables. For example, in the problem below, we want to find the two closest points $p_1$ and $p_2$, where $p_1$ is on the unit circle, and $p_2$ is on the curve $y=x^2$, we can set the initial guess for these two variables separately by calling `SetInitialGuess`.",
"_____no_output_____"
]
],
[
[
"import matplotlib.pyplot as plt\nprog = MathematicalProgram()\np1 = prog.NewContinuousVariables(2, \"p1\")\np2 = prog.NewContinuousVariables(2, \"p2\")\n\n# Add the constraint that p1 is on the unit circle centered at (0, 2)\nprog.AddConstraint(\n lambda z: [z[0]**2 + (z[1]-2)**2],\n lb=np.array([1.]),\n ub=np.array([1.]),\n vars=p1)\n\n# Add the constraint that p2 is on the curve y=x*x\nprog.AddConstraint(\n lambda z: [z[1] - z[0]**2],\n lb=[0.],\n ub=[0.],\n vars=p2)\n\n# Add the cost on the distance between p1 and p2\nprog.AddQuadraticCost((p1-p2).dot(p1-p2))\n\n# Set the value of p1 in initial guess to be [0, 1]\nprog.SetInitialGuess(p1, [0., 1.])\n# Set the value of p2 in initial guess to be [1, 1]\nprog.SetInitialGuess(p2, [1., 1.])\n\n# Now solve the program\nresult = Solve(prog)\nprint(f\"Is optimization successful? {result.is_success()}\")\np1_sol = result.GetSolution(p1)\np2_sol = result.GetSolution(p2)\nprint(f\"solution to p1 {p1_sol}\")\nprint(f\"solution to p2 {p2_sol}\")\nprint(f\"optimal cost {result.get_optimal_cost()}\")\n\n# Plot the solution.\nplt.figure()\nplt.plot(np.cos(np.linspace(0, 2*np.pi, 100)), 2+np.sin(np.linspace(0, 2*np.pi, 100)))\nplt.plot(np.linspace(-2, 2, 100), np.power(np.linspace(-2, 2, 100), 2))\nplt.plot(p1_sol[0], p1_sol[1], '*')\nplt.plot(p2_sol[0], p2_sol[1], '*')\nplt.axis('equal')\nplt.show()",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecaa147549a7f56258b80229b7f5b751bc370d90 | 26,150 | ipynb | Jupyter Notebook | Toxic_Comment_Classification_Challenge/Kernel/toxic_comment_classification_notebook.ipynb | mankutimma/machine-learning-kaggle | 86af47b9c4600f22412c427fefe7ed652d1fa9f2 | [
"Apache-2.0"
] | null | null | null | Toxic_Comment_Classification_Challenge/Kernel/toxic_comment_classification_notebook.ipynb | mankutimma/machine-learning-kaggle | 86af47b9c4600f22412c427fefe7ed652d1fa9f2 | [
"Apache-2.0"
] | 1 | 2018-01-15T05:42:22.000Z | 2018-01-18T17:07:33.000Z | Toxic_Comment_Classification_Challenge/Kernel/toxic_comment_classification_notebook.ipynb | mankutimma/machine-learning-kaggle | 86af47b9c4600f22412c427fefe7ed652d1fa9f2 | [
"Apache-2.0"
] | null | null | null | 33.143219 | 933 | 0.592467 | [
[
[
"**Perform the necessary imports**",
"_____no_output_____"
]
],
[
[
"import numpy as np\nimport pandas as pd\nfrom keras.preprocessing import text, sequence\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Activation\nfrom keras.layers import Embedding\nfrom keras.layers import Conv1D, GlobalMaxPooling1D\nfrom sklearn.model_selection import train_test_split",
"Using TensorFlow backend.\n"
]
],
[
[
"**Necessary global variables**",
"_____no_output_____"
]
],
[
[
"list_of_classes = [\"toxic\", \"severe_toxic\", \"obscene\", \"threat\", \"insult\", \"identity_hate\"]\nmax_features = 20000\nmax_text_length = 400\nembedding_dims = 50\nfilters = 250\nkernel_size = 3\nhidden_dims = 250\nbatch_size = 32\nepochs = 2",
"_____no_output_____"
]
],
[
[
"**Quick peek into the data**",
"_____no_output_____"
]
],
[
[
"train_df = pd.read_csv('../input/train.csv')\nprint(train_df.head())",
" id comment_text toxic \\\n0 22256635 Nonsense? kiss off, geek. what I said is true... 1 \n1 27450690 \"\\n\\n Please do not vandalize pages, as you di... 0 \n2 54037174 \"\\n\\n \"\"Points of interest\"\" \\n\\nI removed the... 0 \n3 77493077 Asking some his nationality is a Racial offenc... 0 \n4 79357270 The reader here is not going by my say so for ... 0 \n\n severe_toxic obscene threat insult identity_hate \n0 0 0 0 0 0 \n1 0 0 0 0 0 \n2 0 0 0 0 0 \n3 0 0 0 0 0 \n4 0 0 0 0 0 \n"
]
],
[
[
"**Printing using 'iloc' just for fun**",
"_____no_output_____"
]
],
[
[
"print(train_df.iloc[0, -7])\nprint(train_df.iloc[0, 1])",
"Nonsense? kiss off, geek. what I said is true. I'll have your account terminated.\nNonsense? kiss off, geek. what I said is true. I'll have your account terminated.\n"
]
],
[
[
"**Checking if NaNs exist in the training data**",
"_____no_output_____"
]
],
[
[
"print(np.where(pd.isnull(train_df)))",
"(array([], dtype=int64), array([], dtype=int64))\n"
]
],
[
[
"**Apparently no NaNs in the training set!**",
"_____no_output_____"
],
[
"**Converting pandas series to a numpy array using .values**",
"_____no_output_____"
]
],
[
[
"x = train_df['comment_text'].values\nprint(x)",
"[ \"Nonsense? kiss off, geek. what I said is true. I'll have your account terminated.\"\n '\"\\n\\n Please do not vandalize pages, as you did with this edit to W. S. Merwin. If you continue to do so, you will be blocked from editing. \"'\n '\"\\n\\n \"\"Points of interest\"\" \\n\\nI removed the \"\"points of interest\"\" section you added because it seemed kind of spammy. I know you probably didn\\'t mean to disobey the rules, but generally, a point of interest tends to be rather touristy, and quite irrelevant to an area culture. That\\'s just my opinion, though.\\n\\nIf you want to reply, just put your reply here and add {{talkback|Jamiegraham08}} on my talkpage. \"'\n ...,\n 'Mamoun Darkazanli\\nFor some reason I am unable to fix the bold formatting on the Arabic name of Mamoun Darkazanli. The entire first paragraph is bolded and I just want to bold the script. Please take a look when you get the chance.'\n 'Salafi would be a better term. It is more politically correct to use in Islam. Very few Muslims, even those who do not agree with those sects, use the term Islamist. The proper term used in Islamic circles is salafi, if anything. Sometime wahabi, but that is considered to be deragatory by some.'\n 'making wikipedia a better and more inviting place.']\n"
],
[
"print(\"properties of x\")\nprint(\"type : {}, dimensions : {}, shape : {}, total no. of elements : {}, data type of each element: {}, size of each element {} bytes\".format(type(x), x.ndim, x.shape, x.size, x.dtype, x.itemsize))",
"properties of x\ntype : <class 'numpy.ndarray'>, dimensions : 1, shape : (95851,), total no. of elements : 95851, data type of each element: object, size of each element 8 bytes\n"
]
],
[
[
"**Getting the labels**",
"_____no_output_____"
]
],
[
[
"y = train_df[list_of_classes].values\nprint(y)",
"[[1 0 0 0 0 0]\n [0 0 0 0 0 0]\n [0 0 0 0 0 0]\n ..., \n [0 0 0 0 0 0]\n [0 0 0 0 0 0]\n [0 0 0 0 0 0]]\n"
],
[
"print(\"properties of y\")\nprint(\"type : {}, dimensions : {}, shape : {}, total no. of elements : {}, data type of each element: {}, size of each element {} bytes\".format(type(y), y.ndim, y.shape, y.size, y.dtype, y.itemsize))",
"properties of y\ntype : <class 'numpy.ndarray'>, dimensions : 2, shape : (95851, 6), total no. of elements : 575106, data type of each element: int64, size of each element 8 bytes\n"
]
],
[
[
"**Keras makes our life easy. Using Tokenizer to get a list of sequence and then padding it form a 2D numpy array **",
"_____no_output_____"
]
],
[
[
"x_tokenizer = text.Tokenizer(num_words=max_features)\nprint(x_tokenizer)\nx_tokenizer.fit_on_texts(list(x))\nprint(x_tokenizer)\nx_tokenized = x_tokenizer.texts_to_sequences(x) #list of lists(containing numbers), so basically a list of sequences, not a numpy array\n#pad_sequences:transform a list of num_samples sequences (lists of scalars) into a 2D Numpy array of shape \nx_train_val = sequence.pad_sequences(x_tokenized, maxlen=max_text_length)",
"<keras.preprocessing.text.Tokenizer object at 0x7f70241c6278>\n<keras.preprocessing.text.Tokenizer object at 0x7f70241c6278>\n"
],
[
"print(\"properties of x_train_val\")\nprint(\"type : {}, dimensions : {}, shape : {}, total no. of elements : {}, data type of each element: {}, size of each element {} bytes\".format(type(x_train_val), x_train_val.ndim, x_train_val.shape, x_train_val.size, x_train_val.dtype, x_train_val.itemsize))",
"properties of x_train_val\ntype : <class 'numpy.ndarray'>, dimensions : 2, shape : (95851, 400), total no. of elements : 38340400, data type of each element: int32, size of each element 4 bytes\n"
]
],
[
[
"**90% of the data is used for training and the rest for validation**",
"_____no_output_____"
]
],
[
[
"x_train, x_val, y_train, y_val = train_test_split(x_train_val, y, test_size=0.1, random_state=1)",
"_____no_output_____"
]
],
[
[
"**Start building the model**",
"_____no_output_____"
]
],
[
[
"print('Build model...')\nmodel = Sequential()\n\n# we start off with an efficient embedding layer which maps\n# our vocab indices into embedding_dims dimensions\nmodel.add(Embedding(max_features,\n embedding_dims,\n input_length=max_text_length))\nmodel.add(Dropout(0.2))\n\n# we add a Convolution1D, which will learn filters\n# word group filters of size filter_length:\nmodel.add(Conv1D(filters,\n kernel_size,\n padding='valid',\n activation='relu',\n strides=1))\n# we use max pooling:\nmodel.add(GlobalMaxPooling1D())\n\n# We add a vanilla hidden layer:\nmodel.add(Dense(hidden_dims))\nmodel.add(Dropout(0.2))\nmodel.add(Activation('relu'))\n\n# We project onto 6 output layers, and squash it with a sigmoid:\nmodel.add(Dense(6))\nmodel.add(Activation('sigmoid'))\n\nmodel.compile(loss='binary_crossentropy',\n optimizer='adam',\n metrics=['accuracy'])\n\nmodel.summary()",
"Build model...\nWARNING:tensorflow:From /opt/conda/lib/python3.6/site-packages/tensorflow/python/util/deprecation.py:381: calling conv1d (from tensorflow.python.ops.nn_ops) with data_format=NHWC is deprecated and will be removed in a future version.\nInstructions for updating:\n`NHWC` for data_format is deprecated, use `NWC` instead\n_________________________________________________________________\nLayer (type) Output Shape Param # \n=================================================================\nembedding_1 (Embedding) (None, 400, 50) 1000000 \n_________________________________________________________________\ndropout_1 (Dropout) (None, 400, 50) 0 \n_________________________________________________________________\nconv1d_1 (Conv1D) (None, 398, 250) 37750 \n_________________________________________________________________\nglobal_max_pooling1d_1 (Glob (None, 250) 0 \n_________________________________________________________________\ndense_1 (Dense) (None, 250) 62750 \n_________________________________________________________________\ndropout_2 (Dropout) (None, 250) 0 \n_________________________________________________________________\nactivation_1 (Activation) (None, 250) 0 \n_________________________________________________________________\ndense_2 (Dense) (None, 6) 1506 \n_________________________________________________________________\nactivation_2 (Activation) (None, 6) 0 \n=================================================================\nTotal params: 1,102,006\nTrainable params: 1,102,006\nNon-trainable params: 0\n_________________________________________________________________\n"
]
],
[
[
"**Begin training**",
"_____no_output_____"
]
],
[
[
"model.fit(x_train, y_train,\n batch_size=batch_size,\n epochs=epochs,\nvalidation_data=(x_val, y_val))",
"Train on 86265 samples, validate on 9586 samples\nEpoch 1/2\n86265/86265 [==============================] - 493s 6ms/step - loss: 0.0732 - acc: 0.9762 - val_loss: 0.0568 - val_acc: 0.9796\nEpoch 2/2\n86265/86265 [==============================] - 503s 6ms/step - loss: 0.0479 - acc: 0.9821 - val_loss: 0.0568 - val_acc: 0.9797\n"
]
],
[
[
"**Good job! 98% accuracy on the validation set. Scope for improvement exists!**",
"_____no_output_____"
],
[
"**Quick peek into the test set**",
"_____no_output_____"
]
],
[
[
"test_df = pd.read_csv('../input/test.csv')\nprint(test_df.head())",
" id comment_text\n0 6044863 ==Orphaned non-free media (Image:41cD1jboEvL. ...\n1 6102620 ::Kentuckiana is colloquial. Even though the ...\n2 14563293 Hello fellow Wikipedians,\\nI have just modifie...\n3 21086297 AKC Suspensions \\nThe Morning Call - Feb 24, 2...\n4 22982444 == [WIKI_LINK: Talk:Celts] ==\n"
]
],
[
[
"**Checking if NaNs exist in the test data**",
"_____no_output_____"
]
],
[
[
"print(np.where(pd.isnull(test_df)))",
"(array([52300]), array([1]))\n"
]
],
[
[
"**Hmmm**",
"_____no_output_____"
]
],
[
[
"test_df.iloc[52300, 1]",
"_____no_output_____"
]
],
[
[
"**Fill the NaN field**",
"_____no_output_____"
]
],
[
[
"x_test = test_df['comment_text'].fillna('comment_missing').values\nprint(x_test)",
"['==Orphaned non-free media (Image:41cD1jboEvL. SS500 .jpg)=='\n '::Kentuckiana is colloquial. Even though the area is often referred to as this, it (in my opinion) has never held the encyclopedic precision of \"Louisville metropolitian area\", which has a specific U.S. Census definition. Also, apparently Kentuckiana often refers to the local television viewing area, which isn\\'t nearly contiguous with the official metro area. As you indicate, Kentuckiana seems to be more of a slang or marketing phenomena than anything we could pin down in encyclopedic terms here. That\\'s why we see Wikipedia language like \"the Louisville metropolitan area, sometimes referred to as Kentuckiana\". That\\'s my take on it. — •'\n 'Hello fellow Wikipedians,\\nI have just modified on [WIKI_LINK: Double Trouble (George Jones and Johnny Paycheck album)]. Please take a moment to review [EXTERNAL_LINK: my edit]. If you have any questions, or need the bot to ignore the links, or the page altogether, please visit for additional information. I made the following changes:\\n*Added archive [EXTERNA_LINK: https://web.archive.org/web/20070403204132/http://www.epiccenter.com/] to [EXTERNA_LINK: http://www.epiccenter.com/]\\nWhen you have finished reviewing my changes, please set the checked parameter below to true or failed to let others know (documentation at ).\\nCheers.—'\n ...,\n '==Fair use rationale for [WIKI_LINK: Image:D.R.I. - Definition.jpg]=='\n '== Employment Practices at Majestic =='\n 'Welcome to Wikipedia. Although everyone is welcome to make constructive contributions to Wikipedia, at least one of your recent edits, such as the one you made to [WIKI_LINK: INevel2], did not appear to be constructive and has been automatically [WIKI_LINK: Help:Reverting@reverted] by . Please use [WIKI_LINK: Wikipedia:Sandbox@the sandbox] for any test edits you would like to make, and take a look at the [WIKI_LINK: Wikipedia:Introduction@welcome page] to learn more about contributing to this encyclopedia. If you believe there has been a mistake and would like to report a false positive, please and then remove this warning from your talk page. If your edit was not vandalism, please feel free to make your edit again after reporting it. The following is the log entry regarding this warning: [WIKI_LINK: INevel2] was [EXTERNAL_LINK: changed] by blanking the page on 2007-12-25T19:53:51+00:00 . Thank you.']\n"
]
],
[
[
"**Tokenizing and padding similar to what we did before to training data**",
"_____no_output_____"
]
],
[
[
"x_test_tokenized = x_tokenizer.texts_to_sequences(x_test)\nx_testing = sequence.pad_sequences(x_test_tokenized, maxlen=max_text_length)",
"_____no_output_____"
]
],
[
[
"**Time to predict!**",
"_____no_output_____"
]
],
[
[
"y_testing = model.predict(x_testing, verbose = 1)",
"226998/226998 [==============================] - 210s 925us/step\n"
]
],
[
[
"**Submit predictions!**",
"_____no_output_____"
]
],
[
[
"sample_submission = pd.read_csv(\"../input/sample_submission.csv\")\nsample_submission[list_of_classes] = y_testing\nsample_submission.to_csv(\"toxic_comment_classification.csv\", index=False)",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecaa1748edb9f090575e229b1e670bbfe7b4f16d | 303,802 | ipynb | Jupyter Notebook | inspirational_cnns.ipynb | Yue1Harriet1Huang/Handson-Fraud-Detection-with-Deep-Learning-draft | 7523ed2970fe859feab25a8a296729cd98bf90ae | [
"Apache-2.0"
] | null | null | null | inspirational_cnns.ipynb | Yue1Harriet1Huang/Handson-Fraud-Detection-with-Deep-Learning-draft | 7523ed2970fe859feab25a8a296729cd98bf90ae | [
"Apache-2.0"
] | null | null | null | inspirational_cnns.ipynb | Yue1Harriet1Huang/Handson-Fraud-Detection-with-Deep-Learning-draft | 7523ed2970fe859feab25a8a296729cd98bf90ae | [
"Apache-2.0"
] | null | null | null | 94.260627 | 29,118 | 0.671605 | [
[
[
"**Chapter – Inspiration from CNN to Fraud Detection**\n\n_This is the description and code used to generate some of the figures in chapter._",
"_____no_output_____"
],
[
"There are ways to infer the bigger context of which a pixel is in, for example, is the pixel of a background or a foreground, called pixel-wise prediction tagging a label for each pixel. This concept can be extended to Part-of-Speech in NLP. The solution comes into rescue transforming lower dimention embeddings of certain content to an high resolution image. ",
"_____no_output_____"
],
[
"# Code example 1-1",
"_____no_output_____"
],
[
"Although Python 2.x may work, it is deprecated so we strongly recommend you use Python 3 instead.",
"_____no_output_____"
]
],
[
[
"# Python ≥3.5 is required\nimport sys\nassert sys.version_info >= (3, 5)",
"_____no_output_____"
],
[
"# Scikit-Learn ≥0.20 is required\nimport sklearn\nassert sklearn.__version__ >= \"0.20\"",
"_____no_output_____"
]
],
[
[
"This function just merges the OECD's life satisfaction data and the IMF's GDP per capita data. It's a bit too long and boring and it's not specific to Machine Learning, which is why I left it out of the book.",
"_____no_output_____"
]
],
[
[
"def prepare_country_stats(oecd_bli, gdp_per_capita):\n oecd_bli = oecd_bli[oecd_bli[\"INEQUALITY\"]==\"TOT\"]\n oecd_bli = oecd_bli.pivot(index=\"Country\", columns=\"Indicator\", values=\"Value\")\n gdp_per_capita.rename(columns={\"2015\": \"GDP per capita\"}, inplace=True)\n gdp_per_capita.set_index(\"Country\", inplace=True)\n full_country_stats = pd.merge(left=oecd_bli, right=gdp_per_capita,\n left_index=True, right_index=True)\n full_country_stats.sort_values(by=\"GDP per capita\", inplace=True)\n remove_indices = [0, 1, 6, 8, 33, 34, 35]\n keep_indices = list(set(range(36)) - set(remove_indices))\n return full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[keep_indices]",
"_____no_output_____"
]
],
[
[
"The code in the book expects the data files to be located in the current directory. I just tweaked it here to fetch the files in datasets/lifesat.",
"_____no_output_____"
]
],
[
[
"import os\ndatapath = os.path.join(\"datasets\", \"lifesat\", \"\")",
"_____no_output_____"
],
[
"# To plot pretty figures directly within Jupyter\n%matplotlib inline\nimport matplotlib as mpl\nmpl.rc('axes', labelsize=14)\nmpl.rc('xtick', labelsize=12)\nmpl.rc('ytick', labelsize=12)",
"_____no_output_____"
],
[
"# Code example\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nimport sklearn.linear_model\n\n# Load the data\noecd_bli = pd.read_csv(datapath + \"oecd_bli_2015.csv\", thousands=',')\ngdp_per_capita = pd.read_csv(datapath + \"gdp_per_capita.csv\",thousands=',',delimiter='\\t',\n encoding='latin1', na_values=\"n/a\")\n\n# Prepare the data\ncountry_stats = prepare_country_stats(oecd_bli, gdp_per_capita)\nX = np.c_[country_stats[\"GDP per capita\"]]\ny = np.c_[country_stats[\"Life satisfaction\"]]\n\n# Visualize the data\ncountry_stats.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction')\nplt.show()\n\n# Select a linear model\nmodel = sklearn.linear_model.LinearRegression()\n\n# Train the model\nmodel.fit(X, y)\n\n# Make a prediction for Cyprus\nX_new = [[22587]] # Cyprus' GDP per capita\nprint(model.predict(X_new)) # outputs [[ 5.96242338]]",
"_____no_output_____"
],
[
"",
"_____no_output_____"
],
[
"",
"_____no_output_____"
],
[
"",
"_____no_output_____"
]
],
[
[
"# Note: you can ignore the rest of this notebook, it just generates many of the figures in chapter 1.",
"_____no_output_____"
]
],
[
[
"",
"_____no_output_____"
],
[
"",
"_____no_output_____"
],
[
"",
"_____no_output_____"
]
],
[
[
"Create a function to save the figures.",
"_____no_output_____"
]
],
[
[
"# Where to save the figures\nPROJECT_ROOT_DIR = \".\"\nCHAPTER_ID = \"fundamentals\"\nIMAGES_PATH = os.path.join(PROJECT_ROOT_DIR, \"images\", CHAPTER_ID)\nos.makedirs(IMAGES_PATH, exist_ok=True)\n\ndef save_fig(fig_id, tight_layout=True, fig_extension=\"png\", resolution=300):\n path = os.path.join(IMAGES_PATH, fig_id + \".\" + fig_extension)\n print(\"Saving figure\", fig_id)\n if tight_layout:\n plt.tight_layout()\n plt.savefig(path, format=fig_extension, dpi=resolution)",
"_____no_output_____"
]
],
[
[
"Make this notebook's output stable across runs:",
"_____no_output_____"
]
],
[
[
"np.random.seed(42)",
"_____no_output_____"
]
],
[
[
"# Load and prepare Life satisfaction data",
"_____no_output_____"
],
[
"If you want, you can get fresh data from the OECD's website.\nDownload the CSV from http://stats.oecd.org/index.aspx?DataSetCode=BLI\nand save it to `datasets/lifesat/`.",
"_____no_output_____"
]
],
[
[
"oecd_bli = pd.read_csv(datapath + \"oecd_bli_2015.csv\", thousands=',')\noecd_bli = oecd_bli[oecd_bli[\"INEQUALITY\"]==\"TOT\"]\noecd_bli = oecd_bli.pivot(index=\"Country\", columns=\"Indicator\", values=\"Value\")\noecd_bli.head(2)",
"_____no_output_____"
],
[
"oecd_bli[\"Life satisfaction\"].head()",
"_____no_output_____"
]
],
[
[
"# Load and prepare GDP per capita data",
"_____no_output_____"
],
[
"Just like above, you can update the GDP per capita data if you want. Just download data from http://goo.gl/j1MSKe (=> imf.org) and save it to `datasets/lifesat/`.",
"_____no_output_____"
]
],
[
[
"gdp_per_capita = pd.read_csv(datapath+\"gdp_per_capita.csv\", thousands=',', delimiter='\\t',\n encoding='latin1', na_values=\"n/a\")\ngdp_per_capita.rename(columns={\"2015\": \"GDP per capita\"}, inplace=True)\ngdp_per_capita.set_index(\"Country\", inplace=True)\ngdp_per_capita.head(2)",
"_____no_output_____"
],
[
"full_country_stats = pd.merge(left=oecd_bli, right=gdp_per_capita, left_index=True, right_index=True)\nfull_country_stats.sort_values(by=\"GDP per capita\", inplace=True)\nfull_country_stats",
"_____no_output_____"
],
[
"full_country_stats[[\"GDP per capita\", 'Life satisfaction']].loc[\"United States\"]",
"_____no_output_____"
],
[
"remove_indices = [0, 1, 6, 8, 33, 34, 35]\nkeep_indices = list(set(range(36)) - set(remove_indices))\n\nsample_data = full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[keep_indices]\nmissing_data = full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[remove_indices]",
"_____no_output_____"
],
[
"sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\nplt.axis([0, 60000, 0, 10])\nposition_text = {\n \"Hungary\": (5000, 1),\n \"Korea\": (18000, 1.7),\n \"France\": (29000, 2.4),\n \"Australia\": (40000, 3.0),\n \"United States\": (52000, 3.8),\n}\nfor country, pos_text in position_text.items():\n pos_data_x, pos_data_y = sample_data.loc[country]\n country = \"U.S.\" if country == \"United States\" else country\n plt.annotate(country, xy=(pos_data_x, pos_data_y), xytext=pos_text,\n arrowprops=dict(facecolor='black', width=0.5, shrink=0.1, headwidth=5))\n plt.plot(pos_data_x, pos_data_y, \"ro\")\nsave_fig('money_happy_scatterplot')\nplt.show()",
"Saving figure money_happy_scatterplot\n"
],
[
"sample_data.to_csv(os.path.join(\"datasets\", \"lifesat\", \"lifesat.csv\"))",
"_____no_output_____"
],
[
"sample_data.loc[list(position_text.keys())]",
"_____no_output_____"
],
[
"import numpy as np\n\nsample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\nplt.axis([0, 60000, 0, 10])\nX=np.linspace(0, 60000, 1000)\nplt.plot(X, 2*X/100000, \"r\")\nplt.text(40000, 2.7, r\"$\\theta_0 = 0$\", fontsize=14, color=\"r\")\nplt.text(40000, 1.8, r\"$\\theta_1 = 2 \\times 10^{-5}$\", fontsize=14, color=\"r\")\nplt.plot(X, 8 - 5*X/100000, \"g\")\nplt.text(5000, 9.1, r\"$\\theta_0 = 8$\", fontsize=14, color=\"g\")\nplt.text(5000, 8.2, r\"$\\theta_1 = -5 \\times 10^{-5}$\", fontsize=14, color=\"g\")\nplt.plot(X, 4 + 5*X/100000, \"b\")\nplt.text(5000, 3.5, r\"$\\theta_0 = 4$\", fontsize=14, color=\"b\")\nplt.text(5000, 2.6, r\"$\\theta_1 = 5 \\times 10^{-5}$\", fontsize=14, color=\"b\")\nsave_fig('tweaking_model_params_plot')\nplt.show()",
"Saving figure tweaking_model_params_plot\n"
],
[
"from sklearn import linear_model\nlin1 = linear_model.LinearRegression()\nXsample = np.c_[sample_data[\"GDP per capita\"]]\nysample = np.c_[sample_data[\"Life satisfaction\"]]\nlin1.fit(Xsample, ysample)\nt0, t1 = lin1.intercept_[0], lin1.coef_[0][0]\nt0, t1",
"_____no_output_____"
],
[
"sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3))\nplt.axis([0, 60000, 0, 10])\nX=np.linspace(0, 60000, 1000)\nplt.plot(X, t0 + t1*X, \"b\")\nplt.text(5000, 3.1, r\"$\\theta_0 = 4.85$\", fontsize=14, color=\"b\")\nplt.text(5000, 2.2, r\"$\\theta_1 = 4.91 \\times 10^{-5}$\", fontsize=14, color=\"b\")\nsave_fig('best_fit_model_plot')\nplt.show()\n",
"Saving figure best_fit_model_plot\n"
],
[
"cyprus_gdp_per_capita = gdp_per_capita.loc[\"Cyprus\"][\"GDP per capita\"]\nprint(cyprus_gdp_per_capita)\ncyprus_predicted_life_satisfaction = lin1.predict([[cyprus_gdp_per_capita]])[0][0]\ncyprus_predicted_life_satisfaction",
"22587.49\n"
],
[
"sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(5,3), s=1)\nX=np.linspace(0, 60000, 1000)\nplt.plot(X, t0 + t1*X, \"b\")\nplt.axis([0, 60000, 0, 10])\nplt.text(5000, 7.5, r\"$\\theta_0 = 4.85$\", fontsize=14, color=\"b\")\nplt.text(5000, 6.6, r\"$\\theta_1 = 4.91 \\times 10^{-5}$\", fontsize=14, color=\"b\")\nplt.plot([cyprus_gdp_per_capita, cyprus_gdp_per_capita], [0, cyprus_predicted_life_satisfaction], \"r--\")\nplt.text(25000, 5.0, r\"Prediction = 5.96\", fontsize=14, color=\"b\")\nplt.plot(cyprus_gdp_per_capita, cyprus_predicted_life_satisfaction, \"ro\")\nsave_fig('cyprus_prediction_plot')\nplt.show()",
"Saving figure cyprus_prediction_plot\n"
],
[
"sample_data[7:10]",
"_____no_output_____"
],
[
"(5.1+5.7+6.5)/3",
"_____no_output_____"
],
[
"backup = oecd_bli, gdp_per_capita\n\ndef prepare_country_stats(oecd_bli, gdp_per_capita):\n oecd_bli = oecd_bli[oecd_bli[\"INEQUALITY\"]==\"TOT\"]\n oecd_bli = oecd_bli.pivot(index=\"Country\", columns=\"Indicator\", values=\"Value\")\n gdp_per_capita.rename(columns={\"2015\": \"GDP per capita\"}, inplace=True)\n gdp_per_capita.set_index(\"Country\", inplace=True)\n full_country_stats = pd.merge(left=oecd_bli, right=gdp_per_capita,\n left_index=True, right_index=True)\n full_country_stats.sort_values(by=\"GDP per capita\", inplace=True)\n remove_indices = [0, 1, 6, 8, 33, 34, 35]\n keep_indices = list(set(range(36)) - set(remove_indices))\n return full_country_stats[[\"GDP per capita\", 'Life satisfaction']].iloc[keep_indices]",
"_____no_output_____"
],
[
"# Code example\nimport matplotlib.pyplot as plt\nimport numpy as np\nimport pandas as pd\nimport sklearn.linear_model\n\n# Load the data\noecd_bli = pd.read_csv(datapath + \"oecd_bli_2015.csv\", thousands=',')\ngdp_per_capita = pd.read_csv(datapath + \"gdp_per_capita.csv\",thousands=',',delimiter='\\t',\n encoding='latin1', na_values=\"n/a\")\n\n# Prepare the data\ncountry_stats = prepare_country_stats(oecd_bli, gdp_per_capita)\nX = np.c_[country_stats[\"GDP per capita\"]]\ny = np.c_[country_stats[\"Life satisfaction\"]]\n\n# Visualize the data\ncountry_stats.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction')\nplt.show()\n\n# Select a linear model\nmodel = sklearn.linear_model.LinearRegression()\n\n# Train the model\nmodel.fit(X, y)\n\n# Make a prediction for Cyprus\nX_new = [[22587]] # Cyprus' GDP per capita\nprint(model.predict(X_new)) # outputs [[ 5.96242338]]",
"_____no_output_____"
],
[
"oecd_bli, gdp_per_capita = backup",
"_____no_output_____"
],
[
"missing_data",
"_____no_output_____"
],
[
"position_text2 = {\n \"Brazil\": (1000, 9.0),\n \"Mexico\": (11000, 9.0),\n \"Chile\": (25000, 9.0),\n \"Czech Republic\": (35000, 9.0),\n \"Norway\": (60000, 3),\n \"Switzerland\": (72000, 3.0),\n \"Luxembourg\": (90000, 3.0),\n}",
"_____no_output_____"
],
[
"sample_data.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(8,3))\nplt.axis([0, 110000, 0, 10])\n\nfor country, pos_text in position_text2.items():\n pos_data_x, pos_data_y = missing_data.loc[country]\n plt.annotate(country, xy=(pos_data_x, pos_data_y), xytext=pos_text,\n arrowprops=dict(facecolor='black', width=0.5, shrink=0.1, headwidth=5))\n plt.plot(pos_data_x, pos_data_y, \"rs\")\n\nX=np.linspace(0, 110000, 1000)\nplt.plot(X, t0 + t1*X, \"b:\")\n\nlin_reg_full = linear_model.LinearRegression()\nXfull = np.c_[full_country_stats[\"GDP per capita\"]]\nyfull = np.c_[full_country_stats[\"Life satisfaction\"]]\nlin_reg_full.fit(Xfull, yfull)\n\nt0full, t1full = lin_reg_full.intercept_[0], lin_reg_full.coef_[0][0]\nX = np.linspace(0, 110000, 1000)\nplt.plot(X, t0full + t1full * X, \"k\")\n\nsave_fig('representative_training_data_scatterplot')\nplt.show()",
"Saving figure representative_training_data_scatterplot\n"
],
[
"full_country_stats.plot(kind='scatter', x=\"GDP per capita\", y='Life satisfaction', figsize=(8,3))\nplt.axis([0, 110000, 0, 10])\n\nfrom sklearn import preprocessing\nfrom sklearn import pipeline\n\npoly = preprocessing.PolynomialFeatures(degree=60, include_bias=False)\nscaler = preprocessing.StandardScaler()\nlin_reg2 = linear_model.LinearRegression()\n\npipeline_reg = pipeline.Pipeline([('poly', poly), ('scal', scaler), ('lin', lin_reg2)])\npipeline_reg.fit(Xfull, yfull)\ncurve = pipeline_reg.predict(X[:, np.newaxis])\nplt.plot(X, curve)\nsave_fig('overfitting_model_plot')\nplt.show()",
"/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/numpy/lib/nanfunctions.py:1431: RuntimeWarning: overflow encountered in multiply\n sqr = np.multiply(arr, arr, out=arr)\n/Users/ageron/.virtualenvs/tf2/lib/python3.6/site-packages/numpy/core/fromnumeric.py:83: RuntimeWarning: overflow encountered in reduce\n return ufunc.reduce(obj, axis, dtype, out, **passkwargs)\n"
],
[
"full_country_stats.loc[[c for c in full_country_stats.index if \"W\" in c.upper()]][\"Life satisfaction\"]",
"_____no_output_____"
],
[
"gdp_per_capita.loc[[c for c in gdp_per_capita.index if \"W\" in c.upper()]].head()",
"_____no_output_____"
],
[
"plt.figure(figsize=(8,3))\n\nplt.xlabel(\"GDP per capita\")\nplt.ylabel('Life satisfaction')\n\nplt.plot(list(sample_data[\"GDP per capita\"]), list(sample_data[\"Life satisfaction\"]), \"bo\")\nplt.plot(list(missing_data[\"GDP per capita\"]), list(missing_data[\"Life satisfaction\"]), \"rs\")\n\nX = np.linspace(0, 110000, 1000)\nplt.plot(X, t0full + t1full * X, \"r--\", label=\"Linear model on all data\")\nplt.plot(X, t0 + t1*X, \"b:\", label=\"Linear model on partial data\")\n\nridge = linear_model.Ridge(alpha=10**9.5)\nXsample = np.c_[sample_data[\"GDP per capita\"]]\nysample = np.c_[sample_data[\"Life satisfaction\"]]\nridge.fit(Xsample, ysample)\nt0ridge, t1ridge = ridge.intercept_[0], ridge.coef_[0][0]\nplt.plot(X, t0ridge + t1ridge * X, \"b\", label=\"Regularized linear model on partial data\")\n\nplt.legend(loc=\"lower right\")\nplt.axis([0, 110000, 0, 10])\nsave_fig('ridge_model_plot')\nplt.show()",
"Saving figure ridge_model_plot\n"
],
[
"backup = oecd_bli, gdp_per_capita\n\ndef prepare_country_stats(oecd_bli, gdp_per_capita):\n return sample_data",
"_____no_output_____"
],
[
"# Replace this linear model:\nimport sklearn.linear_model\nmodel = sklearn.linear_model.LinearRegression()",
"_____no_output_____"
],
[
"# with this k-neighbors regression model:\nimport sklearn.neighbors\nmodel = sklearn.neighbors.KNeighborsRegressor(n_neighbors=3)",
"_____no_output_____"
],
[
"X = np.c_[country_stats[\"GDP per capita\"]]\ny = np.c_[country_stats[\"Life satisfaction\"]]\n\n# Train the model\nmodel.fit(X, y)\n\n# Make a prediction for Cyprus\nX_new = np.array([[22587.0]]) # Cyprus' GDP per capita\nprint(model.predict(X_new)) # outputs [[ 5.76666667]]",
"[[5.76666667]]\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaa31ce734e3525043e5131428308a1f53c5a92 | 925,357 | ipynb | Jupyter Notebook | deprecated/Lending Club Modeling - Random Forest old.ipynb | JifuZhao/Lending-Club-Loan-Analysis | 4b22680d10931922e024e9f10e7b259c22f47327 | [
"MIT"
] | 6 | 2019-05-18T22:45:54.000Z | 2021-06-06T18:34:56.000Z | deprecated/Lending Club Modeling - Random Forest old.ipynb | JifuZhao/Lending-Club-Loan-Analysis | 4b22680d10931922e024e9f10e7b259c22f47327 | [
"MIT"
] | null | null | null | deprecated/Lending Club Modeling - Random Forest old.ipynb | JifuZhao/Lending-Club-Loan-Analysis | 4b22680d10931922e024e9f10e7b259c22f47327 | [
"MIT"
] | 12 | 2019-01-27T12:08:58.000Z | 2021-10-11T04:49:24.000Z | 199.688606 | 505,984 | 0.852576 | [
[
[
"<img src=\"./result/logo.png\" alt=\"Drawing\" align=\"left\" style=\"width: 500px;\"/>",
"_____no_output_____"
]
],
[
[
"# import necessary packages\nimport warnings\nwarnings.simplefilter('ignore')\n\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nimport seaborn as sns\nimport gc\n\nfrom sklearn.metrics import auc, roc_curve, log_loss\nfrom sklearn.preprocessing import LabelEncoder\nfrom sklearn.utils import shuffle\nfrom imblearn.over_sampling import RandomOverSampler\n\nimport h2o\nfrom h2o.frame import H2OFrame\nfrom h2o.estimators.random_forest import H2ORandomForestEstimator\nfrom h2o.grid.grid_search import H2OGridSearch\n\n%matplotlib inline",
"Using TensorFlow backend.\n"
]
],
[
[
"# Lending Club Loan Data Analysis and Modeling",
"_____no_output_____"
],
[
"Classification is one of two most common data science problems (another one is regression). For the supervised classification problem, imbalanced data is pretty common yet very challanging. For example, credit card fraud detection, disease classification, network intrusion and so on, are classification problem with imbalanced data. \n\nIn this project, working with the Lending Club loan data, we hope to correctly predict whether or not on loan will be default using the history data.",
"_____no_output_____"
],
[
"# Contents\n1. Problem Statement\n2. Data Exploration\n3. Data Cleaning and Initial Feature Engineering\n - Feature transformation\n - Missing values\n - Feature transformation\n - Feature normalization\n - And so on ......\n4. Visualization\n5. Further Feature Engineering\n6. Machine Learning\n - Random Forest\n7. Conclusions",
"_____no_output_____"
],
[
"# 1. Problem Statment",
"_____no_output_____"
],
[
"For companies like Lending Club, correctlly predicting whether or not one loan will be default is very important. In this project, using the historical data, more specifically, the Lending Club loan data from 2007 to 2015, we hope to build a machine learning model such that we can predict the chance of default for the future loans. As I will show later, this dataset is highly imbalanced and includes a lot of features, which makes this problem more challanging. ",
"_____no_output_____"
],
[
"# 2. Data Exploration",
"_____no_output_____"
],
[
"There are several ways to download the dataset, for example, you can go to Lending Club's [website](https://www.lendingclub.com/info/download-data.action), or you can go to [Kaggle](https://www.kaggle.com/wendykan/lending-club-loan-data).\n\nI will use the loan data from 2007 to 2015 as the training set (+ validation set), and use the data from 2016 as the test set.",
"_____no_output_____"
],
[
"| Attribute | Explanation |\n| ------------------------ | ----------------------------------------------------------------- |\n| id\t | A unique LC assigned ID for the loan listing. |\n| member_id\t | A unique LC assigned Id for the borrower member. |\n| loan_amnt\t | The listed amount of the loan applied for by the borrower. If at some point in time, the credit department reduces the loan amount, then it will be reflected in this value. |\n| funded_amnt\t | The total amount committed to that loan at that point in time. |\n| funded_amnt_inv\t | The total amount committed by investors for that loan at that point in time. |\n| term\t | The number of payments on the loan. Values are in months and can be either 36 or 60. |\n| int_rate\t | Interest Rate on the loan |\n| installment\t | The monthly payment owed by the borrower if the loan originates. |\n| grade\t | LC assigned loan grade |\n| sub_grade\t | LC assigned loan subgrade |\n| emp_title\t | The job title supplied by the Borrower when applying for the loan.|\n| emp_length\t | Employment length in years. Possible values are between 0 and 10 where 0 means less than one year and 10 means ten or more years. |\n| home_ownership\t | The home ownership status provided by the borrower during registration. Our values are: RENT, OWN, MORTGAGE, OTHER.. |\n| annual_inc\t | The self-reported annual income provided by the borrower during registration. |\n| verification_status\t | |\n| issue_d\t | The month which the loan was funded |\n| loan_status\t | Current status of the loan |\n| pymnt_plan\t | Indicates if a payment plan has been put in place for the loan |\n| url\t | URL for the LC page with listing data. |\n| desc\t | Loan description provided by the borrower |\n| purpose\t | A category provided by the borrower for the loan request. |\n| title\t | The loan title provided by the borrower |\n| zip_code\t | The first 3 numbers of the zip code provided by the borrower in the loan application. |\n| addr_state\t | The state provided by the borrower in the loan application |\n| dti\t | A ratio calculated using the borrower’s total monthly debt payments on the total debt obligations, excluding mortgage and the requested LC loan, divided by the borrower’s self-reported monthly income. |\n| delinq_2yrs\t | The number of 30+ days past-due incidences of delinquency in the borrower's credit file for the past 2 years |\n| earliest_cr_line\t | The month the borrower's earliest reported credit line was opened |\n| inq_last_6mths\t | The number of inquiries in past 6 months (excluding auto and mortgage inquiries) |\n| mths_since_last_delinq\t | The number of months since the borrower's last delinquency. |\n| mths_since_last_record\t | The number of months since the last public record. |\n| open_acc\t | The number of open credit lines in the borrower's credit file. |\n| pub_rec\t | Number of derogatory public records |\n| revol_bal\t | Total credit revolving balance | \n| revol_util\t | Revolving line utilization rate, or the amount of credit the borrower is using relative to all available revolving credit. |\n| total_acc\t | The total number of credit lines currently in the borrower's credit file |\n| initial_list_status\t | The initial listing status of the loan. Possible values are – W, F|\n| out_prncp\t | Remaining outstanding principal for total amount funded |\n| out_prncp_inv\t | Remaining outstanding principal for portion of total amount funded by investors |\n| total_pymnt\t | Payments received to date for total amount funded |\n| total_pymnt_inv\t | Payments received to date for portion of total amount funded by investors |\n| total_rec_prncp\t | Principal received to date |\n| total_rec_int\t | Interest received to date |\n| total_rec_late_fee\t | Late fees received to date |\n| recoveries\t | post charge off gross recovery |\n| collection_recovery_fee | post charge off collection fee |\n| last_pymnt_d\t | Last month payment was received |\n| last_pymnt_amnt\t | Last total payment amount received |\n| next_pymnt_d\t | Next scheduled payment date |\n| last_credit_pull_d\t | The most recent month LC pulled credit for this loan |\n| collections_12_mths_ex_med | Number of collections in 12 months excluding medical collections |\n| mths_since_last_major_derog| Months since most recent 90-day or worse rating |\n| policy_code\t | \"publicly available policy_code=1, new products not publicly available policy_code=2\" |\n| application_type\t | Indicates whether the loan is an individual application or a joint application with two co-borrowers |\n| annual_inc_joint\t | The combined self-reported annual income provided by the co-borrowers during registration |\n| dti_joint\t | A ratio calculated using the co-borrowers' total monthly payments on the total debt obligations, excluding mortgages and the requested LC loan, divided by the co-borrowers' combined self-reported monthly income |\n| verified_status_joint\t | Indicates if the co-borrowers' joint income was verified by LC, not verified, or if the income source was verified |\n| acc_now_delinq\t | The number of accounts on which the borrower is now delinquent. |\n| tot_coll_amt\t | Total collection amounts ever owed |\n| tot_cur_bal\t | Total current balance of all accounts |\n| open_acc_6m\t | Number of open trades in last 6 months |\n| open_il_6m\t | Number of currently active installment trades |\n| open_il_12m\t | Number of installment accounts opened in past 12 months |\n| open_il_24m\t | Number of installment accounts opened in past 24 months |\n| mths_since_rcnt_il\t | Months since most recent installment accounts opened |\n| total_bal_il\t | Total current balance of all installment accounts |\n| il_util\t | Ratio of total current balance to high credit/credit limit on all install acct |\n| open_rv_12m\t | Number of revolving trades opened in past 12 months |\n| open_rv_24m\t | Number of revolving trades opened in past 24 months |\n| max_bal_bc\t | Maximum current balance owed on all revolving accounts |\n| all_util\t | Balance to credit limit on all trades |\n| total_rev_hi_lim \t | Total revolving high credit/credit limit |\n| inq_fi\t | Number of personal finance inquiries |\n| total_cu_tl\t | Number of finance trades |\n| inq_last_12m\t | Number of credit inquiries in past 12 months |",
"_____no_output_____"
]
],
[
[
"# Load the training and test data set\ntrain = pd.read_csv('./data/2007-2015-loan.csv', low_memory=False, encoding='ISO-8859-1')\ntest = pd.read_csv('./data/2016-loan.csv', low_memory=False, encoding='ISO-8859-1')\n\n# There are 74 features in total\nprint('Train:\\t', train.shape)\nprint('Test:\\t', test.shape)",
"Train:\t (887379, 74)\nTest:\t (434407, 74)\n"
],
[
"train.head()",
"_____no_output_____"
],
[
"test.head()",
"_____no_output_____"
],
[
"# Create a concise table for the data\ntrain_dtype = train.dtypes.values\ntrain_missing = train.isnull().sum().values\ntrain_missing_ratio = train_missing / len(train)\n\ntest_dtype = test.dtypes.values\ntest_missing = test.isnull().sum().values\ntest_missing_ratio = test_missing / len(test)\n\n# Calculate unique values\ntrain_unique = []\ntest_unique = []\nfor name in train.columns:\n train_unique.append(train[name].unique().shape[0])\n test_unique.append(test[name].unique().shape[0])\n\n# Useful information\ntmp_map = {'Columns': train.columns, 'Train dtype': train_dtype, 'Train missing': train_missing, \n 'Train missing ratio': train_missing_ratio, 'Train unique': train_unique, 'Test dtype': test_dtype,\n 'Test missing': test_missing, 'Test missing ratio': test_missing_ratio, 'Test unique': test_unique}\ncolumns = ['Columns', 'Train dtype', 'Train missing', 'Train missing ratio', 'Train unique',\n 'Test dtype', 'Test missing', 'Test missing ratio', 'Test unique']\ndf = pd.DataFrame(tmp_map, columns=columns)\n\npd.options.display.max_rows = 75\ndf",
"_____no_output_____"
]
],
[
[
"We should notice some differences between the training and test set, and look into details. Some major difference are:\n1. For test set, `id`, `member_id`, and `url` are totally missing, which is different from training set\n2. For training set, `open_acc_6m`, `open_il_6m`, `open_il_12m`, `open_il_24m`, `mths_since_rcnt_il`, `total_bal_il`, `il_util`, `open_rv_12m`, `open_rv_24m`, `max_bal_bc`, `all_util`, `inq_fi`, `total_cu_tl`, and `inq_last_12m` are almost missing in training set, which is different from test set\n3. `desc`, `mths_since_last_delinq`, `mths_since_last_record`, `mths_since_last_major_derog`, `annual_inc_joint`, `dti_joint`, and `verification_status_joint` have large amount of missing values\n4. There are multiple `loan status`, but we only concern whether or not the load is default",
"_____no_output_____"
],
[
"# 3. Data Cleaning and Initial Feature Engineering",
"_____no_output_____"
],
[
"### I. Transform feature `int_rate` and `revol_util` in test set",
"_____no_output_____"
]
],
[
[
"# Check the difference values for int_rate, revol_util\nprint('Item\\t', 'int_rate', '\\t', 'revol_util')\nprint('-' * 40)\nprint('Train:\\t', train['int_rate'][0], '\\t\\t', train['revol_util'][0])\nprint('Test:\\t', test['int_rate'][0], '\\t', test['revol_util'][0])",
"Item\t int_rate \t revol_util\n----------------------------------------\nTrain:\t 10.65 \t\t 83.7\nTest:\t 18.99% \t 70.50%\n"
],
[
"# Using lambda function\ntest['int_rate'] = test['int_rate'].apply(lambda x: float(x[:-1]))\n\nindex = test[~test['revol_util'].isnull()].index\ntest.loc[index, 'revol_util'] = test.loc[index, 'revol_util'].apply(lambda x: float(x[:-1]))\ntest['revol_util'] = test['revol_util'].astype(float)",
"_____no_output_____"
]
],
[
[
"### II. Transform target values `loan_status`",
"_____no_output_____"
]
],
[
[
"# Check the target values\nprint('Train:\\n', list(train['loan_status'].unique()))\nprint('\\nTest:\\n', list(test['loan_status'].unique()))",
"Train:\n ['Fully Paid', 'Charged Off', 'Current', 'Default', 'Late (31-120 days)', 'In Grace Period', 'Late (16-30 days)', 'Does not meet the credit policy. Status:Fully Paid', 'Does not meet the credit policy. Status:Charged Off', 'Issued']\n\nTest:\n ['Current', 'Charged Off', 'Fully Paid', 'Late (31-120 days)', 'In Grace Period', 'Late (16-30 days)', 'Default']\n"
],
[
"# Let's only keep the data that is not in process currentlly, for more details, refer to \n# https://help.lendingclub.com/hc/en-us/articles/215488038-What-do-the-different-Note-statuses-mean-\ndrop_status = ['Issued']\ntrain = train[~train['loan_status'].isin(drop_status)]\ntest = test[~test['loan_status'].isin(drop_status)]",
"_____no_output_____"
],
[
"# Treat this as a binary classification problem\nmaps = {'Current': 0, 'Fully Paid': 0, 'Charged Off': 1, 'Default': 1, \n 'Does not meet the credit policy. Status:Fully Paid': 0, \n 'Does not meet the credit policy. Status:Charged Off': 1, \n 'In Grace Period': 0, 'Late (16-30 days)': 1, 'Late (31-120 days)': 1}\ntrain['loan_status'] = train['loan_status'].apply(lambda x: maps[x])\ntest['loan_status'] = test['loan_status'].apply(lambda x: maps[x])",
"_____no_output_____"
],
[
"# Check the imbalance\ntrain_default_ratio = np.round(len(train[train['loan_status'] == 1]) / len(train), 4)\ntrain_nondefault_ratio = np.round(len(train[train['loan_status'] == 0]) / len(train), 4)\ntest_default_ratio = np.round(len(test[test['loan_status'] == 1]) / len(test), 4)\ntest_nondefault_ratio = np.round(len(test[test['loan_status'] == 0]) / len(test), 4)\nprint('Item\\t', 'Default', '\\t', 'Not Default')\nprint('-' * 40)\nprint('Train:\\t', train_default_ratio, '\\t', train_nondefault_ratio)\nprint('Test:\\t', test_default_ratio, '\\t', test_nondefault_ratio)",
"Item\t Default \t Not Default\n----------------------------------------\nTrain:\t 0.0696 \t 0.9304\nTest:\t 0.0363 \t 0.9637\n"
]
],
[
[
"It's clear that our dataset is highly imbalanced.",
"_____no_output_____"
]
],
[
[
"# Create a concise table for the data\ntrain_dtype = train.dtypes.values\ntrain_missing = train.isnull().sum().values\ntrain_missing_ratio = train_missing / len(train)\n\ntest_dtype = test.dtypes.values\ntest_missing = test.isnull().sum().values\ntest_missing_ratio = test_missing / len(test)\n\n# Calculate unique values\ntrain_unique = []\ntest_unique = []\nfor name in train.columns:\n train_unique.append(train[name].unique().shape[0])\n test_unique.append(test[name].unique().shape[0])\n\n# Useful information\ndf = pd.DataFrame({'Columns': train.columns, 'Train dtype': train_dtype, 'Train missing': train_missing, \n 'Train missing ratio': train_missing_ratio, 'Train unique': train_unique, \n 'Test dtype': test_dtype, 'Test missing': test_missing, \n 'Test missing ratio': test_missing_ratio, 'Test unique': test_unique}, \n columns=['Columns', 'Train dtype', 'Train missing', 'Train missing ratio', 'Train unique',\n 'Test dtype', 'Test missing', 'Test missing ratio', 'Test unique'])\n\ndf",
"_____no_output_____"
]
],
[
[
"### III. Drop useless features",
"_____no_output_____"
]
],
[
[
"# Drop the features that has too many missing values\nuseless = ['id', 'member_id', 'url', 'open_acc_6m', 'open_il_6m', 'open_il_12m', 'open_il_24m', \n 'mths_since_rcnt_il', 'total_bal_il', 'il_util', 'open_rv_12m', 'open_rv_24m',\n 'max_bal_bc', 'all_util', 'inq_fi', 'total_cu_tl', 'inq_last_12m', 'desc', \n 'mths_since_last_delinq', 'mths_since_last_record', 'mths_since_last_major_derog', \n 'annual_inc_joint', 'dti_joint', 'verification_status_joint']\ntrain = train.drop(labels=useless, axis=1)\ntest = test.drop(labels=useless, axis=1)",
"_____no_output_____"
],
[
"# Drop meaningless features based on understanding\nmeaningless = ['emp_title', 'issue_d', 'last_pymnt_d', 'next_pymnt_d', 'zip_code', 'title', \n 'grade', 'earliest_cr_line', 'last_credit_pull_d', 'policy_code']\ntrain = train.drop(labels=meaningless, axis=1)\ntest = test.drop(labels=meaningless, axis=1)",
"_____no_output_____"
],
[
"_ = gc.collect()\nprint(train.shape, test.shape)",
"(878919, 40) (434407, 40)\n"
]
],
[
[
"Now, we have successfully reduce the features from 74 to 40. Next, let's focus on more detailed feature engineering",
"_____no_output_____"
],
[
"First, let's look at the data again. From the below table, we can see that:\n* Most features are numerical, but there are severl categorical features.\n* There are still some missing values among numerical and categorical features.",
"_____no_output_____"
]
],
[
[
"# Create a concise table for the data\ntrain_dtype = train.dtypes.values\ntrain_missing = train.isnull().sum().values\ntrain_missing_ratio = train_missing / len(train)\n\ntest_dtype = test.dtypes.values\ntest_missing = test.isnull().sum().values\ntest_missing_ratio = test_missing / len(test)\n\n# Calculate unique values\ntrain_unique = []\ntest_unique = []\nfor name in train.columns:\n train_unique.append(train[name].unique().shape[0])\n test_unique.append(test[name].unique().shape[0])\n\n# Useful information\ndf = pd.DataFrame({'Columns': train.columns, 'Train dtype': train_dtype, 'Train missing': train_missing, \n 'Train missing ratio': train_missing_ratio, 'Train unique': train_unique, \n 'Test dtype': test_dtype, 'Test missing': test_missing, \n 'Test missing ratio': test_missing_ratio, 'Test unique': test_unique}, \n columns=['Columns', 'Train dtype', 'Train missing', 'Train missing ratio', 'Train unique',\n 'Test dtype', 'Test missing', 'Test missing ratio', 'Test unique'])\n\ndf",
"_____no_output_____"
]
],
[
[
"### IV. Feature transformation",
"_____no_output_____"
],
[
"Transform numerical values into categorical values",
"_____no_output_____"
]
],
[
[
"transform_featurs = ['total_rec_late_fee', 'recoveries', 'collection_recovery_fee', 'tot_coll_amt', \n 'collections_12_mths_ex_med', 'acc_now_delinq', 'out_prncp', 'out_prncp_inv']\nfor name in transform_featurs:\n train[name] = (train[name] > 0).astype(str)\n test[name] = (test[name] > 0).astype(str)",
"_____no_output_____"
]
],
[
[
"Transform categorical values into numerical values (discrete)",
"_____no_output_____"
]
],
[
[
"# Transform sub_grade\nsub_grade_encoder = LabelEncoder()\nsub_grade_encoder.fit(train['sub_grade'])\ntrain['sub_grade'] = sub_grade_encoder.transform(train['sub_grade'])\ntest['sub_grade'] = sub_grade_encoder.transform(test['sub_grade'])",
"_____no_output_____"
],
[
"# Transform emp_length (first fill NA value with mode)\nmode = train['emp_length'].mode().values[0]\ntrain['emp_length'] = train['emp_length'].fillna(value=mode)\ntest['emp_length'] = test['emp_length'].fillna(value=mode)\n\n# Manually do encoding due to sort problems\nemp_map = {'< 1 year': 0, '1 year': 1, '3 years': 2, '4 years': 3, '5 years': 4, '6 years': 5, \n '2 years': 6, '7 years': 7, '8 years': 8, '9 years': 9, '10+ years': 10}\ntrain['emp_length'] = train['emp_length'].apply(lambda x: emp_map[x])\ntest['emp_length'] = test['emp_length'].apply(lambda x: emp_map[x])",
"_____no_output_____"
]
],
[
[
"### V. Fill missing values\n* For numerical features, use `median`\n* For categorical features, use `mode` (here, we don't have missing categorical values)",
"_____no_output_____"
]
],
[
[
"# Seperate numerical and categorical features (16 categorical features, 23 numerical features)\nnumerical_feature = train.select_dtypes(exclude=['object']).columns.drop('loan_status')\ncategorical_feature = train.select_dtypes(include=['object']).columns\n\nprint('Numerical:\\t', len(numerical_feature))\nprint('Categorical:\\t', len(categorical_feature))",
"Numerical:\t 23\nCategorical:\t 16\n"
],
[
"# Fill numerical features with median\nmedians = train[numerical_feature].median(axis=0, skipna=True)\ntrain[numerical_feature] = train[numerical_feature].fillna(value=medians)\ntest[numerical_feature] = test[numerical_feature].fillna(value=medians)",
"_____no_output_____"
]
],
[
[
"# 4. Visualization ",
"_____no_output_____"
],
[
"### I. Visualize categorical features",
"_____no_output_____"
]
],
[
[
"# For better visualization purpose, we set the y to be log scale\nfig, ax = plt.subplots(nrows=6, ncols=3, figsize=(18, 30))\nplt.tight_layout(h_pad=3)\nfor i in range(len(categorical_feature)):\n name = categorical_feature[i]\n sns.countplot(x=name, hue='loan_status', data=train, ax=ax[i//3][i%3])\n ax[i//3][i%3].set_yscale('log')\nplt.show()\n_ = gc.collect()",
"_____no_output_____"
]
],
[
[
"### II. Visualize numerical features",
"_____no_output_____"
]
],
[
[
"# Histogram of numerical values\nfig, ax = plt.subplots(nrows=8, ncols=3, figsize=(18, 42))\nplt.tight_layout(h_pad=3)\nhist_kws={'histtype': 'bar', 'edgecolor':'black', 'alpha': 0.2}\nfor i in range(len(numerical_feature)):\n name = numerical_feature[i]\n sns.distplot(train[train['loan_status'] == 0][name], label='Not Default',\n hist_kws=hist_kws, ax=ax[i//3][i%3])\n sns.distplot(train[train['loan_status'] == 1][name], label='Default',\n hist_kws=hist_kws, ax=ax[i//3][i%3])\n ax[i//3][i%3].legend()\nplt.show()\n_ = gc.collect()",
"_____no_output_____"
],
[
"# Heatmap of the correlation\ncorr = train[numerical_feature].corr()\nfig, ax = plt.subplots(figsize=(12, 10))\nsns.heatmap(corr, ax=ax)\nplt.axis('image')\nplt.show()",
"_____no_output_____"
]
],
[
[
"# 5. Further Feature Engineering",
"_____no_output_____"
],
[
"From the above heatmap and the categorical variable countplot, we can see that some feature has strong correlation\n* `loan_amnt`, `funded_amnt`, `funded_amnt_inv`, `installment`\n* `int_rate`, `sub_grade`\n* `total_pymnt`, `total_pymnt_inv`, `total_rec_prncp`\n* `out_prncp`, `out_prncp_inv`\n* `recoveries`, `collection_recovery_fee`\n\nWe can drop some of them to reduce redundancy",
"_____no_output_____"
]
],
[
[
"# Drop redundant features\nuseless = ['funded_amnt', 'funded_amnt_inv', 'installment', 'sub_grade', 'total_pymnt_inv', \n 'total_rec_prncp', 'out_prncp_inv', 'collection_recovery_fee']\ntrain = train.drop(useless, axis=1)\ntest = test.drop(useless, axis=1)",
"_____no_output_____"
],
[
"# Seperate numerical and categorical features (14 categorical features, 17 numerical features)\nnumerical_feature = train.select_dtypes(exclude=['object']).columns.drop('loan_status')\ncategorical_feature = train.select_dtypes(include=['object']).columns\n\nprint('Numerical:\\t', len(numerical_feature))\nprint('Categorical:\\t', len(categorical_feature))",
"Numerical:\t 17\nCategorical:\t 14\n"
]
],
[
[
"Now, we only 14 categorical features, 17 numerical features. Let's check the correlation again.",
"_____no_output_____"
]
],
[
[
"print('Numerical features:', '\\n', list(numerical_feature), '\\n')\nprint('Categorical Features:', '\\n', list(categorical_feature))",
"Numerical features: \n ['loan_amnt', 'int_rate', 'emp_length', 'annual_inc', 'dti', 'delinq_2yrs', 'inq_last_6mths', 'open_acc', 'pub_rec', 'revol_bal', 'revol_util', 'total_acc', 'total_pymnt', 'total_rec_int', 'last_pymnt_amnt', 'tot_cur_bal', 'total_rev_hi_lim'] \n\nCategorical Features: \n ['term', 'home_ownership', 'verification_status', 'pymnt_plan', 'purpose', 'addr_state', 'initial_list_status', 'out_prncp', 'total_rec_late_fee', 'recoveries', 'collections_12_mths_ex_med', 'application_type', 'acc_now_delinq', 'tot_coll_amt']\n"
],
[
"# Check the heatmap again\ncorr = train[numerical_feature].corr()\nfig, ax = plt.subplots(figsize=(12, 10))\nsns.heatmap(corr, ax=ax)\nplt.axis('image')\nplt.show()",
"_____no_output_____"
]
],
[
[
"# 6. Machine Learning",
"_____no_output_____"
],
[
"After the above procedures, we are ready to build the predictive models. In this part, I explored the application of Random Forest.\n\nI used to use scikit-learn a lot. But there is one problem with scikit-learn: you need to do one-hot encoding manually, which can sometimes dramatically increase the feature space. In this part, for logistic regression and random forest, I use H2O package, which has a better support with categorical features. For deep learning model, I use Keras with TensorFlow backend. \n\nFor imbalanced data, generally used methods include `Oversampling`, `Undersampling`, `SMOTE` (Synthetic Minority Oversampling Technique). For a lot of ensemble algorithms, for example, random forest, you only need to set the `balance_class` to be `True`",
"_____no_output_____"
]
],
[
[
"# Define x and y variables\ntrain = shuffle(train, random_state=42)\nx = list(train.columns.drop('loan_status'))\ny = 'loan_status'\n\ntrain_y = train['loan_status'].values\ntest_y = test['loan_status'].values",
"_____no_output_____"
],
[
"# Initialize H2O cluster\nh2o.init(nthreads=-1, max_mem_size=32)\nh2o.remove_all()\n\n# Transform to H2O Frame, and make sure the target variable is categorical\nh2o_train = H2OFrame(train)\nh2o_test = H2OFrame(test)\n\nh2o_train['loan_status'] = h2o_train['loan_status'].asfactor()\nh2o_test['loan_status'] = h2o_test['loan_status'].asfactor()",
"Checking whether there is an H2O instance running at http://localhost:54321..... not found.\nAttempting to start a local H2O server...\n Java Version: openjdk version \"1.8.0_121\"; OpenJDK Runtime Environment (Zulu 8.20.0.5-linux64) (build 1.8.0_121-b15); OpenJDK 64-Bit Server VM (Zulu 8.20.0.5-linux64) (build 25.121-b15, mixed mode)\n Starting server from /home/ubuntu/anaconda3/envs/tensorflow_p36/lib/python3.6/site-packages/h2o/backend/bin/h2o.jar\n Ice root: /tmp/tmpxf1pii50\n JVM stdout: /tmp/tmpxf1pii50/h2o_ubuntu_started_from_python.out\n JVM stderr: /tmp/tmpxf1pii50/h2o_ubuntu_started_from_python.err\n Server is running at http://127.0.0.1:54321\nConnecting to H2O server at http://127.0.0.1:54321... successful.\n"
]
],
[
[
"### Random Forest",
"_____no_output_____"
]
],
[
[
"# # Train random forest model using grid search\n# hyper_parameters = {'max_depth': [15, 20], \n# 'min_rows': [3, 5, 7]}\n\n# # Build random forest model\n# rf = H2ORandomForestEstimator(balance_classes=True, ntrees=200, stopping_rounds=5, nfolds=5, \n# stopping_metric='auc', keep_cross_validation_predictions=True)\n\n# # Grid search\n# rf_grid = H2OGridSearch(rf, hyper_parameters, grid_id='DRF')\n# rf_grid.train(x=x, y=y, training_frame=h2o_train)",
"_____no_output_____"
],
[
"# # Get the grid search result, sorted by AUC\n# rf_models = rf_grid.get_grid(sort_by='auc', decreasing=True)\n\n# # Choose the best model\n# best_rf = rf_grid.models[0]\n\n# rf_models",
"_____no_output_____"
],
[
"# Build Random Forest model\nrf_model = H2ORandomForestEstimator(balance_classes=True, ntrees=200, max_depth=20, min_rows=3, seed=42)\nrf_model.train(x=x, y=y, training_frame=h2o_train)",
"drf Model Build progress: |███████████████████████████████████████████████| 100%\n"
],
[
"# Make prediction\nrf_train_pred = rf_model.predict(h2o_train).as_data_frame()['p1'].values\nrf_test_pred = rf_model.predict(h2o_test).as_data_frame()['p1'].values",
"drf prediction progress: |████████████████████████████████████████████████| 100%\ndrf prediction progress: |████████████████████████████████████████████████| 100%\n"
],
[
"# Build the ROC curve\nrf_fpr, rf_tpr, _ = roc_curve(test_y, rf_test_pred)\nrf_auc = np.round(auc(rf_fpr, rf_tpr), 3)\n\nfig, ax = plt.subplots(figsize=(8, 6))\nax.plot(rf_fpr, rf_tpr, label='AUC: ' + str(rf_auc))\nax.set_xlabel('False Positive Rate', fontsize=12)\nax.set_ylabel('True Positive Rate', fontsize=12)\nax.legend(fontsize=12)\nax.grid(True)\nplt.show()",
"_____no_output_____"
],
[
"# Feature importance\nrf_model.varimp_plot(num_of_features=20)\nplt.show()",
"_____no_output_____"
]
],
[
[
"| Attribute | Explanation |\n| ------------------------ | ----------------------------------------------------------------- |\n| out_prncp\t | Remaining outstanding principal for total amount funded |\n| recoveries\t | post charge off gross recovery |\n| last_pymnt_amnt\t | Last total payment amount received |\n| int_rate\t | Interest Rate on the loan |\n| total_pymnt\t | Payments received to date for total amount funded |\n| addr_state\t | The state provided by the borrower in the loan application |\n| loan_amnt\t | The listed amount of the loan applied for by the borrower. If at some point in time, the credit department reduces the loan amount, then it will be reflected in this value. |\n| total_rec_late_fee\t | Late fees received to date |\n| total_rec_int\t | Interest received to date |",
"_____no_output_____"
]
],
[
[
"# Shutdown h2o instance\nh2o.cluster().shutdown()",
"H2O session _sid_b98d closed.\n"
]
],
[
[
"I have also explored logistic regression and deep learning models for the same problem, please refer to https://github.com/JifuZhao/Lending_Club_Loan/blob/master/Lending%20Club%20Modeling%20(AWS).ipynb for details",
"_____no_output_____"
],
[
"# 7. Conclusions",
"_____no_output_____"
],
[
"I have explored three algorithms: Logistic Regression, Random Forest, and Neural Networks. Their performance on the test set is pretty similar. Based on our simple analysis and grid search, Random Forest gives the best result. \n\nThere are a lot of other methods, such as AdaBoost and XGBoost, and we can tune a lot of parameters for different models, especially for Neural Networks. Here, I didn't explore all possible algorithms and conduct comprehensive parameter tuning.",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
]
] |
ecaa3cd51f366389595c1d0eaa9513cbeb5f93b1 | 196,674 | ipynb | Jupyter Notebook | p1_charityml/finding_donors.ipynb | Amr411996/Finding-donors | 5f504592a6768482092b0599aef601019d40e896 | [
"MIT"
] | null | null | null | p1_charityml/finding_donors.ipynb | Amr411996/Finding-donors | 5f504592a6768482092b0599aef601019d40e896 | [
"MIT"
] | null | null | null | p1_charityml/finding_donors.ipynb | Amr411996/Finding-donors | 5f504592a6768482092b0599aef601019d40e896 | [
"MIT"
] | null | null | null | 139.090523 | 57,524 | 0.839842 | [
[
[
"# Data Scientist Nanodegree\n## Supervised Learning\n## Project: Finding Donors for *CharityML*",
"_____no_output_____"
],
[
"Welcome to the first project of the Data Scientist Nanodegree! In this notebook, some template code has already been provided for you, and it will be your job to implement the additional functionality necessary to successfully complete this project. Sections that begin with **'Implementation'** in the header indicate that the following block of code will require additional functionality which you must provide. Instructions will be provided for each section and the specifics of the implementation are marked in the code block with a `'TODO'` statement. Please be sure to read the instructions carefully!\n\nIn addition to implementing code, there will be questions that you must answer which relate to the project and your implementation. Each section where you will answer a question is preceded by a **'Question X'** header. Carefully read each question and provide thorough answers in the following text boxes that begin with **'Answer:'**. Your project submission will be evaluated based on your answers to each of the questions and the implementation you provide. \n\n>**Note:** Please specify WHICH VERSION OF PYTHON you are using when submitting this notebook. Code and Markdown cells can be executed using the **Shift + Enter** keyboard shortcut. In addition, Markdown cells can be edited by typically double-clicking the cell to enter edit mode.",
"_____no_output_____"
],
[
"## Getting Started\n\nIn this project, you will employ several supervised algorithms of your choice to accurately model individuals' income using data collected from the 1994 U.S. Census. You will then choose the best candidate algorithm from preliminary results and further optimize this algorithm to best model the data. Your goal with this implementation is to construct a model that accurately predicts whether an individual makes more than $50,000. This sort of task can arise in a non-profit setting, where organizations survive on donations. Understanding an individual's income can help a non-profit better understand how large of a donation to request, or whether or not they should reach out to begin with. While it can be difficult to determine an individual's general income bracket directly from public sources, we can (as we will see) infer this value from other publically available features. \n\nThe dataset for this project originates from the [UCI Machine Learning Repository](https://archive.ics.uci.edu/ml/datasets/Census+Income). The datset was donated by Ron Kohavi and Barry Becker, after being published in the article _\"Scaling Up the Accuracy of Naive-Bayes Classifiers: A Decision-Tree Hybrid\"_. You can find the article by Ron Kohavi [online](https://www.aaai.org/Papers/KDD/1996/KDD96-033.pdf). The data we investigate here consists of small changes to the original dataset, such as removing the `'fnlwgt'` feature and records with missing or ill-formatted entries.",
"_____no_output_____"
],
[
"----\n## Exploring the Data\nRun the code cell below to load necessary Python libraries and load the census data. Note that the last column from this dataset, `'income'`, will be our target label (whether an individual makes more than, or at most, $50,000 annually). All other columns are features about each individual in the census database.",
"_____no_output_____"
]
],
[
[
"# Import libraries necessary for this project\nimport numpy as np\nimport pandas as pd\nfrom time import time\nfrom IPython.display import display # Allows the use of display() for DataFrames\n\n# Import supplementary visualization code visuals.py\nimport visuals as vs\n\n# Pretty display for notebooks\n%matplotlib inline\n\n# Load the Census dataset\ndata = pd.read_csv(\"census.csv\")\n\n# Success - Display the first record\ndisplay(data.head(n=1))",
"_____no_output_____"
]
],
[
[
"### Implementation: Data Exploration\nA cursory investigation of the dataset will determine how many individuals fit into either group, and will tell us about the percentage of these individuals making more than \\$50,000. In the code cell below, you will need to compute the following:\n- The total number of records, `'n_records'`\n- The number of individuals making more than \\$50,000 annually, `'n_greater_50k'`.\n- The number of individuals making at most \\$50,000 annually, `'n_at_most_50k'`.\n- The percentage of individuals making more than \\$50,000 annually, `'greater_percent'`.\n\n** HINT: ** You may need to look at the table above to understand how the `'income'` entries are formatted. ",
"_____no_output_____"
]
],
[
[
"# TODO: Total number of records\nn_records = data[\"income\"].size\n\n# TODO: Number of records where individual's income is more than $50,000\nn_greater_50k = data[\"income\"].where(data[\"income\"]==\">50K\").dropna().size\n\n# TODO: Number of records where individual's income is at most $50,000\nn_at_most_50k = data[\"income\"].where(data[\"income\"]==\"<=50K\").dropna().size\n\n# TODO: Percentage of individuals whose income is more than $50,000\ngreater_percent = n_greater_50k*100/n_records\n\n# Print the results\nprint(\"Total number of records: {}\".format(n_records))\nprint(\"Individuals making more than $50,000: {}\".format(n_greater_50k))\nprint(\"Individuals making at most $50,000: {}\".format(n_at_most_50k))\nprint(\"Percentage of individuals making more than $50,000: {}%\".format(greater_percent))",
"Total number of records: 45222\nIndividuals making more than $50,000: 11208\nIndividuals making at most $50,000: 34014\nPercentage of individuals making more than $50,000: 24.78439697492371%\n"
]
],
[
[
"** Featureset Exploration **\n\n* **age**: continuous. \n* **workclass**: Private, Self-emp-not-inc, Self-emp-inc, Federal-gov, Local-gov, State-gov, Without-pay, Never-worked. \n* **education**: Bachelors, Some-college, 11th, HS-grad, Prof-school, Assoc-acdm, Assoc-voc, 9th, 7th-8th, 12th, Masters, 1st-4th, 10th, Doctorate, 5th-6th, Preschool. \n* **education-num**: continuous. \n* **marital-status**: Married-civ-spouse, Divorced, Never-married, Separated, Widowed, Married-spouse-absent, Married-AF-spouse. \n* **occupation**: Tech-support, Craft-repair, Other-service, Sales, Exec-managerial, Prof-specialty, Handlers-cleaners, Machine-op-inspct, Adm-clerical, Farming-fishing, Transport-moving, Priv-house-serv, Protective-serv, Armed-Forces. \n* **relationship**: Wife, Own-child, Husband, Not-in-family, Other-relative, Unmarried. \n* **race**: Black, White, Asian-Pac-Islander, Amer-Indian-Eskimo, Other. \n* **sex**: Female, Male. \n* **capital-gain**: continuous. \n* **capital-loss**: continuous. \n* **hours-per-week**: continuous. \n* **native-country**: United-States, Cambodia, England, Puerto-Rico, Canada, Germany, Outlying-US(Guam-USVI-etc), India, Japan, Greece, South, China, Cuba, Iran, Honduras, Philippines, Italy, Poland, Jamaica, Vietnam, Mexico, Portugal, Ireland, France, Dominican-Republic, Laos, Ecuador, Taiwan, Haiti, Columbia, Hungary, Guatemala, Nicaragua, Scotland, Thailand, Yugoslavia, El-Salvador, Trinadad&Tobago, Peru, Hong, Holand-Netherlands.",
"_____no_output_____"
],
[
"----\n## Preparing the Data\nBefore data can be used as input for machine learning algorithms, it often must be cleaned, formatted, and restructured — this is typically known as **preprocessing**. Fortunately, for this dataset, there are no invalid or missing entries we must deal with, however, there are some qualities about certain features that must be adjusted. This preprocessing can help tremendously with the outcome and predictive power of nearly all learning algorithms.",
"_____no_output_____"
],
[
"### Transforming Skewed Continuous Features\nA dataset may sometimes contain at least one feature whose values tend to lie near a single number, but will also have a non-trivial number of vastly larger or smaller values than that single number. Algorithms can be sensitive to such distributions of values and can underperform if the range is not properly normalized. With the census dataset two features fit this description: '`capital-gain'` and `'capital-loss'`. \n\nRun the code cell below to plot a histogram of these two features. Note the range of the values present and how they are distributed.",
"_____no_output_____"
]
],
[
[
"# Split the data into features and target label\nincome_raw = data['income']\nfeatures_raw = data.drop('income', axis = 1)\n\n# Visualize skewed continuous features of original data\nvs.distribution(data)",
"_____no_output_____"
]
],
[
[
"For highly-skewed feature distributions such as `'capital-gain'` and `'capital-loss'`, it is common practice to apply a <a href=\"https://en.wikipedia.org/wiki/Data_transformation_(statistics)\">logarithmic transformation</a> on the data so that the very large and very small values do not negatively affect the performance of a learning algorithm. Using a logarithmic transformation significantly reduces the range of values caused by outliers. Care must be taken when applying this transformation however: The logarithm of `0` is undefined, so we must translate the values by a small amount above `0` to apply the the logarithm successfully.\n\nRun the code cell below to perform a transformation on the data and visualize the results. Again, note the range of values and how they are distributed. ",
"_____no_output_____"
]
],
[
[
"# Log-transform the skewed features\nskewed = ['capital-gain', 'capital-loss']\nfeatures_log_transformed = pd.DataFrame(data = features_raw)\nfeatures_log_transformed[skewed] = features_raw[skewed].apply(lambda x: np.log(x + 1))\n\n# Visualize the new log distributions\nvs.distribution(features_log_transformed, transformed = True)",
"_____no_output_____"
]
],
[
[
"### Normalizing Numerical Features\nIn addition to performing transformations on features that are highly skewed, it is often good practice to perform some type of scaling on numerical features. Applying a scaling to the data does not change the shape of each feature's distribution (such as `'capital-gain'` or `'capital-loss'` above); however, normalization ensures that each feature is treated equally when applying supervised learners. Note that once scaling is applied, observing the data in its raw form will no longer have the same original meaning, as exampled below.\n\nRun the code cell below to normalize each numerical feature. We will use [`sklearn.preprocessing.MinMaxScaler`](http://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.MinMaxScaler.html) for this.",
"_____no_output_____"
]
],
[
[
"# Import sklearn.preprocessing.StandardScaler\nfrom sklearn.preprocessing import MinMaxScaler\n\n# Initialize a scaler, then apply it to the features\nscaler = MinMaxScaler() # default=(0, 1)\nnumerical = ['age', 'education-num', 'capital-gain', 'capital-loss', 'hours-per-week']\n\nfeatures_log_minmax_transform = pd.DataFrame(data = features_log_transformed)\nfeatures_log_minmax_transform[numerical] = scaler.fit_transform(features_log_transformed[numerical])\n\n# Show an example of a record with scaling applied\ndisplay(features_log_minmax_transform.head(n = 5))",
"C:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\preprocessing\\data.py:323: DataConversionWarning: Data with input dtype int64, float64 were all converted to float64 by MinMaxScaler.\n return self.partial_fit(X, y)\n"
]
],
[
[
"### Implementation: Data Preprocessing\n\nFrom the table in **Exploring the Data** above, we can see there are several features for each record that are non-numeric. Typically, learning algorithms expect input to be numeric, which requires that non-numeric features (called *categorical variables*) be converted. One popular way to convert categorical variables is by using the **one-hot encoding** scheme. One-hot encoding creates a _\"dummy\"_ variable for each possible category of each non-numeric feature. For example, assume `someFeature` has three possible entries: `A`, `B`, or `C`. We then encode this feature into `someFeature_A`, `someFeature_B` and `someFeature_C`.\n\n| | someFeature | | someFeature_A | someFeature_B | someFeature_C |\n| :-: | :-: | | :-: | :-: | :-: |\n| 0 | B | | 0 | 1 | 0 |\n| 1 | C | ----> one-hot encode ----> | 0 | 0 | 1 |\n| 2 | A | | 1 | 0 | 0 |\n\nAdditionally, as with the non-numeric features, we need to convert the non-numeric target label, `'income'` to numerical values for the learning algorithm to work. Since there are only two possible categories for this label (\"<=50K\" and \">50K\"), we can avoid using one-hot encoding and simply encode these two categories as `0` and `1`, respectively. In code cell below, you will need to implement the following:\n - Use [`pandas.get_dummies()`](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.get_dummies.html?highlight=get_dummies#pandas.get_dummies) to perform one-hot encoding on the `'features_log_minmax_transform'` data.\n - Convert the target label `'income_raw'` to numerical entries.\n - Set records with \"<=50K\" to `0` and records with \">50K\" to `1`.",
"_____no_output_____"
]
],
[
[
"# TODO: One-hot encode the 'features_log_minmax_transform' data using pandas.get_dummies()\nfeatures_final = pd.get_dummies(features_log_minmax_transform)\n\n# TODO: Encode the 'income_raw' data to numerical values\nincome = np.zeros((data[\"income\"].size))\ni=0\nfor item in income_raw:\n if item == \">50K\":\n income[i]=1\n i=i+1\n else:\n income[i]=0\n i=i+1\n\n# Print the number of features after one-hot encoding\nencoded = list(features_final.columns)\n#print(income)\nprint(\"{} total features after one-hot encoding.\".format(len(encoded)))\n\n# Uncomment the following line to see the encoded feature names\n# print encoded",
"103 total features after one-hot encoding.\n"
]
],
[
[
"### Shuffle and Split Data\nNow all _categorical variables_ have been converted into numerical features, and all numerical features have been normalized. As always, we will now split the data (both features and their labels) into training and test sets. 80% of the data will be used for training and 20% for testing.\n\nRun the code cell below to perform this split.",
"_____no_output_____"
]
],
[
[
"# Import train_test_split\nfrom sklearn.model_selection import train_test_split\n#ytrain has error\n# Split the 'features' and 'income' data into training and testing sets\nX_train, X_test, y_train, y_test = train_test_split(features_final, \n income, \n test_size = 0.2, \n random_state = 0)\nprint(y_train)\n\n# Show the results of the split\nprint(\"Training set has {} samples.\".format(X_train.shape[0]))\nprint(\"Testing set has {} samples.\".format(X_test.shape[0]))",
"[0. 0. 0. ... 1. 0. 0.]\nTraining set has 36177 samples.\nTesting set has 9045 samples.\n"
]
],
[
[
"----\n## Evaluating Model Performance\nIn this section, we will investigate four different algorithms, and determine which is best at modeling the data. Three of these algorithms will be supervised learners of your choice, and the fourth algorithm is known as a *naive predictor*.",
"_____no_output_____"
],
[
"### Metrics and the Naive Predictor\n*CharityML*, equipped with their research, knows individuals that make more than \\$50,000 are most likely to donate to their charity. Because of this, *CharityML* is particularly interested in predicting who makes more than \\$50,000 accurately. It would seem that using **accuracy** as a metric for evaluating a particular model's performace would be appropriate. Additionally, identifying someone that *does not* make more than \\$50,000 as someone who does would be detrimental to *CharityML*, since they are looking to find individuals willing to donate. Therefore, a model's ability to precisely predict those that make more than \\$50,000 is *more important* than the model's ability to **recall** those individuals. We can use **F-beta score** as a metric that considers both precision and recall:\n\n$$ F_{\\beta} = (1 + \\beta^2) \\cdot \\frac{precision \\cdot recall}{\\left( \\beta^2 \\cdot precision \\right) + recall} $$\n\nIn particular, when $\\beta = 0.5$, more emphasis is placed on precision. This is called the **F$_{0.5}$ score** (or F-score for simplicity).\n\nLooking at the distribution of classes (those who make at most \\$50,000, and those who make more), it's clear most individuals do not make more than \\$50,000. This can greatly affect **accuracy**, since we could simply say *\"this person does not make more than \\$50,000\"* and generally be right, without ever looking at the data! Making such a statement would be called **naive**, since we have not considered any information to substantiate the claim. It is always important to consider the *naive prediction* for your data, to help establish a benchmark for whether a model is performing well. That been said, using that prediction would be pointless: If we predicted all people made less than \\$50,000, *CharityML* would identify no one as donors. \n\n\n#### Note: Recap of accuracy, precision, recall\n\n** Accuracy ** measures how often the classifier makes the correct prediction. It’s the ratio of the number of correct predictions to the total number of predictions (the number of test data points).\n\n** Precision ** tells us what proportion of messages we classified as spam, actually were spam.\nIt is a ratio of true positives(words classified as spam, and which are actually spam) to all positives(all words classified as spam, irrespective of whether that was the correct classificatio), in other words it is the ratio of\n\n`[True Positives/(True Positives + False Positives)]`\n\n** Recall(sensitivity)** tells us what proportion of messages that actually were spam were classified by us as spam.\nIt is a ratio of true positives(words classified as spam, and which are actually spam) to all the words that were actually spam, in other words it is the ratio of\n\n`[True Positives/(True Positives + False Negatives)]`\n\nFor classification problems that are skewed in their classification distributions like in our case, for example if we had a 100 text messages and only 2 were spam and the rest 98 weren't, accuracy by itself is not a very good metric. We could classify 90 messages as not spam(including the 2 that were spam but we classify them as not spam, hence they would be false negatives) and 10 as spam(all 10 false positives) and still get a reasonably good accuracy score. For such cases, precision and recall come in very handy. These two metrics can be combined to get the F1 score, which is weighted average(harmonic mean) of the precision and recall scores. This score can range from 0 to 1, with 1 being the best possible F1 score(we take the harmonic mean as we are dealing with ratios).",
"_____no_output_____"
],
[
"### Question 1 - Naive Predictor Performace\n* If we chose a model that always predicted an individual made more than $50,000, what would that model's accuracy and F-score be on this dataset? You must use the code cell below and assign your results to `'accuracy'` and `'fscore'` to be used later.\n\n** Please note ** that the the purpose of generating a naive predictor is simply to show what a base model without any intelligence would look like. In the real world, ideally your base model would be either the results of a previous model or could be based on a research paper upon which you are looking to improve. When there is no benchmark model set, getting a result better than random choice is a place you could start from.\n\n** HINT: ** \n\n* When we have a model that always predicts '1' (i.e. the individual makes more than 50k) then our model will have no True Negatives(TN) or False Negatives(FN) as we are not making any negative('0' value) predictions. Therefore our Accuracy in this case becomes the same as our Precision(True Positives/(True Positives + False Positives)) as every prediction that we have made with value '1' that should have '0' becomes a False Positive; therefore our denominator in this case is the total number of records we have in total. \n* Our Recall score(True Positives/(True Positives + False Negatives)) in this setting becomes 1 as we have no False Negatives.",
"_____no_output_____"
]
],
[
[
"'''\nTP = np.sum(income) # Counting the ones as this is the naive case. Note that 'income' is the 'income_raw' data \nencoded to numerical values done in the data preprocessing step.\nFP = income.count() - TP # Specific to the naive case\n\nTN = 0 # No predicted negatives in the naive case\nFN = 0 # No predicted negatives in the naive case\n'''\n# TODO: Calculate accuracy, precision and recall\naccuracy = np.sum(income)/(income_raw.size)\nrecall = 1\nprecision = np.sum(income)/(income_raw.size)\n\n# TODO: Calculate F-score using the formula above for beta = 0.5 and correct values for precision and recall.\nfscore = 1.25*precision*recall/(.25*precision+recall)\n\n# Print the results \nprint(\"Naive Predictor: [Accuracy score: {:.4f}, F-score: {:.4f}]\".format(accuracy, fscore))",
"Naive Predictor: [Accuracy score: 0.2478, F-score: 0.2917]\n"
]
],
[
[
"### Supervised Learning Models\n**The following are some of the supervised learning models that are currently available in** [`scikit-learn`](http://scikit-learn.org/stable/supervised_learning.html) **that you may choose from:**\n- Gaussian Naive Bayes (GaussianNB)\n- Decision Trees\n- Ensemble Methods (Bagging, AdaBoost, Random Forest, Gradient Boosting)\n- K-Nearest Neighbors (KNeighbors)\n- Stochastic Gradient Descent Classifier (SGDC)\n- Support Vector Machines (SVM)\n- Logistic Regression",
"_____no_output_____"
],
[
"### Question 2 - Model Application\nList three of the supervised learning models above that are appropriate for this problem that you will test on the census data. For each model chosen\n\n- Describe one real-world application in industry where the model can be applied. \n- What are the strengths of the model; when does it perform well?\n- What are the weaknesses of the model; when does it perform poorly?\n- What makes this model a good candidate for the problem, given what you know about the data?\n\n** HINT: **\n\nStructure your answer in the same format as above^, with 4 parts for each of the three models you pick. Please include references with your answer.",
"_____no_output_____"
],
[
"**Answer: **",
"_____no_output_____"
],
[
"### Implementation - Creating a Training and Predicting Pipeline\nTo properly evaluate the performance of each model you've chosen, it's important that you create a training and predicting pipeline that allows you to quickly and effectively train models using various sizes of training data and perform predictions on the testing data. Your implementation here will be used in the following section.\nIn the code block below, you will need to implement the following:\n - Import `fbeta_score` and `accuracy_score` from [`sklearn.metrics`](http://scikit-learn.org/stable/modules/classes.html#sklearn-metrics-metrics).\n - Fit the learner to the sampled training data and record the training time.\n - Perform predictions on the test data `X_test`, and also on the first 300 training points `X_train[:300]`.\n - Record the total prediction time.\n - Calculate the accuracy score for both the training subset and testing set.\n - Calculate the F-score for both the training subset and testing set.\n - Make sure that you set the `beta` parameter!",
"_____no_output_____"
]
],
[
[
"# TODO: Import two metrics from sklearn - fbeta_score and accuracy_score\nfrom sklearn.metrics import fbeta_score\nfrom sklearn.metrics import accuracy_score\nfrom sklearn.feature_extraction.text import CountVectorizer\n\ndef train_predict(learner, sample_size, X_train, y_train, X_test, y_test): \n '''\n inputs:\n - learner: the learning algorithm to be trained and predicted on\n - sample_size: the size of samples (number) to be drawn from training set\n - X_train: features training set\n - y_train: income training set\n - X_test: features testing set\n - y_test: income testing set\n '''\n \n results = {}\n \n # TODO: Fit the learner to the training data using slicing with 'sample_size' using .fit(training_features[:], training_labels[:])\n start = time() # Get start time\n learner = learner.fit(X_train,y_train)\n end = time() # Get end time\n \n # TODO: Calculate the training time\n results['train_time'] = start - end\n \n # TODO: Get the predictions on the test set(X_test),\n # then get predictions on the first 300 training samples(X_train) using .predict()\n start = time() # Get start time\n predictions_test = learner.predict(X_test)\n i=0\n for item in predictions_test:\n if item >0:\n predictions_test[i]=1\n i=i+1\n else:\n predictions_test[i]=0\n i=i+1\n predictions_train = learner.predict(X_train[:300])\n i=0\n for item in predictions_train:\n if item >0:\n predictions_train[i]=1\n i=i+1\n else:\n predictions_train[i]=0\n i=i+1\n #print(predictions_train)\n end = time() # Get end time\n \n # TODO: Calculate the total prediction time\n results['pred_time'] = start - end\n \n # TODO: Compute accuracy on the first 300 training samples which is y_train[:300]\n results['acc_train'] = accuracy_score(y_train[:300],predictions_train)\n \n # TODO: Compute accuracy on test set using accuracy_score()\n results['acc_test'] = accuracy_score(y_test,predictions_test)\n \n # TODO: Compute F-score on the the first 300 training samples using fbeta_score()\n results['f_train'] = fbeta_score(y_train[:300], predictions_train, beta=.5)\n \n # TODO: Compute F-score on the test set which is y_test\n results['f_test'] = fbeta_score(y_test, predictions_test, beta=.5)\n \n # Success\n print(\"{} trained on {} samples.\".format(learner.__class__.__name__, sample_size))\n \n # Return the results\n return results",
"_____no_output_____"
]
],
[
[
"### Implementation: Initial Model Evaluation\nIn the code cell, you will need to implement the following:\n- Import the three supervised learning models you've discussed in the previous section.\n- Initialize the three models and store them in `'clf_A'`, `'clf_B'`, and `'clf_C'`.\n - Use a `'random_state'` for each model you use, if provided.\n - **Note:** Use the default settings for each model — you will tune one specific model in a later section.\n- Calculate the number of records equal to 1%, 10%, and 100% of the training data.\n - Store those values in `'samples_1'`, `'samples_10'`, and `'samples_100'` respectively.\n\n**Note:** Depending on which algorithms you chose, the following implementation may take some time to run!",
"_____no_output_____"
]
],
[
[
"# TODO: Import the three supervised learning models from sklearn\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.tree import DecisionTreeClassifier\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.svm import SVC\nfrom sklearn.ensemble import BaggingClassifier, RandomForestClassifier, AdaBoostClassifier, GradientBoostingClassifier\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.linear_model import SGDClassifier\nfrom sklearn.neighbors import KNeighborsClassifier\n# TODO: Initialize the three models\nclf_A = LogisticRegression()\nclf_B = AdaBoostClassifier()\nclf_C = SGDClassifier()\n\n# TODO: Calculate the number of samples for 1%, 10%, and 100% of the training data\n# HINT: samples_100 is the entire training set i.e. len(y_train)\n# HINT: samples_10 is 10% of samples_100 (ensure to set the count of the values to be `int` and not `float`)\n# HINT: samples_1 is 1% of samples_100 (ensure to set the count of the values to be `int` and not `float`)\n\nsamples_100 = len(y_train)\nsamples_10 = len(y_train)//10\nsamples_1 = len(y_train)//100\n#print(samples_100,samples_10,samples_1)\n# Collect results on the learners\nresults = {}\nfor clf in [clf_A, clf_B, clf_C]:\n clf_name = clf.__class__.__name__\n results[clf_name] = {}\n for i, samples in enumerate([samples_1, samples_10, samples_100]):\n #print(i,samples)\n results[clf_name][i] = \\\n train_predict(clf, samples, X_train, y_train, X_test, y_test)\n\n# Run metrics visualization for the three supervised learning models chosen\nvs.evaluate(results, accuracy, fscore)",
"C:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\linear_model\\logistic.py:433: FutureWarning: Default solver will be changed to 'lbfgs' in 0.22. Specify a solver to silence this warning.\n FutureWarning)\n"
]
],
[
[
"----\n## Improving Results\nIn this final section, you will choose from the three supervised learning models the *best* model to use on the student data. You will then perform a grid search optimization for the model over the entire training set (`X_train` and `y_train`) by tuning at least one parameter to improve upon the untuned model's F-score. ",
"_____no_output_____"
],
[
"### Question 3 - Choosing the Best Model\n\n* Based on the evaluation you performed earlier, in one to two paragraphs, explain to *CharityML* which of the three models you believe to be most appropriate for the task of identifying individuals that make more than \\$50,000. \n\n** HINT: ** \nLook at the graph at the bottom left from the cell above(the visualization created by `vs.evaluate(results, accuracy, fscore)`) and check the F score for the testing set when 100% of the training set is used. Which model has the highest score? Your answer should include discussion of the:\n* metrics - F score on the testing when 100% of the training data is used, \n* prediction/training time\n* the algorithm's suitability for the data.",
"_____no_output_____"
],
[
"**Answer: **",
"_____no_output_____"
],
[
"### Question 4 - Describing the Model in Layman's Terms\n\n* In one to two paragraphs, explain to *CharityML*, in layman's terms, how the final model chosen is supposed to work. Be sure that you are describing the major qualities of the model, such as how the model is trained and how the model makes a prediction. Avoid using advanced mathematical jargon, such as describing equations.\n\n** HINT: **\n\nWhen explaining your model, if using external resources please include all citations.",
"_____no_output_____"
],
[
"**Answer: ** ",
"_____no_output_____"
],
[
"### Implementation: Model Tuning\nFine tune the chosen model. Use grid search (`GridSearchCV`) with at least one important parameter tuned with at least 3 different values. You will need to use the entire training set for this. In the code cell below, you will need to implement the following:\n- Import [`sklearn.grid_search.GridSearchCV`](http://scikit-learn.org/0.17/modules/generated/sklearn.grid_search.GridSearchCV.html) and [`sklearn.metrics.make_scorer`](http://scikit-learn.org/stable/modules/generated/sklearn.metrics.make_scorer.html).\n- Initialize the classifier you've chosen and store it in `clf`.\n - Set a `random_state` if one is available to the same state you set before.\n- Create a dictionary of parameters you wish to tune for the chosen model.\n - Example: `parameters = {'parameter' : [list of values]}`.\n - **Note:** Avoid tuning the `max_features` parameter of your learner if that parameter is available!\n- Use `make_scorer` to create an `fbeta_score` scoring object (with $\\beta = 0.5$).\n- Perform grid search on the classifier `clf` using the `'scorer'`, and store it in `grid_obj`.\n- Fit the grid search object to the training data (`X_train`, `y_train`), and store it in `grid_fit`.\n\n**Note:** Depending on the algorithm chosen and the parameter list, the following implementation may take some time to run!",
"_____no_output_____"
]
],
[
[
"# TODO: Import 'GridSearchCV', 'make_scorer', and any other necessary libraries\nfrom sklearn.metrics import make_scorer\nfrom sklearn.model_selection import GridSearchCV\n# TODO: Initialize the classifier\nclf = AdaBoostClassifier(random_state=42)\n\n# TODO: Create the parameters list you wish to tune, using a dictionary if needed.\n# HINT: parameters = {'parameter_1': [value1, value2], 'parameter_2': [value1, value2]}\nparameters = {\"n_estimators\": [10, 100, 200, 400],\n \"learning_rate\": [0.001, 0.005, .01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 1, 2, 10, 20]}\n\n# TODO: Make an fbeta_score scoring object using make_scorer()\nscorer = make_scorer(f1_score)\n\n# TODO: Perform grid search on the classifier using 'scorer' as the scoring method using GridSearchCV()\ngrid_obj = GridSearchCV(clf, parameters, scoring=scorer)\n\n# TODO: Fit the grid search object to the training data and find the optimal parameters using fit()\ngrid_fit = grid_obj.fit(X_train, y_train)\n\n# Get the estimator\nbest_clf = grid_fit.best_estimator_\n\n# Make predictions using the unoptimized and model\npredictions = (clf.fit(X_train, y_train)).predict(X_test)\nbest_predictions = best_clf.predict(X_test)\n\n# Report the before-and-afterscores\nprint(\"Unoptimized model\\n------\")\nprint(\"Accuracy score on testing data: {:.4f}\".format(accuracy_score(y_test, predictions)))\nprint(\"F-score on testing data: {:.4f}\".format(fbeta_score(y_test, predictions, beta = 0.5)))\nprint(\"\\nOptimized Model\\n------\")\nprint(\"Final accuracy score on the testing data: {:.4f}\".format(accuracy_score(y_test, best_predictions)))\nprint(\"Final F-score on the testing data: {:.4f}\".format(fbeta_score(y_test, best_predictions, beta = 0.5)))",
"C:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\model_selection\\_split.py:2053: FutureWarning: You should specify a value for 'cv' instead of relying on the default value. The default value will change from 3 to 5 in version 0.22.\n warnings.warn(CV_WARNING, FutureWarning)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\nC:\\Users\\dotnet5\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\sklearn\\metrics\\classification.py:1143: UndefinedMetricWarning: F-score is ill-defined and being set to 0.0 due to no predicted samples.\n 'precision', 'predicted', average, warn_for)\n"
]
],
[
[
"### Question 5 - Final Model Evaluation\n\n* What is your optimized model's accuracy and F-score on the testing data? \n* Are these scores better or worse than the unoptimized model? \n* How do the results from your optimized model compare to the naive predictor benchmarks you found earlier in **Question 1**?_ \n\n**Note:** Fill in the table below with your results, and then provide discussion in the **Answer** box.",
"_____no_output_____"
],
[
"#### Results:\n\n| Metric | Unoptimized Model | Optimized Model |\n| :------------: | :---------------: | :-------------: | \n| Accuracy Score | | |\n| F-score | | EXAMPLE |\n",
"_____no_output_____"
],
[
"**Answer: **",
"_____no_output_____"
],
[
"----\n## Feature Importance\n\nAn important task when performing supervised learning on a dataset like the census data we study here is determining which features provide the most predictive power. By focusing on the relationship between only a few crucial features and the target label we simplify our understanding of the phenomenon, which is most always a useful thing to do. In the case of this project, that means we wish to identify a small number of features that most strongly predict whether an individual makes at most or more than \\$50,000.\n\nChoose a scikit-learn classifier (e.g., adaboost, random forests) that has a `feature_importance_` attribute, which is a function that ranks the importance of features according to the chosen classifier. In the next python cell fit this classifier to training set and use this attribute to determine the top 5 most important features for the census dataset.",
"_____no_output_____"
],
[
"### Question 6 - Feature Relevance Observation\nWhen **Exploring the Data**, it was shown there are thirteen available features for each individual on record in the census data. Of these thirteen records, which five features do you believe to be most important for prediction, and in what order would you rank them and why?",
"_____no_output_____"
],
[
"**Answer:**",
"_____no_output_____"
],
[
"### Implementation - Extracting Feature Importance\nChoose a `scikit-learn` supervised learning algorithm that has a `feature_importance_` attribute availble for it. This attribute is a function that ranks the importance of each feature when making predictions based on the chosen algorithm.\n\nIn the code cell below, you will need to implement the following:\n - Import a supervised learning model from sklearn if it is different from the three used earlier.\n - Train the supervised model on the entire training set.\n - Extract the feature importances using `'.feature_importances_'`.",
"_____no_output_____"
]
],
[
[
"# TODO: Import a supervised learning model that has 'feature_importances_'\n\n\n# TODO: Train the supervised model on the training set using .fit(X_train, y_train)\nmodel = AdaBoostClassifier()\nmodel.fit(X_train, y_train)\n# TODO: Extract the feature importances using .feature_importances_ \nimportances = model.feature_importances_ \n\n# Plot\nvs.feature_plot(importances, X_train, y_train)",
"_____no_output_____"
]
],
[
[
"### Question 7 - Extracting Feature Importance\n\nObserve the visualization created above which displays the five most relevant features for predicting if an individual makes at most or above \\$50,000. \n* How do these five features compare to the five features you discussed in **Question 6**?\n* If you were close to the same answer, how does this visualization confirm your thoughts? \n* If you were not close, why do you think these features are more relevant?",
"_____no_output_____"
],
[
"**Answer:**",
"_____no_output_____"
],
[
"### Feature Selection\nHow does a model perform if we only use a subset of all the available features in the data? With less features required to train, the expectation is that training and prediction time is much lower — at the cost of performance metrics. From the visualization above, we see that the top five most important features contribute more than half of the importance of **all** features present in the data. This hints that we can attempt to *reduce the feature space* and simplify the information required for the model to learn. The code cell below will use the same optimized model you found earlier, and train it on the same training set *with only the top five important features*. ",
"_____no_output_____"
]
],
[
[
"# Import functionality for cloning a model\nfrom sklearn.base import clone\n\n# Reduce the feature space\nX_train_reduced = X_train[X_train.columns.values[(np.argsort(importances)[::-1])[:5]]]\nX_test_reduced = X_test[X_test.columns.values[(np.argsort(importances)[::-1])[:5]]]\n\n# Train on the \"best\" model found from grid search earlier\nclf = (clone(best_clf)).fit(X_train_reduced, y_train)\n\n# Make new predictions\nreduced_predictions = clf.predict(X_test_reduced)\n\n# Report scores from the final model using both versions of data\nprint(\"Final Model trained on full data\\n------\")\nprint(\"Accuracy on testing data: {:.4f}\".format(accuracy_score(y_test, best_predictions)))\nprint(\"F-score on testing data: {:.4f}\".format(fbeta_score(y_test, best_predictions, beta = 0.5)))\nprint(\"\\nFinal Model trained on reduced data\\n------\")\nprint(\"Accuracy on testing data: {:.4f}\".format(accuracy_score(y_test, reduced_predictions)))\nprint(\"F-score on testing data: {:.4f}\".format(fbeta_score(y_test, reduced_predictions, beta = 0.5)))",
"Final Model trained on full data\n------\nAccuracy on testing data: 0.8652\nF-score on testing data: 0.7401\n\nFinal Model trained on reduced data\n------\nAccuracy on testing data: 0.8417\nF-score on testing data: 0.7017\n"
]
],
[
[
"### Question 8 - Effects of Feature Selection\n\n* How does the final model's F-score and accuracy score on the reduced data using only five features compare to those same scores when all features are used?\n* If training time was a factor, would you consider using the reduced data as your training set?",
"_____no_output_____"
],
[
"**Answer:**",
"_____no_output_____"
],
[
"> **Note**: Once you have completed all of the code implementations and successfully answered each question above, you may finalize your work by exporting the iPython Notebook as an HTML document. You can do this by using the menu above and navigating to \n**File -> Download as -> HTML (.html)**. Include the finished document along with this notebook as your submission.",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
]
] |
ecaa638781f7b77b256585c48f136eff665d0c8e | 40,919 | ipynb | Jupyter Notebook | mlapp/MLAPP_CODE/MLAPP-C4-Code/dataset/.ipynb_checkpoints/shrunkenCentroidsSRBCTdemo-checkpoint.ipynb | xishansnow/MLAPP | 2f30cd94fd852a3f66fe92a124f65722bd2af509 | [
"MIT"
] | null | null | null | mlapp/MLAPP_CODE/MLAPP-C4-Code/dataset/.ipynb_checkpoints/shrunkenCentroidsSRBCTdemo-checkpoint.ipynb | xishansnow/MLAPP | 2f30cd94fd852a3f66fe92a124f65722bd2af509 | [
"MIT"
] | null | null | null | mlapp/MLAPP_CODE/MLAPP-C4-Code/dataset/.ipynb_checkpoints/shrunkenCentroidsSRBCTdemo-checkpoint.ipynb | xishansnow/MLAPP | 2f30cd94fd852a3f66fe92a124f65722bd2af509 | [
"MIT"
] | null | null | null | 34.47262 | 98 | 0.365307 | [
[
[
"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nplt.rcParams['figure.figsize']=(15,8)",
"_____no_output_____"
],
[
"# 从文件中载入数据\ndf_xtrain = pd.read_table('14cancer.xtrain',sep='\\s+',header=None, encoding='utf-8')\ndf_ytrain = pd.read_table('14cancer.ytrain',sep='\\s+',header=None, encoding='utf-8')\ndf_xtest = pd.read_table('14cancer.xtest',sep='\\s+',header=None, encoding='utf-8')\ndf_ytest = pd.read_table('14cancer.ytest',sep='\\s+',header=None, encoding='utf-8')",
"_____no_output_____"
],
[
"# 查看数据的形状\n# shape=(n_genes,n_samples),shape=(1,n_class)\nprint(df_xtrain.shape,df_ytrain.shape,df_xtest.shape,df_ytest.shape)",
"(2308, 63) (1, 63) (2308, 25) (1, 25)\n"
],
[
"# 对数据进行预览\ndf_xtrain.head()",
"_____no_output_____"
],
[
"# 对数据进行初步清洗,消除nan值\ndef drop_df_nan(df_x,df_y): \n # x: dataframe shape=(m,n) n: the number of samples\n # y: dataframe shape=(1,n)\n # 删除样本中那些包含nan值的样本(列)\n nan_x_index = np.where(np.isnan(df_x)) # 返回np.nan值所在的行和列 (rows_index,columns_index)\n nan_y_index = np.where(np.isnan(df_y)) \n nan_rows = np.union1d(nan_x_index[0],nan_y_index[0]) # 求取两个并集\n nan_cols = np.union1d(nan_x_index[1],nan_y_index[1])\n #print(list(df_x.columns[nan_cols]),type(list(df_x.columns[nan_cols])))\n if len(nan_cols)!= 0: # 如果返回的列索引值非空,即存在某些列存在np.nan值,我们进行删除,注意drop不改变元对象\n df_x=df_x.drop(columns=nan_cols)\n df_y=df_y.drop(columns=nan_cols)\n return df_x,df_y\ndf_xtrain,df_ytrain = drop_df_nan(df_xtrain, df_ytrain)\ndf_xtest, df_ytest = drop_df_nan(df_xtest, df_ytest)",
"_____no_output_____"
],
[
"# 按照机器学习中的常规习惯,我们将数据进行转置,使shape=(n_samples,d)\ndf_xtrain = df_xtrain.T\ndf_xtest = df_xtest.T",
"_____no_output_____"
],
[
"# 观察调整后的数据\ndf_xtrain.head()",
"_____no_output_____"
],
[
"df_xtest.head()",
"_____no_output_____"
],
[
"# 将每个样本的类别添加到dataframe的第1列\ndf_xtrain.insert(0,'Type',df_ytrain.T)\ndf_xtest.insert(0,'Type',df_ytest.T)",
"_____no_output_____"
],
[
"df_xtrain.head()",
"_____no_output_____"
],
[
"df_xtrain.head()",
"_____no_output_____"
],
[
"print('a')",
"a\n"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaa67dc2430ae993b2fe93e79ffbcb79a008a11 | 14,829 | ipynb | Jupyter Notebook | datasets/datasets_generation/utmb.ipynb | technion046195/technion_046195_2019_winter | af510cf91361790f8839638b78d18a14c1cb952e | [
"MIT"
] | null | null | null | datasets/datasets_generation/utmb.ipynb | technion046195/technion_046195_2019_winter | af510cf91361790f8839638b78d18a14c1cb952e | [
"MIT"
] | 3 | 2021-05-20T10:24:17.000Z | 2022-02-26T05:48:36.000Z | datasets/datasets_generation/utmb.ipynb | technion046195/technion_046195_2019_winter | af510cf91361790f8839638b78d18a14c1cb952e | [
"MIT"
] | 1 | 2021-11-09T12:59:17.000Z | 2021-11-09T12:59:17.000Z | 28.353728 | 266 | 0.397667 | [
[
[
"# Cleaning Up the Ultra-Trail du Mont-Blanc (UTMB) Dataset\nThe inspiration for using this dataset came from the following Kaggle datasets:\n- [Dataset: Ultra-Trail du Mont-Blanc 2003-2017](https://www.kaggle.com/ceruleansea/ultratrail-du-montblanc-20032017)\n\nThe original dataset taken from here: <https://utmbmontblanc.com/en/page/349/results.html>",
"_____no_output_____"
],
[
"## Importing Packages",
"_____no_output_____"
]
],
[
[
"import numpy as np\nimport pandas as pd",
"_____no_output_____"
]
],
[
[
"## Deffining Parameters",
"_____no_output_____"
]
],
[
[
"years = [2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018]\nage_group_mapping = {\n 'ES': 0,\n 'SE': 1,\n 'V1': 2,\n 'V2': 3,\n 'V3': 4,\n 'V4': 5,\n 'V5': 6,\n}",
"_____no_output_____"
]
],
[
[
"## Downloading Dataset",
"_____no_output_____"
],
[
"Manually download the web pages containing the dataset as a table. Go to <https://utmbmontblanc.com/en/page/349/results.html> select each of the years, right click the web page and select \"save as...\". Save the pages in \"../original/utmb_pages/{year}.html\"",
"_____no_output_____"
],
[
"## Loading the Datset",
"_____no_output_____"
]
],
[
[
"datasets_list = []\nfor year in years:\n dataset_tmp = pd.read_html('../original/utmb_pages/{}.html'.format(year), attrs = {'id': 'tabPass'})[0]\n dataset_tmp = pd.DataFrame({'Rank': dataset_tmp[0],\n 'Name': dataset_tmp[2],\n 'Category': dataset_tmp[3],\n 'Year': year,\n 'Time': dataset_tmp[len(dataset_tmp.columns) - 1],\n })\n dataset_tmp = dataset_tmp.dropna(axis=0)\n datasets_list.append(dataset_tmp)\n\nfull_dataset = pd.concat(datasets_list, axis=0, ignore_index=True)",
"_____no_output_____"
]
],
[
[
"## Displaying the first 10 rows of the dataset",
"_____no_output_____"
]
],
[
[
"print(len(full_dataset))\nfull_dataset.head(10)",
"19516\n"
]
],
[
[
"## Cleaning up the data",
"_____no_output_____"
]
],
[
[
"dataset = full_dataset.copy() # Creat a copy of the data\n\n## convert time from string to float-hours\ndataset['Result'] = pd.to_timedelta(dataset['Time']).astype(int) / 1e9 / 60 / 60\ndataset['Age Group'] = dataset['Category'].apply(lambda x: age_group_mapping[x[:2]])\ndataset['Gender'] = dataset['Category'].apply(lambda x: int(x[-1:] == 'F'))\n\n## Remove unneccesery fields\ndataset.pop('Category')\ndataset.pop('Time')\n\n## Print first 10 rows\ndataset.head(10)",
"_____no_output_____"
]
],
[
[
"## Save the clean dataset",
"_____no_output_____"
]
],
[
[
"dataset.to_csv('../../datasets/utmb.csv', index=False)",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecaa6caa01950fb8723fc91404da0171340374bd | 63,195 | ipynb | Jupyter Notebook | scripts/optuna/02_first_optimization.ipynb | tayutaedomo/tensorflow-sandbox | 3af51b73c76d48fffea63c9d33c5e54f6bcf0eca | [
"MIT"
] | null | null | null | scripts/optuna/02_first_optimization.ipynb | tayutaedomo/tensorflow-sandbox | 3af51b73c76d48fffea63c9d33c5e54f6bcf0eca | [
"MIT"
] | 8 | 2020-07-20T10:13:01.000Z | 2022-03-12T00:33:29.000Z | scripts/optuna/02_first_optimization.ipynb | tayutaedomo/tensorflow-sandbox | 3af51b73c76d48fffea63c9d33c5e54f6bcf0eca | [
"MIT"
] | null | null | null | 145.275862 | 393 | 0.712477 | [
[
[
"### Reference\n- https://optuna.readthedocs.io/en/stable/tutorial/first.html",
"_____no_output_____"
]
],
[
[
"import optuna",
"_____no_output_____"
],
[
"def objective(trial):\n x = trial.suggest_uniform('x', -10, 10)\n return (x - 2) ** 2",
"_____no_output_____"
],
[
"study = optuna.create_study()\nstudy.optimize(objective, n_trials=100)",
"[I 2020-06-19 17:19:33,909] Finished trial#0 with value: 18.067473315789826 with parameters: {'x': -2.250585055705841}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:33,971] Finished trial#1 with value: 20.0734940948287 with parameters: {'x': 6.480345309775654}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,031] Finished trial#2 with value: 62.9039901495955 with parameters: {'x': -5.9312035750947345}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,083] Finished trial#3 with value: 89.61323726363338 with parameters: {'x': -7.466426847741094}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,137] Finished trial#4 with value: 31.6929956783712 with parameters: {'x': -3.6296532467258764}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,197] Finished trial#5 with value: 53.330563910412785 with parameters: {'x': -5.302777821515097}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,252] Finished trial#6 with value: 48.73981496379398 with parameters: {'x': -4.981390618193053}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,308] Finished trial#7 with value: 140.28818719911067 with parameters: {'x': -9.844331437405433}. Best is trial#0 with value: 18.067473315789826.\n[I 2020-06-19 17:19:34,363] Finished trial#8 with value: 7.980473186580735 with parameters: {'x': -0.8249731302404868}. Best is trial#8 with value: 7.980473186580735.\n[I 2020-06-19 17:19:34,417] Finished trial#9 with value: 45.94757256950422 with parameters: {'x': 8.77846387978163}. Best is trial#8 with value: 7.980473186580735.\n[I 2020-06-19 17:19:34,485] Finished trial#10 with value: 0.2562785137953189 with parameters: {'x': 2.506239581419034}. Best is trial#10 with value: 0.2562785137953189.\n[I 2020-06-19 17:19:34,542] Finished trial#11 with value: 0.09341126612438752 with parameters: {'x': 2.305632567185481}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,601] Finished trial#12 with value: 2.2556960502984333 with parameters: {'x': 3.5018974832852052}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,656] Finished trial#13 with value: 0.17788253369599444 with parameters: {'x': 2.42176122829866}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,710] Finished trial#14 with value: 0.12900266521001522 with parameters: {'x': 2.359169410181345}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,767] Finished trial#15 with value: 12.02914489185987 with parameters: {'x': 5.468305766777184}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,826] Finished trial#16 with value: 2.0433310545141325 with parameters: {'x': 0.5705486876027808}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,883] Finished trial#17 with value: 59.32324814410884 with parameters: {'x': 9.702158667809229}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:34,944] Finished trial#18 with value: 10.530057047816575 with parameters: {'x': 5.245004938026532}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:35,002] Finished trial#19 with value: 30.217807552945004 with parameters: {'x': 7.497072634861668}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:35,058] Finished trial#20 with value: 2.6337915322951093 with parameters: {'x': 0.3771039675028134}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:35,117] Finished trial#21 with value: 0.5230875984562947 with parameters: {'x': 2.723247950882887}. Best is trial#11 with value: 0.09341126612438752.\n[I 2020-06-19 17:19:35,175] Finished trial#22 with value: 0.028019678693792106 with parameters: {'x': 1.8326092036765698}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,233] Finished trial#23 with value: 5.709864253503196 with parameters: {'x': 4.389532224830457}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,289] Finished trial#24 with value: 0.28941729344824446 with parameters: {'x': 1.4620248207879434}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,348] Finished trial#25 with value: 11.268498078248179 with parameters: {'x': -1.3568583643413048}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,409] Finished trial#26 with value: 0.6648948214939617 with parameters: {'x': 1.1845891701148668}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,465] Finished trial#27 with value: 4.880387593911087 with parameters: {'x': 4.209159929455332}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,525] Finished trial#28 with value: 20.819360382981035 with parameters: {'x': -2.5628237291156704}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,580] Finished trial#29 with value: 9.80845048724809 with parameters: {'x': -1.1318445822307481}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,631] Finished trial#30 with value: 22.735937449739765 with parameters: {'x': -2.768221623387462}. Best is trial#22 with value: 0.028019678693792106.\n[I 2020-06-19 17:19:35,691] Finished trial#31 with value: 0.0005746762763577535 with parameters: {'x': 2.023972406561665}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:35,760] Finished trial#32 with value: 0.003798368719038886 with parameters: {'x': 1.9383690928264163}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:35,836] Finished trial#33 with value: 22.01772066767798 with parameters: {'x': 6.6923044091019905}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:35,896] Finished trial#34 with value: 5.607591408183371 with parameters: {'x': -0.36803534774786906}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:35,959] Finished trial#35 with value: 2.7305788539006937 with parameters: {'x': 3.6524463240603895}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,023] Finished trial#36 with value: 0.19117982504230474 with parameters: {'x': 1.5627588479542385}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,092] Finished trial#37 with value: 9.534588503716032 with parameters: {'x': 5.087812899726282}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,153] Finished trial#38 with value: 3.382412957116685 with parameters: {'x': 0.1608662481709806}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,210] Finished trial#39 with value: 0.21948361321649293 with parameters: {'x': 1.5315092175757425}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,275] Finished trial#40 with value: 38.288943243324354 with parameters: {'x': -4.187806012095431}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,336] Finished trial#41 with value: 0.8188615869129919 with parameters: {'x': 2.9049097120226923}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,401] Finished trial#42 with value: 0.013125370398397389 with parameters: {'x': 1.8854339910863724}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,459] Finished trial#43 with value: 13.779286902557669 with parameters: {'x': -1.7120461880959497}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,519] Finished trial#44 with value: 2.6969137891907464 with parameters: {'x': 3.642228299960376}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,580] Finished trial#45 with value: 0.0019358416173742606 with parameters: {'x': 1.9560017998393768}. Best is trial#31 with value: 0.0005746762763577535.\n[I 2020-06-19 17:19:36,643] Finished trial#46 with value: 1.2244856267091275 with parameters: {'x': 0.8934352135057217}. Best is trial#31 with value: 0.0005746762763577535.\n"
],
[
"study.best_params",
"_____no_output_____"
],
[
"study.best_value",
"_____no_output_____"
],
[
"study.best_trial",
"_____no_output_____"
],
[
"study.trials",
"_____no_output_____"
],
[
"len(study.trials)",
"_____no_output_____"
],
[
"study.optimize(objective, n_trials=10)",
"[I 2020-06-19 17:22:30,429] Finished trial#100 with value: 7.498788637351737 with parameters: {'x': -0.738391615045543}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,486] Finished trial#101 with value: 0.00021060234932702564 with parameters: {'x': 2.0145121448906433}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,539] Finished trial#102 with value: 0.0002640585947654872 with parameters: {'x': 2.016249879838494}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,597] Finished trial#103 with value: 0.38922452684333053 with parameters: {'x': 2.623878615472057}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,649] Finished trial#104 with value: 2.247031240337747 with parameters: {'x': 0.5009899131967968}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,707] Finished trial#105 with value: 3.107608070292746 with parameters: {'x': 3.7628409089571146}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,761] Finished trial#106 with value: 0.41342749329865386 with parameters: {'x': 1.357016723935487}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,817] Finished trial#107 with value: 0.004184513303950873 with parameters: {'x': 2.0646878141843645}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,876] Finished trial#108 with value: 4.596582922341541 with parameters: {'x': -0.1439643006219904}. Best is trial#72 with value: 3.8623862398451214e-05.\n[I 2020-06-19 17:22:30,935] Finished trial#109 with value: 0.8642970166706844 with parameters: {'x': 2.9296757588916065}. Best is trial#72 with value: 3.8623862398451214e-05.\n"
],
[
"len(study.trials)",
"_____no_output_____"
]
]
] | [
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaa78fbfed57ee0efcd3f80ae8c5fbd90403222 | 23,838 | ipynb | Jupyter Notebook | docs/tutorials/01_quadratic_program.ipynb | MartinBeseda/qiskit-optimization | 11a924bd7b7f8508149d051827fe82591a12caba | [
"Apache-2.0"
] | 1 | 2021-07-09T14:53:15.000Z | 2021-07-09T14:53:15.000Z | docs/tutorials/01_quadratic_program.ipynb | MartinBeseda/qiskit-optimization | 11a924bd7b7f8508149d051827fe82591a12caba | [
"Apache-2.0"
] | null | null | null | docs/tutorials/01_quadratic_program.ipynb | MartinBeseda/qiskit-optimization | 11a924bd7b7f8508149d051827fe82591a12caba | [
"Apache-2.0"
] | null | null | null | 28.929612 | 646 | 0.529323 | [
[
[
"# Quadratic Programs",
"_____no_output_____"
],
[
"## Introduction",
"_____no_output_____"
],
[
"In this tutorial, we briefly introduce how to build optimization problems using Qiskit's optimization module.\nQiskit introduces the `QuadraticProgram` class to make a model of an optimization problem.\nMore precisely, it deals with quadratically constrained quadratic programs given as follows:\n\n$$\n\\begin{align}\n\\text{minimize}\\quad& x^\\top Q_0 x + c^\\top x\\\\\n\\text{subject to}\\quad& A x \\leq b\\\\\n& x^\\top Q_i x + a_i^\\top x \\leq r_i, \\quad 1,\\dots,i,\\dots,q\\\\\n& l_i \\leq x_i \\leq u_i, \\quad 1,\\dots,i,\\dots,n,\n\\end{align}\n$$\n\nwhere the $Q_i$ are $n \\times n$ matrices, $A$ is a $m \\times n$ matrix , $x$, and $c$ are $n$-dimensional vectors, $b$ is an $m$-dimensional vector, and where $x$ can defined as binary, integer, or continuous variables.\nIn addition to \"$\\leq$\" constraints 'QuadraticProgram' also supports \"$\\geq$\" and \"$=$\".",
"_____no_output_____"
],
[
"## Loading a `Quadratic Program` from an LP file",
"_____no_output_____"
],
[
"As setup, you need to import the following module.",
"_____no_output_____"
]
],
[
[
"from qiskit_optimization import QuadraticProgram\nfrom qiskit_optimization.translators import from_docplex_mp",
"_____no_output_____"
]
],
[
[
"You start with an empty model. How to add variables and constraints to a model is explained in the section \"Directly constructing a `QuadraticProgram`\".",
"_____no_output_____"
],
[
"Qiskit's optimization module supports the conversion from Docplex model. You can easily make a model of an optimization problem with Docplex.\nYou can find the documentation of Docplex at https://ibmdecisionoptimization.github.io/docplex-doc/mp/index.html\n\nYou can load a Docplex model to `QuadraticProgram` by using `from_docplex_mp` function.",
"_____no_output_____"
],
[
"## Loading a `QuadraticProgram` from a docplex model",
"_____no_output_____"
]
],
[
[
"# Make a Docplex model\nfrom docplex.mp.model import Model\n\nmdl = Model('docplex model')\nx = mdl.binary_var('x')\ny = mdl.integer_var(lb=-1, ub=5, name='y')\nmdl.minimize(x + 2 * y)\nmdl.add_constraint(x - y == 3)\nmdl.add_constraint((x + y) * (x - y) <= 1)\nprint(mdl.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: docplex model\n\nMinimize\n obj: x + 2 y\nSubject To\n c1: x - y = 3\n qc1: [ x^2 - y^2 ] <= 1\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
],
[
"# load from a Docplex model\nmod = from_docplex_mp(mdl)\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: docplex model\n\nMinimize\n obj: x + 2 y\nSubject To\n c0: x - y = 3\n q0: [ x^2 - y^2 ] <= 1\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"## Directly constructing a `QuadraticProgram`",
"_____no_output_____"
],
[
"We then explain how to make model of an optimization problem directly using `QuadraticProgram`.\nLet's start from an empty model.",
"_____no_output_____"
]
],
[
[
"# make an empty problem\nmod = QuadraticProgram('my problem')\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj:\nSubject To\n\nBounds\nEnd\n\n"
]
],
[
[
"The `QuadraticProgram` supports three types of variables:\n- Binary variable\n- Integer variable\n- Continuous variable\n\nWhen you add variables, you can specify names, types, lower bounds and upper bounds.\n\nWhen you display your problem as LP format,\n`Binaries` denotes binary variables and `Generals` denotes integer variables.\nIf variables are not included in either `Binaries` or `Generals`, such variables are continuous ones with default lower bound = 0 and upper bound = infinity.\nNote that you cannot use 'e' or 'E' as the first character of names due to the [specification of LP format](https://www.ibm.com/support/knowledgecenter/SSSA5P_12.7.1/ilog.odms.cplex.help/CPLEX/FileFormats/topics/LP_VariableNames.html).",
"_____no_output_____"
]
],
[
[
"# Add variables\nmod.binary_var(name='x')\nmod.integer_var(name='y', lowerbound=-1, upperbound=5)\nmod.continuous_var(name='z', lowerbound=-1, upperbound=5)\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj:\nSubject To\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n -1 <= z <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"You can set the objective function by invoking `QuadraticProgram.minimize` or `QuadraticProgram.maximize`.\nYou can add a constant term as well as linear and quadratic objective function by specifying linear and quadratic terms with either list, matrix or dictionary.\n\nNote that in the LP format the quadratic part has to be scaled by a factor $1/2$.\nThus, when printing as LP format, the quadratic part is first multiplied by 2 and then divided by 2 again.\n\nFor quadratic programs, there are 3 pieces that have to be specified: a constant (offset), a linear term ($c^{T}x$), and a quadratic term ($x^{T}Qx$).\n\nThe cell below shows how to declare an objective function using a dictionary. For the linear term, keys in the dictionary correspond to variable names, and the corresponding values are the coefficients. For the quadratic term, keys in the dictionary correspond to the two variables being multiplied, and the values are again the coefficients.\n",
"_____no_output_____"
]
],
[
[
"# Add objective function using dictionaries\nmod.minimize(constant=3, linear={'x': 1}, quadratic={('x', 'y'): 2, ('z', 'z'): -1})\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj: x + [ 4 x*y - 2 z^2 ]/2 + 3\nSubject To\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n -1 <= z <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"Another way to specify the quadratic program is using arrays. For the linear term, the array corresponds to the vector $c$ in the mathematical formulation. For the quadratic term, the array corresponds to the matrix $Q$. Note that the ordering of the variables ($x$ in the mathematical formulation) is the order in which the variables were originally declared in the QuadraticProgram object.",
"_____no_output_____"
]
],
[
[
"# Add objective function using lists/arrays\nmod.minimize(constant=3, linear=[1,0,0], quadratic=[[0,1,0],[1,0,0],[0,0,-1]])\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj: x + [ 4 x*y - 2 z^2 ]/2 + 3\nSubject To\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n -1 <= z <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"You can access the constant, the linear term, and the quadratic term by looking at `Quadratic.objective.{constant, linear, quadratic}`, respectively.\nAs for linear and quadratic terms, you can get a dense matrix (`to_array`), a sparse matrix (`coefficients`), and a dictionary (`to_dict`).\nFor dictionaries, you can specify whether to use variable indices or names as keys.\nNote that the quadratic terms are stored in a compressed way, e.g., `{('x', 'y'): 1, ('y', 'x'): 2}` is stored as `{('x', 'y'): 3}`.\nYou can get the quadratic term as a symmetric matrix by calling `to_array(symmetric=True)` or `to_dict(symmetric=True)`.\nIf you call `to_dict(name=True)`, you can get a dictionary whose keys are pairs of variable names.",
"_____no_output_____"
]
],
[
[
"print('constant:\\t\\t\\t', mod.objective.constant)\nprint('linear dict:\\t\\t\\t', mod.objective.linear.to_dict())\nprint('linear array:\\t\\t\\t', mod.objective.linear.to_array())\nprint('linear array as sparse matrix:\\n', mod.objective.linear.coefficients, '\\n')\nprint('quadratic dict w/ index:\\t', mod.objective.quadratic.to_dict())\nprint('quadratic dict w/ name:\\t\\t', mod.objective.quadratic.to_dict(use_name=True))\nprint('symmetric quadratic dict w/ name:\\t', mod.objective.quadratic.to_dict(use_name=True, symmetric=True))\nprint('quadratic matrix:\\n', mod.objective.quadratic.to_array(),'\\n')\nprint('symmetric quadratic matrix:\\n', mod.objective.quadratic.to_array(symmetric=True),'\\n')\nprint('quadratic matrix as sparse matrix:\\n', mod.objective.quadratic.coefficients)",
"constant:\t\t\t 3\nlinear dict:\t\t\t {0: 1}\nlinear array:\t\t\t [1 0 0]\nlinear array as sparse matrix:\n (0, 0)\t1 \n\nquadratic dict w/ index:\t {(0, 1): 2, (2, 2): -1}\nquadratic dict w/ name:\t\t {('x', 'y'): 2, ('z', 'z'): -1}\nsymmetric quadratic dict w/ name:\t {('y', 'x'): 1, ('x', 'y'): 1, ('z', 'z'): -1}\nquadratic matrix:\n [[ 0 2 0]\n [ 0 0 0]\n [ 0 0 -1]] \n\nsymmetric quadratic matrix:\n [[ 0 1 0]\n [ 1 0 0]\n [ 0 0 -1]] \n\nquadratic matrix as sparse matrix:\n (0, 1)\t2\n (2, 2)\t-1\n"
]
],
[
[
"## Adding/removing linear and quadratic constraints",
"_____no_output_____"
],
[
"You can add linear constraints by setting name, linear expression, sense and right-hand-side value (rhs).\nYou can use senses 'EQ', 'LE', and 'GE' as Docplex supports.",
"_____no_output_____"
]
],
[
[
"# Add linear constraints\nmod.linear_constraint(linear={'x': 1, 'y': 2}, sense='==', rhs=3, name='lin_eq')\nmod.linear_constraint(linear={'x': 1, 'y': 2}, sense='<=', rhs=3, name='lin_leq')\nmod.linear_constraint(linear={'x': 1, 'y': 2}, sense='>=', rhs=3, name='lin_geq')\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj: x + [ 4 x*y - 2 z^2 ]/2 + 3\nSubject To\n lin_eq: x + 2 y = 3\n lin_leq: x + 2 y <= 3\n lin_geq: x + 2 y >= 3\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n -1 <= z <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"You can add quadratic constraints as well as objective function and linear constraints.",
"_____no_output_____"
]
],
[
[
"# Add quadratic constraints\nmod.quadratic_constraint(linear={'x': 1, 'y': 1}, quadratic={('x', 'x'): 1, ('y', 'z'): -1}, sense='==', rhs=1, name='quad_eq')\nmod.quadratic_constraint(linear={'x': 1, 'y': 1}, quadratic={('x', 'x'): 1, ('y', 'z'): -1}, sense='<=', rhs=1, name='quad_leq')\nmod.quadratic_constraint(linear={'x': 1, 'y': 1}, quadratic={('x', 'x'): 1, ('y', 'z'): -1}, sense='>=', rhs=1, name='quad_geq')\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj: x + [ 4 x*y - 2 z^2 ]/2 + 3\nSubject To\n lin_eq: x + 2 y = 3\n lin_leq: x + 2 y <= 3\n lin_geq: x + 2 y >= 3\n quad_eq: [ x^2 - y*z ] + x + y = 1\n quad_leq: [ x^2 - y*z ] + x + y <= 1\n quad_geq: [ x^2 - y*z ] + x + y >= 1\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n -1 <= z <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"You can access linear and quadratic terms of linear and quadratic constraints as in the same way as the objective function.",
"_____no_output_____"
]
],
[
[
"lin_geq = mod.get_linear_constraint('lin_geq')\nprint('lin_geq:', lin_geq.linear.to_dict(use_name=True), lin_geq.sense, lin_geq.rhs)\nquad_geq = mod.get_quadratic_constraint('quad_geq')\nprint('quad_geq:', quad_geq.linear.to_dict(use_name=True), quad_geq.quadratic.to_dict(use_name=True), quad_geq.sense, lin_geq.rhs)",
"lin_geq: {'x': 1.0, 'y': 2.0} ConstraintSense.GE 3\nquad_geq: {'x': 1.0, 'y': 1.0} {('x', 'x'): 1.0, ('y', 'z'): -1.0} ConstraintSense.GE 3\n"
]
],
[
[
"You can also remove linear/quadratic constraints by `remove_linear_constraint` and `remove_quadratic_constraint`.",
"_____no_output_____"
]
],
[
[
"# Remove constraints\nmod.remove_linear_constraint('lin_eq')\nmod.remove_quadratic_constraint('quad_leq')\nprint(mod.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj: x + [ 4 x*y - 2 z^2 ]/2 + 3\nSubject To\n lin_leq: x + 2 y <= 3\n lin_geq: x + 2 y >= 3\n quad_eq: [ x^2 - y*z ] + x + y = 1\n quad_geq: [ x^2 - y*z ] + x + y >= 1\n\nBounds\n 0 <= x <= 1\n -1 <= y <= 5\n -1 <= z <= 5\n\nBinaries\n x\n\nGenerals\n y\nEnd\n\n"
]
],
[
[
"You can substitute some of variables with constants or other variables.\nMore precisely, `QuadraticProgram` has a method `substitute_variables(constants=..., variables=...)` to deal with the following two cases.\n- $x \\leftarrow c$: when `constants` have a dictionary `{x: c}`. \n- $x \\leftarrow c y$: when `variables` have a dictionary `{x: (y, c)}`.",
"_____no_output_____"
],
[
"## Substituting Variables",
"_____no_output_____"
]
],
[
[
"sub = mod.substitute_variables(constants={'x': 0}, variables={'y': ('z', -1)})\nprint(sub.export_as_lp_string())",
"\\ This file has been generated by DOcplex\n\\ ENCODING=ISO-8859-1\n\\Problem name: my problem\n\nMinimize\n obj: [ - 2 z^2 ]/2 + 3\nSubject To\n lin_leq: - 2 z <= 3\n lin_geq: - 2 z >= 3\n quad_eq: [ z^2 ] - z = 1\n quad_geq: [ z^2 ] - z >= 1\n\nBounds\n -1 <= z <= 1\nEnd\n\n"
]
],
[
[
"If the resulting problem is infeasible due to lower bounds or upper bounds, the methods returns the status `Status.INFEASIBLE`.\nWe try to replace variable `x` with -1, but -1 is out of range of `x` (0 <= `x` <= 1). So, it returns `Status.INFEASIBLE`.",
"_____no_output_____"
]
],
[
[
"sub = mod.substitute_variables(constants={'x': -1})\nprint(sub.status)",
"Infeasible substitution for variable: x\n"
]
],
[
[
"You cannot substitute variables multiple times. \nThe method raises an error in such a case.",
"_____no_output_____"
]
],
[
[
"from qiskit_optimization import QiskitOptimizationError\ntry:\n sub = mod.substitute_variables(constants={'x': -1}, variables={'y': ('x', 1)})\nexcept QiskitOptimizationError as e:\n print('Error: {}'.format(e))",
"Error: 'Cannot substitute by variable that gets substituted itself: y <- x 1'\n"
],
[
"import qiskit.tools.jupyter\n%qiskit_version_table\n%qiskit_copyright",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
]
] |
ecaa7a31dc48df4dc158b21a91708f914cd0f43e | 9,463 | ipynb | Jupyter Notebook | scientific_computation/about_accuracy.ipynb | vicente-gonzalez-ruiz/python-tutorial | e6a79510a0b3663786d6476a40e79fc8e8726f61 | [
"CC0-1.0"
] | 4 | 2017-03-06T09:49:11.000Z | 2019-10-16T00:09:38.000Z | scientific_computation/about_accuracy.ipynb | vicente-gonzalez-ruiz/python-tutorial | e6a79510a0b3663786d6476a40e79fc8e8726f61 | [
"CC0-1.0"
] | null | null | null | scientific_computation/about_accuracy.ipynb | vicente-gonzalez-ruiz/python-tutorial | e6a79510a0b3663786d6476a40e79fc8e8726f61 | [
"CC0-1.0"
] | 7 | 2017-11-02T11:00:30.000Z | 2020-01-31T22:41:27.000Z | 26.507003 | 1,013 | 0.59907 | [
[
[
"# About arithmetic accuracy in Python",
"_____no_output_____"
],
[
"<h1>Table of Contents<span class=\"tocSkip\"></span></h1>\n<div class=\"toc\"><ul class=\"toc-item\"><li><span><a href=\"#Integers\" data-toc-modified-id=\"Integers-1\"><span class=\"toc-item-num\">1 </span><a href=\"https://docs.python.org/3/c-api/long.html\" target=\"_blank\">Integers</a></a></span></li><li><span><a href=\"#Floats\" data-toc-modified-id=\"Floats-2\"><span class=\"toc-item-num\">2 </span><a href=\"https://docs.python.org/3/tutorial/floatingpoint.html\" target=\"_blank\">Floats</a></a></span></li></ul></div>",
"_____no_output_____"
],
[
"## [Integers](https://docs.python.org/3/c-api/long.html)",
"_____no_output_____"
],
[
"In python, integers have arbitrary precision and therefore we can represent an arbitrarily large range of integers (only limited by the available memory).",
"_____no_output_____"
]
],
[
[
"x = 7**273\nprint(x)\nprint(type(x))",
"514949835672429280118340184962210764526557059561644551308225135656646772567852802341125202657808555553768425192667497268234055382589043229395747814284702360571674673819941501856557513477604134701802987908639670470095067188938102407\n<class 'int'>\n"
]
],
[
[
"## [Floats](https://docs.python.org/3/tutorial/floatingpoint.html)",
"_____no_output_____"
],
[
"Python uses (hardware) [754 double precision representation](https://en.wikipedia.org/wiki/Double-precision_floating-point_format#IEEE_754_double-precision_binary_floating-point_format:_binary64) for floats. This means that some floats can be only represented approximately.",
"_____no_output_____"
],
[
"* Using [string format](https://docs.python.org/3.4/library/string.html#string-formatting) to see the precision limitation of **doubles** in Python. For example, it is impossible to represent exactly the number `0.1`:",
"_____no_output_____"
]
],
[
[
"format(0.1, '.80f')",
"_____no_output_____"
]
],
[
[
"* This can give us *surprises*:",
"_____no_output_____"
]
],
[
[
".1 + .1 + .1 == .3",
"_____no_output_____"
],
[
".1 + .1 == .2",
"_____no_output_____"
]
],
[
[
"* For \"infinite\" precision float arithmetic you can use [decimal](https://docs.python.org/3/library/decimal.html#module-decimal) or [mpmath](http://mpmath.org):",
"_____no_output_____"
]
],
[
[
"from decimal import Decimal, getcontext",
"_____no_output_____"
]
],
[
[
"* Getting 30 digits of 1/7:",
"_____no_output_____"
]
],
[
[
"getcontext().prec=80\nformat(Decimal(1)/Decimal(7), '.80f')",
"_____no_output_____"
]
],
[
[
"* We can see how many digits are true of 1/7 using doubles:",
"_____no_output_____"
]
],
[
[
"format(1/7, '.80f')",
"_____no_output_____"
],
[
"#12345678901234567 (17 digits)",
"_____no_output_____"
]
],
[
[
"* Decimal arithmetic produces decimal objects:",
"_____no_output_____"
]
],
[
[
"Decimal(1)/Decimal(7)",
"_____no_output_____"
]
],
[
[
"* Decimal objects can be printed with `format`:",
"_____no_output_____"
]
],
[
[
"print('{:.50f}'.format(Decimal(1)/Decimal(7)))",
"0.14285714285714285714285714285714285714285714285714\n"
]
],
[
[
"* A more complex example: lets compute 1000 digits of the $\\pi$ number using the [Bailey–Borwein–Plouffe formula](https://en.wikipedia.org/wiki/Bailey%E2%80%93Borwein%E2%80%93Plouffe_formula):\n\n$$\n\\pi = \\sum_{k = 0}^{\\infty}\\Bigg[ \\frac{1}{16^k} \\left( \\frac{4}{8k + 1} - \\frac{2}{8k + 4} - \\frac{1}{8k + 5} - \\frac{1}{8k + 6} \\right) \\Bigg]\n$$",
"_____no_output_____"
]
],
[
[
"# https://stackoverflow.com/questions/28284996/python-pi-calculation\nfrom decimal import Decimal, getcontext\ngetcontext().prec=1000\nmy_pi= sum(1/Decimal(16)**k * \n (Decimal(4)/(8*k+1) - \n Decimal(2)/(8*k+4) -\n Decimal(1)/(8*k+5) -\n Decimal(1)/(8*k+6)) for k in range(1000))\n'{:.1000f}'.format(my_pi)",
"_____no_output_____"
]
],
[
[
"You can visit [100,000 Digits of Pi](http://www.geom.uiuc.edu/~huberty/math5337/groupe/digits.html) or [One Million Digits of Pi](http://www.piday.org/million/) to check the correctness this code.",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecaa7b358b914d7510e5bc0d3071e27aeb9f0d53 | 949,042 | ipynb | Jupyter Notebook | examples/demo_fluxonium.ipynb | scqubits/scqubits-examples | 83e267b795f3c90de5543a5ca2b1c9d109acd52c | [
"BSD-3-Clause"
] | 8 | 2021-01-25T19:14:31.000Z | 2022-03-12T14:25:34.000Z | examples/demo_fluxonium.ipynb | scqubits/scqubits-examples | 83e267b795f3c90de5543a5ca2b1c9d109acd52c | [
"BSD-3-Clause"
] | null | null | null | examples/demo_fluxonium.ipynb | scqubits/scqubits-examples | 83e267b795f3c90de5543a5ca2b1c9d109acd52c | [
"BSD-3-Clause"
] | 9 | 2021-01-12T18:24:59.000Z | 2022-02-25T09:19:50.000Z | 42.256645 | 4,079 | 0.495872 | [
[
[
"# scqubits example: the fluxonium qubit\nJ. Koch and P. Groszkowski\n\nFor further documentation of scqubits see https://scqubits.readthedocs.io/en/latest/.\n\n---",
"_____no_output_____"
]
],
[
[
"%matplotlib inline\n%config InlineBackend.figure_format = 'svg'\n\nimport numpy as np\nimport scqubits as scq",
"_____no_output_____"
]
],
[
[
"# Fluxonium qubit",
"_____no_output_____"
],
[
"$H_\\text{fl}=-4E_\\text{C}\\partial_\\phi^2-E_\\text{J}\\cos(\\phi-\\varphi_\\text{ext}) +\\frac{1}{2}E_L\\phi^2$",
"_____no_output_____"
],
[
"**Creation via GUI** (ipywidgets needs to be installed for this to work.)",
"_____no_output_____"
]
],
[
[
"fluxonium = scq.Fluxonium.create()",
"_____no_output_____"
],
[
"print(fluxonium)",
"Fluxonium-----------| [Fluxonium_1]\n | EJ: 8.9\n | EC: 2.5\n | EL: 0.5\n | flux: 0.0\n | cutoff: 110\n | truncated_dim: 10\n |\n | dim: 110\n\n"
]
],
[
[
"**Programmatic creation**",
"_____no_output_____"
]
],
[
[
"fluxonium2 = scq.Fluxonium(\n EJ=8.9,\n EC=2.5,\n EL=0.5,\n cutoff = 110,\n flux = 0.5\n)",
"_____no_output_____"
]
],
[
[
"## Computing and visualizing spectra",
"_____no_output_____"
]
],
[
[
"fluxonium.eigenvals()",
"_____no_output_____"
],
[
"fluxonium.eigenvals()",
"_____no_output_____"
],
[
"flux_list = np.linspace(-0.5, 0.5, 151)\nfluxonium.plot_evals_vs_paramvals('flux', flux_list, evals_count=8);",
"_____no_output_____"
],
[
"fluxonium.cos_phi_operator()",
"_____no_output_____"
],
[
"flux_list = np.linspace(-0.5, 0.5, 151)\nfluxonium.plot_evals_vs_paramvals('flux', flux_list, evals_count=8);",
"_____no_output_____"
],
[
"fluxonium.plot_evals_vs_paramvals('flux', flux_list, evals_count=9, subtract_ground=True);",
"_____no_output_____"
],
[
"fluxonium.flux = 0.5\nfluxonium.plot_wavefunction(esys=None, which=range(5), mode='real');",
"_____no_output_____"
],
[
"fluxonium = scq.Fluxonium(\n EJ=5.7,\n EC=1.2,\n EL=1.0,\n cutoff = 150,\n flux = 0.5\n)\nfig, axes=fluxonium.plot_wavefunction(esys=None, which=[0,1,2,3,4,5], mode='real');",
"_____no_output_____"
]
],
[
[
"## Matrix elements",
"_____no_output_____"
]
],
[
[
"phimat = fluxonium.matrixelement_table('phi_operator', evals_count=10)\nprint(phimat)",
"[[-2.90163865e-14 -2.42020774e+00 5.90469630e-15 -5.96669304e-01\n -2.03234656e-15 1.26034410e-02 5.95007150e-16 1.05152531e-02\n -1.74134593e-15 -2.08796925e-03]\n [-2.42020774e+00 3.00354610e-14 1.16100233e+00 3.24395106e-15\n -1.98939356e-01 -7.54922082e-17 1.96392027e-02 -1.61667425e-15\n -1.88229452e-03 -5.82740140e-16]\n [ 5.90469630e-15 1.16100233e+00 2.41381156e-16 2.02810531e+00\n 1.37402274e-15 -2.87499531e-01 2.56172447e-16 -3.19256763e-02\n 5.97912002e-16 1.96457721e-04]\n [-5.96669304e-01 3.24395106e-15 2.02810531e+00 6.91353555e-16\n -2.11221368e+00 -2.34689704e-15 -1.78076985e-01 2.51487532e-15\n -4.52028150e-02 2.16859244e-15]\n [-2.03234656e-15 -1.98939356e-01 1.37402274e-15 -2.11221368e+00\n -3.58037476e-15 2.41344721e+00 9.55042118e-16 -1.41490331e-01\n -1.89666319e-15 5.74957935e-02]\n [ 1.26034410e-02 -7.54922082e-17 -2.87499531e-01 -2.34689704e-15\n 2.41344721e+00 -6.45618181e-15 2.65902027e+00 5.82901810e-15\n -7.06894388e-02 3.34797329e-15]\n [ 5.95007150e-16 1.96392027e-02 2.56172447e-16 -1.78076985e-01\n 9.55042118e-16 2.65902027e+00 3.66400698e-15 -2.95543793e+00\n -8.25765333e-15 2.89606649e-02]\n [ 1.05152531e-02 -1.61667425e-15 -3.19256763e-02 2.51487532e-15\n -1.41490331e-01 5.82901810e-15 -2.95543793e+00 -1.23135517e-14\n 3.32236039e+00 -2.75391230e-14]\n [-1.74134593e-15 -1.88229452e-03 5.97912002e-16 -4.52028150e-02\n -1.89666319e-15 -7.06894388e-02 -8.25765333e-15 3.32236039e+00\n 4.75438291e-14 3.82811850e+00]\n [-2.08796925e-03 -5.82740140e-16 1.96457721e-04 2.16859244e-15\n 5.74957935e-02 3.34797329e-15 2.89606649e-02 -2.75391230e-14\n 3.82811850e+00 9.58022230e-15]]\n"
],
[
"fluxonium.plot_matrixelements('n_operator', evals_count=16);",
"_____no_output_____"
],
[
"fluxonium.plot_matelem_vs_paramvals('n_operator', 'flux', flux_list, select_elems=4);",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
]
] |
ecaa8acff682391c82547f71d9f0e223e5d12062 | 2,525 | ipynb | Jupyter Notebook | colab/fin_eng_translate.ipynb | juslop/nmt | 27674843e41046296d146272a1865268cfe21d71 | [
"Apache-2.0"
] | 1 | 2019-11-01T08:59:42.000Z | 2019-11-01T08:59:42.000Z | colab/fin_eng_translate.ipynb | juslop/nmt | 27674843e41046296d146272a1865268cfe21d71 | [
"Apache-2.0"
] | 2 | 2020-01-28T22:10:13.000Z | 2020-09-25T22:03:18.000Z | colab/fin_eng_translate.ipynb | juslop/nmt | 27674843e41046296d146272a1865268cfe21d71 | [
"Apache-2.0"
] | null | null | null | 28.693182 | 105 | 0.522772 | [
[
[
"#interactive finnish to english translation with 6 LSTM layer model\n#encoder has 3 bidirectional layers, decoder 6 unidir LSTM layers, Banhdanau attention\n#model trained with 2.5M translated sentences for 36 hours with 2 Nvidia GTX 1060 6GB cards.\n#english vocabulary 65 kwords, finnish voc 286 kwords\n!git clone https://github.com/juslop/nmt.git\n!pip install --upgrade tables\n!pip install deepdish",
"_____no_output_____"
],
[
"from google.colab import drive\ndrive.mount(\"/content/gdrive\")",
"_____no_output_____"
],
[
"#upload weights and dictionary files for reading, in this case they are in gdrive\nimport tarfile, os\npath_to_tarballs = \"/content/gdrive/My Drive/tf_translator_weights_and_dictionaries\"\nembeddings = os.path.join(path_to_tarballs, \"finnish-english-dct-embeddings.tar.gz\")\nweights = os.path.join(path_to_tarballs, \"finnish-english-weights.tar.gz\")\nwith tarfile.open(weights) as tb:\n tb.extractall(path=\"nmt\")\nwith tarfile.open(embeddings) as tb:\n tb.extractall(path=\"nmt\")",
"_____no_output_____"
],
[
"%cd nmt\n!cp configs/finnish-english.json config.json\n!python translate.py translate",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code"
]
] |
ecaa94c1ed48bff8dc1b27c6ff4fee9d66747597 | 7,541 | ipynb | Jupyter Notebook | day-3/wordembeddings.ipynb | ruschenpohler/computational-text-analysis-spring-2019 | 05abff06c4cc8596d29e05e2b69a7323d9c2f5d4 | [
"CC-BY-4.0"
] | null | null | null | day-3/wordembeddings.ipynb | ruschenpohler/computational-text-analysis-spring-2019 | 05abff06c4cc8596d29e05e2b69a7323d9c2f5d4 | [
"CC-BY-4.0"
] | null | null | null | day-3/wordembeddings.ipynb | ruschenpohler/computational-text-analysis-spring-2019 | 05abff06c4cc8596d29e05e2b69a7323d9c2f5d4 | [
"CC-BY-4.0"
] | null | null | null | 31.290456 | 731 | 0.609336 | [
[
[
"# Intro to word embeddings\n\nSo far we have focused on bag-of-word approaches i.e representations of text as a vector of word frequencies. An alternative formalization of text consists in representing the words (or bi-grams, phrases, etc) themselves as vectors. A _word vector_ has no meaning per se, but it is informative of the _context_ in which the word is used. This vector representation can become very close to the semantic meaning of the word. Combined with simple vector operations, these representations can used to find synonyms, to test analogies, etc. Word vectors can also be used in any subsequent task (dictionary methods, classification, etc) as features instead of the simple word frequencies in the classical bag-of-words approach.\n\nIn this notebook we are going to construct word embeddings using neural networks. The spirit of the method is to use 'prediction as an excuse': either predict a target word conditional on its surrounding words (_continuous-bag-of-words_) or predict surrounding words conditional on the target (_skip-gram_). What we care about is not the final output but the _hidden layer_ projection from a two-layers neural network designed to solve that prediction problem (see skip-gram diagram below from Mikolov et al. 2013). \n\n<img src='img/wordembeddings_diagram.png' />\n\nIf we choose the hidden layer to have $K$ hidden neurons then each target word is represented by a $K$-dimensional vector of hidden outputm which we call _embedding_. In practice $K$ should be between 100 and 300, but that really depends on the vocabulary size. For the purpose of learning we are going to apply the famous skip-gram Google's Word2Vec approach (Mikolov et al. 2013) to a corpus that is typically _too small_ so that we reduce our word representations to vectors of 30 dimensions. Keep in mind that the typical required vocabulary size is at least half a million of unique tokens.\n\nLast note on Word2Vec: it is very powerful! When trained on very large corpora (like all of English Wikipedia) it can perform very strong analogies such as finding that the vector corresponding the most to the output of the operation 'king' - 'man' + 'woman' is 'queen'. There exist alternative packages such as GloVe (Stanford NLP) or FastText.",
"_____no_output_____"
],
[
"## Data\n\nWe are going to embed the vocabulary from the corpus of Jane Austen's books we encountered on day 1. First, let's read the files into a single string:",
"_____no_output_____"
]
],
[
[
"import codecs\n\nimport os\nDATA_DIR = 'data'\n\nimport glob\nfnames = os.path.join(DATA_DIR, 'austen', '*.txt')\nfnames = glob.glob(fnames)\nraw = ''\nfor fname in fnames:\n with codecs.open(fname, \"r\", encoding='utf-8-sig', errors='ignore') as f:\n t = f.read()\n raw += t",
"_____no_output_____"
]
],
[
[
"## Quick pre-processing",
"_____no_output_____"
]
],
[
[
"text = raw [679:] # gets rid of meta information at the beginning\n\n# A few modifications before sentence segmentation\ntext = text.replace('Mr.', 'Mr')\ntext = text.replace('Mrs.', 'Mrs')\ntext = text.replace('\\n', ' ')\ntext = text.replace('\\r', ' ')\n\n# Sentence segmentation\nimport re\nsent_boundary_pattern = r'[.?!]'\nsentences = re.split(sent_boundary_pattern, text)\n\n# Remove punctuation, special characters and upper cases\nfrom string import punctuation\nspecial = ['“', '”']\nsentences = [''.join([ch for ch in sent if ch not in punctuation and ch not in special]) for sent in sentences]\nsentences = [sent.lower() for sent in sentences]\n\n# Remove white sace\nsentences = [sent.strip() for sent in sentences]\n\n# Tokenization within sentence\nlist_of_list = [sent.split() for sent in sentences]\nlist_of_list[:2]",
"_____no_output_____"
]
],
[
[
"## Train a skip-gram model with Word2Vec \n\nFirst, you'll need to install [Gensim](https://pypi.org/project/gensim/). You can do so directly in the notebook using ```!pip install```.",
"_____no_output_____"
]
],
[
[
"!pip install gensim",
"_____no_output_____"
],
[
"from gensim.models import Word2Vec\n\nmodel = Word2Vec(min_count=2, size=30, sg=1)\nmodel.build_vocab(list_of_list) # prepare the model vocabulary\nmodel.train(list_of_list, total_examples=model.corpus_count, epochs=model.iter)\n",
"_____no_output_____"
]
],
[
[
"## Asses model accuracy\n### Size of vocabulary",
"_____no_output_____"
]
],
[
[
" print(len(model.wv.vocab))",
"_____no_output_____"
]
],
[
[
"### Latent vector representation",
"_____no_output_____"
]
],
[
[
"print(model.wv.word_vec('woman'))",
"_____no_output_____"
]
],
[
[
"### Similarity between words",
"_____no_output_____"
]
],
[
[
"print(model.wv.similarity('woman', 'wife'))",
"_____no_output_____"
]
],
[
[
"### Most similar words ",
"_____no_output_____"
]
],
[
[
"print(model.wv.similar_by_word('woman'))",
"_____no_output_____"
],
[
"vector = model.wv.word_vec('woman') - model.wv.word_vec('man') + model.wv.word_vec('husband') #wife?\nprint(model.wv.similar_by_vector(vector))",
"_____no_output_____"
]
],
[
[
"## Challenge\n\nTry to improve the model by tuning its parameters:\n- Increase the context window\n- Construct continuous-bag-of-words representations\n",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
]
] |
ecaa9a4ce72728e6a4d846f3b2d140ffc3f2bec0 | 443,115 | ipynb | Jupyter Notebook | Untitled.ipynb | dougollerenshaw/rsna-intracranial-hemorrhage-detection | 1edc660c672ba8f811f6ae11b817e5fcb6bc3fa8 | [
"MIT"
] | null | null | null | Untitled.ipynb | dougollerenshaw/rsna-intracranial-hemorrhage-detection | 1edc660c672ba8f811f6ae11b817e5fcb6bc3fa8 | [
"MIT"
] | null | null | null | Untitled.ipynb | dougollerenshaw/rsna-intracranial-hemorrhage-detection | 1edc660c672ba8f811f6ae11b817e5fcb6bc3fa8 | [
"MIT"
] | null | null | null | 884.461078 | 430,328 | 0.950886 | [
[
[
"import pydicom\n\nimport pandas as pd\nimport numpy as np\nimport os\nimport matplotlib.pyplot as plt\nfrom skimage import exposure, io, transform\nfrom skimage.transform import rotate, warp\nfrom skimage.transform import SimilarityTransform\nimport shutil\nimport urllib\nimport warnings\nimport datetime\nimport fnmatch\n\n%matplotlib notebook\n\nfrom IPython.core.display import display, HTML\ndisplay(HTML(\"<style>.container { width:100% !important; }</style>\"))",
"_____no_output_____"
],
[
"import sys\nsys.path.append('..')",
"_____no_output_____"
],
[
"import utils",
"Using TensorFlow backend.\n"
],
[
"dataloc = '/ssd1'\ntraindf_raw = pd.read_csv(os.path.join(dataloc,'stage_1_train.csv'))",
"_____no_output_____"
],
[
"tdf = utils.load_training_data('/ssd1')",
"_____no_output_____"
],
[
"categories = utils.define_categories(tdf)",
"_____no_output_____"
],
[
"categories",
"_____no_output_____"
],
[
"training_fraction = 0.001\nshuff = tdf.sample(frac=training_fraction, random_state=0)\ntrain_df = shuff.iloc[:int(0.90*len(shuff))]\nvalidate_df = shuff.iloc[int(0.90*len(shuff)):]\nlen(shuff),len(train_df),len(validate_df)",
"_____no_output_____"
],
[
"train_df.head()",
"_____no_output_____"
],
[
"\ntrain_generator = utils.Three_Channel_Generator(\n train_df.reset_index(),\n ycols=categories,\n desired_size=512,\n batch_size=8,\n random_transform=False,\n rgb=True\n)",
"_____no_output_____"
],
[
"train_generator.__reset__()\nX,y = train_generator.__next__()\n\nfig,ax=plt.subplots(2,4,figsize=(14,7))\nfor ii,axis in enumerate(ax.flatten()):\n axis.imshow(X[ii])\n axis.set_title(y[ii])",
"_____no_output_____"
],
[
"np.shape(X[0])",
"_____no_output_____"
],
[
"X[0,:,:,2].min(),X[0,:,:,2].max()",
"_____no_output_____"
],
[
"train_df.iloc[2]",
"_____no_output_____"
],
[
"traindf_raw[traindf_raw['ID'].str.startswith('ID_f242b800c')]",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaaa1d9a6648399bb4407376e321169366b4851 | 56,247 | ipynb | Jupyter Notebook | content/lessons/01/Class-Coding-Lab/CCL-walkthrough.ipynb | hvpuzzan-su/intern-project | b65e8d2cd43e21c3fdc61b7bbb8e81f5c9148f08 | [
"MIT"
] | null | null | null | content/lessons/01/Class-Coding-Lab/CCL-walkthrough.ipynb | hvpuzzan-su/intern-project | b65e8d2cd43e21c3fdc61b7bbb8e81f5c9148f08 | [
"MIT"
] | null | null | null | content/lessons/01/Class-Coding-Lab/CCL-walkthrough.ipynb | hvpuzzan-su/intern-project | b65e8d2cd43e21c3fdc61b7bbb8e81f5c9148f08 | [
"MIT"
] | null | null | null | 325.127168 | 51,468 | 0.931943 | [
[
[
"# Class Coding Lab: Walkthrough\n\nFor this class coding lab paste the code provided by the walk through into the cell below. Execute the cell to verfiy the program runs correctly and also saves the notebook output.",
"_____no_output_____"
]
],
[
[
"print(\"Hello, Python!\")",
"Hello, Python!\n"
],
[
"%matplotlib inline\nimport numpy as np\nimport matplotlib.pyplot as plt\n\nN = 20\ntheta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)\nradii = 10 * np.random.rand(N)\nwidth = np.pi / 4 * np.random.rand(N)\n\nax = plt.subplot(111, polar=True)\nbars = ax.bar(theta, radii, width=width, bottom=0.0)\n\nfor r, bar in zip(radii, bars):\n bar.set_facecolor(plt.cm.jet(r / 10.))\n bar.set_alpha(0.5)\n\nplt.show()",
"_____no_output_____"
],
[
"print(\"Testing to ensure all modules are installed...\")\nimport requests \nimport json\nimport pandas as pd\nimport numpy as np\nimport matplotlib\nimport plotly\nimport cufflinks as cf\nimport folium \nfrom IPython.display import display, HTML\n\ndisplay(HTML(\"This is <span style='colo: green;'>Working</span\"))",
"Testing to ensure all modules are installed...\n"
],
[
"print(\"Testing to ensure all modules are installed...\")\nimport requests \nimport json\nimport pandas as pd\nimport numpy as np\nimport matplotlib\nimport plotly\nimport cufflinks as cf\nimport folium \nfrom IPython.display import display, HTML\n\ndisplay(HTML(\"This is <span style='color: green;'>Working</span\"))",
"Testing to ensure all modules are installed...\n"
]
]
] | [
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code"
]
] |
ecaab4ee0da10bd8d4eab334fab79a1717e556b2 | 959,893 | ipynb | Jupyter Notebook | ml/Retraining_Fairfaces.ipynb | margaretmz/selfie2anime-with-tflite | 8cd1c03f8c5133a53b88d67eafebbac83b64a86a | [
"MIT"
] | 28 | 2020-07-15T14:01:59.000Z | 2020-09-04T16:41:31.000Z | ml/Retraining_Fairfaces.ipynb | margaretmz/selfie2anime-e2e-tutorial | 8cd1c03f8c5133a53b88d67eafebbac83b64a86a | [
"MIT"
] | 2 | 2020-09-30T05:31:40.000Z | 2020-09-30T05:33:31.000Z | ml/Retraining_Fairfaces.ipynb | margaretmz/selfie2anime-e2e-tutorial | 8cd1c03f8c5133a53b88d67eafebbac83b64a86a | [
"MIT"
] | 8 | 2020-07-15T19:00:14.000Z | 2020-08-19T03:38:35.000Z | 137.304105 | 100,838 | 0.746078 | [
[
[
"<a href=\"https://colab.research.google.com/github/margaretmz/selfie2anime-e2e-tutorial/blob/master/Retraining_Fairfaces.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
]
],
[
[
"!nvidia-smi",
"Thu Jun 25 16:35:58 2020 \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 450.36.06 Driver Version: 418.67 CUDA Version: 10.1 |\n|-------------------------------+----------------------+----------------------+\n| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |\n| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |\n| | | MIG M. |\n|===============================+======================+======================|\n| 0 Tesla K80 Off | 00000000:00:04.0 Off | 0 |\n| N/A 57C P8 30W / 149W | 0MiB / 11441MiB | 0% Default |\n| | | ERR! |\n+-------------------------------+----------------------+----------------------+\n \n+-----------------------------------------------------------------------------+\n| Processes: |\n| GPU GI CI PID Type Process name GPU Memory |\n| ID ID Usage |\n|=============================================================================|\n| No running processes found |\n+-----------------------------------------------------------------------------+\n"
],
[
"%tensorflow_version 1.x",
"TensorFlow 1.x selected.\n"
],
[
"import tensorflow as tf\nprint(tf.__version__)",
"1.15.2\n"
]
],
[
[
"### Fairfaces dataset",
"_____no_output_____"
]
],
[
[
"!wget --load-cookies /tmp/cookies.txt \"https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\\1\\n/p')&id=1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86\" -O fairface-img-margin025-trainval.zip && rm -rf /tmp/cookies.txt",
"--2020-06-25 16:36:11-- https://docs.google.com/uc?export=download&confirm=uvTH&id=1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86\nResolving docs.google.com (docs.google.com)... 108.177.111.102, 108.177.111.138, 108.177.111.113, ...\nConnecting to docs.google.com (docs.google.com)|108.177.111.102|:443... connected.\nHTTP request sent, awaiting response... 302 Moved Temporarily\nLocation: https://doc-0s-44-docs.googleusercontent.com/docs/securesc/jers9n5hblft7tchc7skr5ap0ioic9bq/vnclf26sc55v0pub8huumvo9fd8ap38c/1593102900000/03161587497725415728/00424035155371049218Z/1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86?e=download [following]\n--2020-06-25 16:36:11-- https://doc-0s-44-docs.googleusercontent.com/docs/securesc/jers9n5hblft7tchc7skr5ap0ioic9bq/vnclf26sc55v0pub8huumvo9fd8ap38c/1593102900000/03161587497725415728/00424035155371049218Z/1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86?e=download\nResolving doc-0s-44-docs.googleusercontent.com (doc-0s-44-docs.googleusercontent.com)... 172.217.212.132, 2607:f8b0:4001:c03::84\nConnecting to doc-0s-44-docs.googleusercontent.com (doc-0s-44-docs.googleusercontent.com)|172.217.212.132|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https://docs.google.com/nonceSigner?nonce=qkabviufi12qs&continue=https://doc-0s-44-docs.googleusercontent.com/docs/securesc/jers9n5hblft7tchc7skr5ap0ioic9bq/vnclf26sc55v0pub8huumvo9fd8ap38c/1593102900000/03161587497725415728/00424035155371049218Z/1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86?e%3Ddownload&hash=q6gsi8ork2qddk51sljcaf3uvkkbtkgq [following]\n--2020-06-25 16:36:11-- https://docs.google.com/nonceSigner?nonce=qkabviufi12qs&continue=https://doc-0s-44-docs.googleusercontent.com/docs/securesc/jers9n5hblft7tchc7skr5ap0ioic9bq/vnclf26sc55v0pub8huumvo9fd8ap38c/1593102900000/03161587497725415728/00424035155371049218Z/1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86?e%3Ddownload&hash=q6gsi8ork2qddk51sljcaf3uvkkbtkgq\nConnecting to docs.google.com (docs.google.com)|108.177.111.102|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https://doc-0s-44-docs.googleusercontent.com/docs/securesc/jers9n5hblft7tchc7skr5ap0ioic9bq/vnclf26sc55v0pub8huumvo9fd8ap38c/1593102900000/03161587497725415728/00424035155371049218Z/1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86?e=download&nonce=qkabviufi12qs&user=00424035155371049218Z&hash=n7gj6ktrv0e1a1083jengam0821rqpnb [following]\n--2020-06-25 16:36:11-- https://doc-0s-44-docs.googleusercontent.com/docs/securesc/jers9n5hblft7tchc7skr5ap0ioic9bq/vnclf26sc55v0pub8huumvo9fd8ap38c/1593102900000/03161587497725415728/00424035155371049218Z/1Z1RqRo0_JiavaZw2yzZG6WETdZQ8qX86?e=download&nonce=qkabviufi12qs&user=00424035155371049218Z&hash=n7gj6ktrv0e1a1083jengam0821rqpnb\nConnecting to doc-0s-44-docs.googleusercontent.com (doc-0s-44-docs.googleusercontent.com)|172.217.212.132|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: unspecified [application/zip]\nSaving to: ‘fairface-img-margin025-trainval.zip’\n\nfairface-img-margin [ <=> ] 551.45M 48.1MB/s in 12s \n\n2020-06-25 16:36:23 (46.7 MB/s) - ‘fairface-img-margin025-trainval.zip’ saved [578232678]\n\n"
],
[
"!unzip -q fairface-img-margin025-trainval.zip",
"_____no_output_____"
]
],
[
[
"### Selfie2Anime dataset",
"_____no_output_____"
]
],
[
[
"!wget --load-cookies /tmp/cookies.txt \"https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\\1\\n/p')&id=1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF\" -O selfie2anime.zip && rm -rf /tmp/cookies.txt",
"--2020-06-25 16:36:41-- https://docs.google.com/uc?export=download&confirm=wrXD&id=1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF\nResolving docs.google.com (docs.google.com)... 108.177.111.102, 108.177.111.139, 108.177.111.100, ...\nConnecting to docs.google.com (docs.google.com)|108.177.111.102|:443... connected.\nHTTP request sent, awaiting response... 302 Moved Temporarily\nLocation: https://doc-14-bo-docs.googleusercontent.com/docs/securesc/411qa4g4tdlvt7602v3qqn8dk58sq2p8/8v0r9mlp4kpe53tve0grauekhf9l52g6/1593102975000/07883268761297596834/00043245050220984211Z/1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF?e=download [following]\n--2020-06-25 16:36:41-- https://doc-14-bo-docs.googleusercontent.com/docs/securesc/411qa4g4tdlvt7602v3qqn8dk58sq2p8/8v0r9mlp4kpe53tve0grauekhf9l52g6/1593102975000/07883268761297596834/00043245050220984211Z/1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF?e=download\nResolving doc-14-bo-docs.googleusercontent.com (doc-14-bo-docs.googleusercontent.com)... 172.217.212.132, 2607:f8b0:4001:c03::84\nConnecting to doc-14-bo-docs.googleusercontent.com (doc-14-bo-docs.googleusercontent.com)|172.217.212.132|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https://docs.google.com/nonceSigner?nonce=h9hdtrtu9nafc&continue=https://doc-14-bo-docs.googleusercontent.com/docs/securesc/411qa4g4tdlvt7602v3qqn8dk58sq2p8/8v0r9mlp4kpe53tve0grauekhf9l52g6/1593102975000/07883268761297596834/00043245050220984211Z/1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF?e%3Ddownload&hash=bmnrts8b4e3l17a7gasqrma7tq8q6uu3 [following]\n--2020-06-25 16:36:41-- https://docs.google.com/nonceSigner?nonce=h9hdtrtu9nafc&continue=https://doc-14-bo-docs.googleusercontent.com/docs/securesc/411qa4g4tdlvt7602v3qqn8dk58sq2p8/8v0r9mlp4kpe53tve0grauekhf9l52g6/1593102975000/07883268761297596834/00043245050220984211Z/1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF?e%3Ddownload&hash=bmnrts8b4e3l17a7gasqrma7tq8q6uu3\nConnecting to docs.google.com (docs.google.com)|108.177.111.102|:443... connected.\nHTTP request sent, awaiting response... 302 Found\nLocation: https://doc-14-bo-docs.googleusercontent.com/docs/securesc/411qa4g4tdlvt7602v3qqn8dk58sq2p8/8v0r9mlp4kpe53tve0grauekhf9l52g6/1593102975000/07883268761297596834/00043245050220984211Z/1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF?e=download&nonce=h9hdtrtu9nafc&user=00043245050220984211Z&hash=i86gvqe903t0q93i8mgb1euo7pn28j19 [following]\n--2020-06-25 16:36:41-- https://doc-14-bo-docs.googleusercontent.com/docs/securesc/411qa4g4tdlvt7602v3qqn8dk58sq2p8/8v0r9mlp4kpe53tve0grauekhf9l52g6/1593102975000/07883268761297596834/00043245050220984211Z/1xOWj1UVgp6NKMT3HbPhBbtq2A4EDkghF?e=download&nonce=h9hdtrtu9nafc&user=00043245050220984211Z&hash=i86gvqe903t0q93i8mgb1euo7pn28j19\nConnecting to doc-14-bo-docs.googleusercontent.com (doc-14-bo-docs.googleusercontent.com)|172.217.212.132|:443... connected.\nHTTP request sent, awaiting response... 200 OK\nLength: unspecified [application/x-zip-compressed]\nSaving to: ‘selfie2anime.zip’\n\nselfie2anime.zip [ <=> ] 390.23M 129MB/s in 3.0s \n\n2020-06-25 16:36:45 (129 MB/s) - ‘selfie2anime.zip’ saved [409184099]\n\n"
],
[
"!unzip -q selfie2anime.zip",
"_____no_output_____"
]
],
[
[
"## Preparing the new dataset for UGATIT",
"_____no_output_____"
]
],
[
[
"from imutils import paths\n\ntrain_images = list(paths.list_images('train'))\nvalidation_images = list(paths.list_images('val'))\ntrain_images[:5], validation_images[:5]",
"_____no_output_____"
],
[
"domainB_images_train = list(paths.list_images('trainB'))\ndomainB_images_test = list(paths.list_images('testB'))\ndomainB_images_train[:5], domainB_images_test[:5]",
"_____no_output_____"
],
[
"from PIL import Image\n\nImage.open(train_images[0])",
"_____no_output_____"
],
[
"Image.open(domainB_images_train[0])",
"_____no_output_____"
]
],
[
[
"UGATIT needs the dataset to be present in the following format ([reference](https://github.com/taki0112/UGATIT/#usage)):\n\n```\n├── dataset\n └── YOUR_DATASET_NAME\n ├── trainA\n ├── xxx.jpg (name, format doesn't matter)\n ├── yyy.png\n └── ...\n ├── trainB\n ├── zzz.jpg\n ├── www.png\n └── ...\n ├── testA\n ├── aaa.jpg \n ├── bbb.png\n └── ...\n └── testB\n ├── ccc.jpg \n ├── ddd.png\n └── ...\n```",
"_____no_output_____"
]
],
[
[
"print(len(train_images), len(validation_images))",
"86744 10954\n"
],
[
"len(domainB_images_train), len(domainB_images_test)",
"_____no_output_____"
]
],
[
[
"Going with 10000 train and 5000 test images",
"_____no_output_____"
]
],
[
[
"!mkdir fairfaces\n!mkdir fairfaces/trainA\n!mkdir fairfaces/trainB\n!mkdir fairfaces/testA\n!mkdir fairfaces/testB",
"_____no_output_____"
],
[
"from tqdm.notebook import tqdm\nimport numpy as np\nimport shutil\nimport os\n\nnp.random.seed(666)",
"_____no_output_____"
],
[
"partial_train_images = np.random.choice(train_images, 10000)\npartial_validation_images = np.random.choice(validation_images, 5000)\nprint(len(partial_train_images), len(partial_validation_images))",
"10000 5000\n"
],
[
"partial_train_images[0].split('/')",
"_____no_output_____"
],
[
"def move_images(directory, list_image_path):\n for image_path in tqdm(list_image_path): \n image_filename = image_path.split('/')[1]\n new_image_path = os.path.join(directory, image_filename)\n shutil.copy2(image_path, new_image_path)\n\n print('Total images found at {} directory: {}'.format(directory, \n len(list(paths.list_images(directory)))\n ))",
"_____no_output_____"
],
[
"move_images('fairfaces/trainA', partial_train_images)\nmove_images('fairfaces/trainB', domainB_images_train)\nmove_images('fairfaces/testA', partial_validation_images)\nmove_images('fairfaces/testB', domainB_images_test)",
"_____no_output_____"
]
],
[
[
"Not sure why the number of images mismatches in certain cases. Need to investigate. But the training can begin. ",
"_____no_output_____"
]
],
[
[
"!apt-get install tree",
"Reading package lists... Done\nBuilding dependency tree \nReading state information... Done\nThe following package was automatically installed and is no longer required:\n libnvidia-common-440\nUse 'apt autoremove' to remove it.\nThe following NEW packages will be installed:\n tree\n0 upgraded, 1 newly installed, 0 to remove and 59 not upgraded.\nNeed to get 40.7 kB of archives.\nAfter this operation, 105 kB of additional disk space will be used.\nGet:1 http://archive.ubuntu.com/ubuntu bionic/universe amd64 tree amd64 1.7.0-5 [40.7 kB]\nFetched 40.7 kB in 0s (124 kB/s)\nSelecting previously unselected package tree.\n(Reading database ... 144328 files and directories currently installed.)\nPreparing to unpack .../tree_1.7.0-5_amd64.deb ...\nUnpacking tree (1.7.0-5) ...\nSetting up tree (1.7.0-5) ...\nProcessing triggers for man-db (2.8.3-2ubuntu0.1) ...\n"
],
[
"!tree --dirsfirst --filelimit 20 fairfaces",
"fairfaces\n├── testA [4002 entries exceeds filelimit, not opening dir]\n├── testB [100 entries exceeds filelimit, not opening dir]\n├── trainA [9428 entries exceeds filelimit, not opening dir]\n└── trainB [3400 entries exceeds filelimit, not opening dir]\n\n4 directories, 0 files\n"
]
],
[
[
"## Model training",
"_____no_output_____"
]
],
[
[
"!git clone https://github.com/taki0112/UGATIT/",
"Cloning into 'UGATIT'...\nremote: Enumerating objects: 171, done.\u001b[K\nremote: Total 171 (delta 0), reused 0 (delta 0), pack-reused 171\u001b[K\nReceiving objects: 100% (171/171), 5.68 MiB | 21.21 MiB/s, done.\nResolving deltas: 100% (89/89), done.\n"
],
[
"!mkdir dataset\n!cp -r /content/fairfaces dataset",
"_____no_output_____"
]
],
[
[
"According to [this issue comment](https://github.com/taki0112/UGATIT/issues/15#issuecomment-519034663), the training would take:\n\n> one v100 32GB GPU, 4 days",
"_____no_output_____"
]
],
[
[
"!mv dataset UGATIT",
"_____no_output_____"
],
[
"%cd UGATIT",
"/content/UGATIT\n"
],
[
"!python main.py --dataset fairfaces",
"\u001b[1;30;43mStreaming output truncated to the last 5000 lines.\u001b[0m\n2020-06-25 16:43:23.687928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad000 next 902 of size 1024\n2020-06-25 16:43:23.687948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad400 next 903 of size 1024\n2020-06-25 16:43:23.687969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad800 next 904 of size 1024\n2020-06-25 16:43:23.687990: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055adc00 next 905 of size 1024\n2020-06-25 16:43:23.688012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae000 next 906 of size 1024\n2020-06-25 16:43:23.688035: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae400 next 907 of size 256\n2020-06-25 16:43:23.688056: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae500 next 908 of size 1024\n2020-06-25 16:43:23.688076: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae900 next 909 of size 1024\n2020-06-25 16:43:23.688097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aed00 next 910 of size 256\n2020-06-25 16:43:23.688119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aee00 next 911 of size 1024\n2020-06-25 16:43:23.688156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af200 next 912 of size 256\n2020-06-25 16:43:23.688180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af300 next 913 of size 1024\n2020-06-25 16:43:23.688201: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af700 next 914 of size 512\n2020-06-25 16:43:23.688221: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af900 next 915 of size 256\n2020-06-25 16:43:23.688242: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055afa00 next 916 of size 32768\n2020-06-25 16:43:23.688264: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055b7a00 next 917 of size 32768\n2020-06-25 16:43:23.688286: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055bfa00 next 918 of size 4096\n2020-06-25 16:43:23.688306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055c0a00 next 919 of size 2359296\n2020-06-25 16:43:23.688327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805800a00 next 920 of size 2359296\n2020-06-25 16:43:23.688347: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40a00 next 921 of size 256\n2020-06-25 16:43:23.688368: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40b00 next 922 of size 512\n2020-06-25 16:43:23.688387: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40d00 next 923 of size 1024\n2020-06-25 16:43:23.688406: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41100 next 924 of size 1024\n2020-06-25 16:43:23.688426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41500 next 925 of size 256\n2020-06-25 16:43:23.688447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41600 next 926 of size 1024\n2020-06-25 16:43:23.688469: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41a00 next 927 of size 1024\n2020-06-25 16:43:23.688489: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41e00 next 928 of size 1024\n2020-06-25 16:43:23.688511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42200 next 929 of size 1024\n2020-06-25 16:43:23.688533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42600 next 930 of size 1024\n2020-06-25 16:43:23.688553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42a00 next 931 of size 1024\n2020-06-25 16:43:23.688573: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42e00 next 932 of size 256\n2020-06-25 16:43:23.688594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42f00 next 933 of size 1024\n2020-06-25 16:43:23.688616: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43300 next 934 of size 1024\n2020-06-25 16:43:23.688636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43700 next 935 of size 1024\n2020-06-25 16:43:23.688655: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43b00 next 936 of size 1024\n2020-06-25 16:43:23.688675: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43f00 next 937 of size 512\n2020-06-25 16:43:23.688696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44100 next 938 of size 1024\n2020-06-25 16:43:23.688717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44500 next 939 of size 1179648\n2020-06-25 16:43:23.688738: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805b64500 next 940 of size 1179648\n2020-06-25 16:43:23.688759: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805c84500 next 941 of size 33554432\n2020-06-25 16:43:23.688780: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x807c84500 next 942 of size 33554432\n2020-06-25 16:43:23.688803: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809c84500 next 943 of size 294912\n2020-06-25 16:43:23.688853: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809ccc500 next 944 of size 294912\n2020-06-25 16:43:23.688878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14500 next 945 of size 256\n2020-06-25 16:43:23.688899: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14600 next 946 of size 256\n2020-06-25 16:43:23.688919: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14700 next 947 of size 2097152\n2020-06-25 16:43:23.688939: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809f14700 next 948 of size 2097152\n2020-06-25 16:43:23.688958: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114700 next 949 of size 1024\n2020-06-25 16:43:23.688979: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114b00 next 950 of size 2048\n2020-06-25 16:43:23.689000: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115300 next 951 of size 1024\n2020-06-25 16:43:23.689020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115700 next 952 of size 8192\n2020-06-25 16:43:23.689041: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117700 next 953 of size 1024\n2020-06-25 16:43:23.689063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117b00 next 954 of size 2359296\n2020-06-25 16:43:23.689085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a357b00 next 955 of size 2359296\n2020-06-25 16:43:23.689105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a597b00 next 956 of size 1179648\n2020-06-25 16:43:23.689126: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a6b7b00 next 957 of size 1179648\n2020-06-25 16:43:23.689167: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a7d7b00 next 958 of size 2097152\n2020-06-25 16:43:23.689187: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a9d7b00 next 959 of size 2097152\n2020-06-25 16:43:23.689208: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80abd7b00 next 960 of size 2359296\n2020-06-25 16:43:23.689228: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ae17b00 next 961 of size 2359296\n2020-06-25 16:43:23.689250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b057b00 next 963 of size 8192\n2020-06-25 16:43:23.689270: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b059b00 next 964 of size 8192\n2020-06-25 16:43:23.689291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05bb00 next 965 of size 8192\n2020-06-25 16:43:23.689313: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05db00 next 966 of size 524288\n2020-06-25 16:43:23.689334: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b0ddb00 next 967 of size 524288\n2020-06-25 16:43:23.689355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15db00 next 968 of size 1024\n2020-06-25 16:43:23.689375: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15df00 next 969 of size 1024\n2020-06-25 16:43:23.689396: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15e300 next 970 of size 2359296\n2020-06-25 16:43:23.689417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e300 next 971 of size 1024\n2020-06-25 16:43:23.689436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e700 next 972 of size 1024\n2020-06-25 16:43:23.689455: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39eb00 next 974 of size 262144\n2020-06-25 16:43:23.689474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b3deb00 next 975 of size 2359296\n2020-06-25 16:43:23.689493: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b61eb00 next 976 of size 2359296\n2020-06-25 16:43:23.689514: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b85eb00 next 977 of size 2359296\n2020-06-25 16:43:23.689547: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ba9eb00 next 978 of size 2359296\n2020-06-25 16:43:23.689567: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdeb00 next 979 of size 2048\n2020-06-25 16:43:23.689588: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdf300 next 980 of size 2359296\n2020-06-25 16:43:23.689608: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bf1f300 next 981 of size 2359296\n2020-06-25 16:43:23.689653: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c15f300 next 982 of size 4096\n2020-06-25 16:43:23.689673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160300 next 983 of size 256\n2020-06-25 16:43:23.689708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160400 next 984 of size 1024\n2020-06-25 16:43:23.689742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160800 next 985 of size 32768\n2020-06-25 16:43:23.689775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c168800 next 986 of size 32768\n2020-06-25 16:43:23.689805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c170800 next 987 of size 2359296\n2020-06-25 16:43:23.689880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c3b0800 next 988 of size 2359296\n2020-06-25 16:43:23.689906: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c5f0800 next 989 of size 2359296\n2020-06-25 16:43:23.689942: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c830800 next 990 of size 2359296\n2020-06-25 16:43:23.689964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ca70800 next 991 of size 33554432\n2020-06-25 16:43:23.689988: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ea70800 next 992 of size 33554432\n2020-06-25 16:43:23.690012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810a70800 next 993 of size 2359296\n2020-06-25 16:43:23.690033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810cb0800 next 994 of size 2359296\n2020-06-25 16:43:23.690054: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810ef0800 next 995 of size 131072\n2020-06-25 16:43:23.690076: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f10800 next 996 of size 131072\n2020-06-25 16:43:23.690097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f30800 next 997 of size 2359296\n2020-06-25 16:43:23.690117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811170800 next 998 of size 2359296\n2020-06-25 16:43:23.690162: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8113b0800 next 1001 of size 2359296\n2020-06-25 16:43:23.690193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8115f0800 next 1002 of size 2359296\n2020-06-25 16:43:23.690217: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811830800 next 1003 of size 8388608\n2020-06-25 16:43:23.690253: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812030800 next 1004 of size 8388608\n2020-06-25 16:43:23.690289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830800 next 1005 of size 1024\n2020-06-25 16:43:23.690310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830c00 next 1006 of size 2359296\n2020-06-25 16:43:23.690330: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812a70c00 next 1007 of size 2359296\n2020-06-25 16:43:23.690351: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb0c00 next 1008 of size 1024\n2020-06-25 16:43:23.690371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1000 next 1009 of size 1024\n2020-06-25 16:43:23.690390: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1400 next 1010 of size 1024\n2020-06-25 16:43:23.690411: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1800 next 1011 of size 1024\n2020-06-25 16:43:23.690429: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1c00 next 1012 of size 262144\n2020-06-25 16:43:23.690449: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cf1c00 next 1013 of size 1179648\n2020-06-25 16:43:23.690469: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812e11c00 next 1014 of size 1179648\n2020-06-25 16:43:23.690502: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f31c00 next 1015 of size 262144\n2020-06-25 16:43:23.690523: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f71c00 next 1016 of size 262144\n2020-06-25 16:43:23.690545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812fb1c00 next 1017 of size 524288\n2020-06-25 16:43:23.690567: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813031c00 next 1018 of size 524288\n2020-06-25 16:43:23.690589: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8130b1c00 next 1019 of size 2359296\n2020-06-25 16:43:23.690610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8132f1c00 next 1020 of size 2359296\n2020-06-25 16:43:23.690630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813531c00 next 1021 of size 12288\n2020-06-25 16:43:23.690652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813534c00 next 1022 of size 12288\n2020-06-25 16:43:23.690673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813537c00 next 1023 of size 2048\n2020-06-25 16:43:23.690693: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813538400 next 1024 of size 1179648\n2020-06-25 16:43:23.690713: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813658400 next 1025 of size 1179648\n2020-06-25 16:43:23.690759: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778400 next 1026 of size 256\n2020-06-25 16:43:23.690779: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778500 next 1027 of size 1024\n2020-06-25 16:43:23.690800: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778900 next 1028 of size 1024\n2020-06-25 16:43:23.690850: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778d00 next 1029 of size 2359296\n2020-06-25 16:43:23.690888: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b8d00 next 1030 of size 1024\n2020-06-25 16:43:23.690911: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9100 next 1031 of size 1024\n2020-06-25 16:43:23.690934: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9500 next 1032 of size 37632\n2020-06-25 16:43:23.690955: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139c2800 next 1033 of size 37632\n2020-06-25 16:43:23.690977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139cbb00 next 1034 of size 524288\n2020-06-25 16:43:23.690999: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813a4bb00 next 1035 of size 524288\n2020-06-25 16:43:23.691019: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813acbb00 next 1036 of size 37632\n2020-06-25 16:43:23.691038: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ad4e00 next 1037 of size 37632\n2020-06-25 16:43:23.691058: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ade100 next 1038 of size 524288\n2020-06-25 16:43:23.691080: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813b5e100 next 1039 of size 524288\n2020-06-25 16:43:23.691101: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813bde100 next 1040 of size 262144\n2020-06-25 16:43:23.691123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c1e100 next 1041 of size 262144\n2020-06-25 16:43:23.691165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c5e100 next 1042 of size 2359296\n2020-06-25 16:43:23.691192: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813e9e100 next 1043 of size 2359296\n2020-06-25 16:43:23.691215: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8140de100 next 1044 of size 8388608\n2020-06-25 16:43:23.691237: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8148de100 next 1045 of size 8388608\n2020-06-25 16:43:23.691260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8150de100 next 1046 of size 262144\n2020-06-25 16:43:23.691295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81511e100 next 1047 of size 262144\n2020-06-25 16:43:23.691314: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81515e100 next 1048 of size 2359296\n2020-06-25 16:43:23.691335: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81539e100 next 1049 of size 2359296\n2020-06-25 16:43:23.691357: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8155de100 next 1050 of size 33554432\n2020-06-25 16:43:23.691379: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8175de100 next 1051 of size 33554432\n2020-06-25 16:43:23.691401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195de100 next 1052 of size 131072\n2020-06-25 16:43:23.691422: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe100 next 1053 of size 1024\n2020-06-25 16:43:23.691456: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe500 next 1054 of size 1024\n2020-06-25 16:43:23.691479: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe900 next 1055 of size 2097152\n2020-06-25 16:43:23.691501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fe900 next 1056 of size 1024\n2020-06-25 16:43:23.691522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fed00 next 1057 of size 131072\n2020-06-25 16:43:23.691543: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981ed00 next 1058 of size 1024\n2020-06-25 16:43:23.691563: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f100 next 1059 of size 1024\n2020-06-25 16:43:23.691582: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f500 next 1060 of size 2359296\n2020-06-25 16:43:23.691603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819a5f500 next 1061 of size 2359296\n2020-06-25 16:43:23.691624: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819c9f500 next 1062 of size 2359296\n2020-06-25 16:43:23.691646: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819edf500 next 1063 of size 2359296\n2020-06-25 16:43:23.691667: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a11f500 next 1064 of size 2359296\n2020-06-25 16:43:23.691687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a35f500 next 1065 of size 2359296\n2020-06-25 16:43:23.691710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a59f500 next 18446744073709551615 of size 158075648\n2020-06-25 16:43:23.691733: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4294967296\n2020-06-25 16:43:23.691756: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x823e60000 next 678 of size 1073741824\n2020-06-25 16:43:23.691778: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x863e60000 next 962 of size 1073741824\n2020-06-25 16:43:23.691799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8a3e60000 next 973 of size 1073741824\n2020-06-25 16:43:23.691847: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8e3e60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:23.691873: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2202261760\n2020-06-25 16:43:23.691895: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x923e60000 next 1000 of size 1073741824\n2020-06-25 16:43:23.691916: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x963e60000 next 1066 of size 134217728\n2020-06-25 16:43:23.691937: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be60000 next 1067 of size 12288\n2020-06-25 16:43:23.691958: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be63000 next 1068 of size 12288\n2020-06-25 16:43:23.691980: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be66000 next 1069 of size 33554432\n2020-06-25 16:43:23.692001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96de66000 next 1070 of size 33554432\n2020-06-25 16:43:23.692025: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe66000 next 1071 of size 12288\n2020-06-25 16:43:23.692046: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe69000 next 1072 of size 12288\n2020-06-25 16:43:23.692067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c000 next 1073 of size 2048\n2020-06-25 16:43:23.692089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c800 next 1074 of size 262144\n2020-06-25 16:43:23.692110: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feac800 next 1075 of size 262144\n2020-06-25 16:43:23.692144: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feec800 next 1076 of size 2359296\n2020-06-25 16:43:23.692174: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97012c800 next 1077 of size 2359296\n2020-06-25 16:43:23.692197: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97036c800 next 1078 of size 294912\n2020-06-25 16:43:23.692218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703b4800 next 1079 of size 294912\n2020-06-25 16:43:23.692241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703fc800 next 1080 of size 2097152\n2020-06-25 16:43:23.692264: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fc800 next 1081 of size 1024\n2020-06-25 16:43:23.692285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fcc00 next 1082 of size 1024\n2020-06-25 16:43:23.692306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fd000 next 1083 of size 2359296\n2020-06-25 16:43:23.692326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d000 next 1084 of size 1024\n2020-06-25 16:43:23.692348: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d400 next 1085 of size 2048\n2020-06-25 16:43:23.692368: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083dc00 next 1086 of size 294912\n2020-06-25 16:43:23.692388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970885c00 next 1087 of size 294912\n2020-06-25 16:43:23.692409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9708cdc00 next 1088 of size 294912\n2020-06-25 16:43:23.692430: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970915c00 next 1089 of size 294912\n2020-06-25 16:43:23.692451: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97095dc00 next 1090 of size 37632\n2020-06-25 16:43:23.692473: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970966f00 next 1091 of size 37632\n2020-06-25 16:43:23.692495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970970200 next 1092 of size 2359296\n2020-06-25 16:43:23.692518: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970bb0200 next 1093 of size 2359296\n2020-06-25 16:43:23.692552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df0200 next 1094 of size 8192\n2020-06-25 16:43:23.692596: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df2200 next 1095 of size 8192\n2020-06-25 16:43:23.692621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df4200 next 1096 of size 8192\n2020-06-25 16:43:23.692643: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df6200 next 1097 of size 2359296\n2020-06-25 16:43:23.692663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971036200 next 1098 of size 2359296\n2020-06-25 16:43:23.692699: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971276200 next 1099 of size 262144\n2020-06-25 16:43:23.692729: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712b6200 next 1100 of size 262144\n2020-06-25 16:43:23.692753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712f6200 next 1101 of size 2097152\n2020-06-25 16:43:23.692789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9714f6200 next 1102 of size 2097152\n2020-06-25 16:43:23.692829: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9716f6200 next 1103 of size 134217728\n2020-06-25 16:43:23.692862: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9796f6200 next 1104 of size 134217728\n2020-06-25 16:43:23.692885: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6200 next 1105 of size 512\n2020-06-25 16:43:23.692907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6400 next 1106 of size 512\n2020-06-25 16:43:23.692928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6600 next 1107 of size 1024\n2020-06-25 16:43:23.692948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6a00 next 1108 of size 2359296\n2020-06-25 16:43:23.692968: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981936a00 next 1109 of size 2359296\n2020-06-25 16:43:23.692991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981b76a00 next 1110 of size 8388608\n2020-06-25 16:43:23.693013: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376a00 next 1111 of size 1024\n2020-06-25 16:43:23.693034: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376e00 next 1112 of size 1024\n2020-06-25 16:43:23.693055: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982377200 next 1113 of size 12288\n2020-06-25 16:43:23.693077: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237a200 next 1114 of size 12288\n2020-06-25 16:43:23.693098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237d200 next 1115 of size 2097152\n2020-06-25 16:43:23.693120: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98257d200 next 1116 of size 2097152\n2020-06-25 16:43:23.693161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98277d200 next 1117 of size 8388608\n2020-06-25 16:43:23.693187: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982f7d200 next 1118 of size 8388608\n2020-06-25 16:43:23.693209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377d200 next 1119 of size 8192\n2020-06-25 16:43:23.693230: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377f200 next 1120 of size 8192\n2020-06-25 16:43:23.693251: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983781200 next 1121 of size 524288\n2020-06-25 16:43:23.693272: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983801200 next 1122 of size 524288\n2020-06-25 16:43:23.693294: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983881200 next 1123 of size 2359296\n2020-06-25 16:43:23.693315: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983ac1200 next 1124 of size 2359296\n2020-06-25 16:43:23.693337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983d01200 next 1125 of size 2359296\n2020-06-25 16:43:23.693360: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983f41200 next 1126 of size 2359296\n2020-06-25 16:43:23.693381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984181200 next 1127 of size 37632\n2020-06-25 16:43:23.693401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98418a500 next 1128 of size 37632\n2020-06-25 16:43:23.693422: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193800 next 1129 of size 1024\n2020-06-25 16:43:23.693443: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193c00 next 1130 of size 2048\n2020-06-25 16:43:23.693475: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984194400 next 1131 of size 2359296\n2020-06-25 16:43:23.693509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4400 next 1132 of size 1024\n2020-06-25 16:43:23.693530: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4800 next 1133 of size 2359296\n2020-06-25 16:43:23.693551: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984614800 next 1134 of size 2359296\n2020-06-25 16:43:23.693573: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984854800 next 1135 of size 2359296\n2020-06-25 16:43:23.693595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984a94800 next 1136 of size 2359296\n2020-06-25 16:43:23.693617: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984cd4800 next 1137 of size 2359296\n2020-06-25 16:43:23.693639: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984f14800 next 1138 of size 2359296\n2020-06-25 16:43:23.693660: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154800 next 1139 of size 1024\n2020-06-25 16:43:23.693680: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154c00 next 1140 of size 512\n2020-06-25 16:43:23.693701: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154e00 next 1141 of size 8192\n2020-06-25 16:43:23.693722: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985156e00 next 1142 of size 8192\n2020-06-25 16:43:23.693743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985158e00 next 1143 of size 1024\n2020-06-25 16:43:23.693763: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159200 next 1144 of size 2048\n2020-06-25 16:43:23.693784: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159a00 next 1145 of size 1024\n2020-06-25 16:43:23.693805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159e00 next 1146 of size 1024\n2020-06-25 16:43:23.693855: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98515a200 next 1147 of size 8388608\n2020-06-25 16:43:23.693879: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98595a200 next 1148 of size 524288\n2020-06-25 16:43:23.693903: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9859da200 next 1149 of size 524288\n2020-06-25 16:43:23.693925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985a5a200 next 1150 of size 2359296\n2020-06-25 16:43:23.693946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985c9a200 next 1151 of size 2359296\n2020-06-25 16:43:23.693967: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985eda200 next 1152 of size 2097152\n2020-06-25 16:43:23.693988: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9860da200 next 1153 of size 2097152\n2020-06-25 16:43:23.694010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9862da200 next 1154 of size 2359296\n2020-06-25 16:43:23.694029: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98651a200 next 1155 of size 2359296\n2020-06-25 16:43:23.694050: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a200 next 1156 of size 1024\n2020-06-25 16:43:23.694070: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a600 next 1157 of size 2359296\n2020-06-25 16:43:23.694091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98699a600 next 1158 of size 2359296\n2020-06-25 16:43:23.694112: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bda600 next 1159 of size 1024\n2020-06-25 16:43:23.694148: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaa00 next 1160 of size 256\n2020-06-25 16:43:23.694176: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdab00 next 1161 of size 256\n2020-06-25 16:43:23.694198: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdac00 next 1162 of size 256\n2020-06-25 16:43:23.694219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdad00 next 1163 of size 256\n2020-06-25 16:43:23.694240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdae00 next 1164 of size 256\n2020-06-25 16:43:23.694260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaf00 next 1165 of size 256\n2020-06-25 16:43:23.694280: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb000 next 1166 of size 256\n2020-06-25 16:43:23.694321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb100 next 1167 of size 256\n2020-06-25 16:43:23.694351: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb200 next 1168 of size 256\n2020-06-25 16:43:23.694373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb300 next 1169 of size 256\n2020-06-25 16:43:23.694395: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb400 next 1170 of size 256\n2020-06-25 16:43:23.694417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb500 next 1171 of size 256\n2020-06-25 16:43:23.694439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb600 next 1172 of size 256\n2020-06-25 16:43:23.694460: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb700 next 1173 of size 256\n2020-06-25 16:43:23.694497: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb800 next 1174 of size 256\n2020-06-25 16:43:23.694520: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb900 next 1175 of size 256\n2020-06-25 16:43:23.694539: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdba00 next 1176 of size 256\n2020-06-25 16:43:23.694559: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbb00 next 1177 of size 256\n2020-06-25 16:43:23.694580: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbc00 next 1178 of size 256\n2020-06-25 16:43:23.694600: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbd00 next 1179 of size 256\n2020-06-25 16:43:23.694621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbe00 next 1180 of size 256\n2020-06-25 16:43:23.694642: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbf00 next 1181 of size 256\n2020-06-25 16:43:23.694664: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc000 next 1182 of size 256\n2020-06-25 16:43:23.694685: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc100 next 1183 of size 256\n2020-06-25 16:43:23.694706: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc200 next 1184 of size 256\n2020-06-25 16:43:23.694753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc300 next 1185 of size 256\n2020-06-25 16:43:23.694789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc400 next 1186 of size 256\n2020-06-25 16:43:23.694832: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc500 next 1187 of size 256\n2020-06-25 16:43:23.694862: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc600 next 1188 of size 256\n2020-06-25 16:43:23.694885: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc700 next 1189 of size 256\n2020-06-25 16:43:23.694907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc800 next 1190 of size 256\n2020-06-25 16:43:23.694928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc900 next 1191 of size 256\n2020-06-25 16:43:23.694949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdca00 next 1192 of size 256\n2020-06-25 16:43:23.694971: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcb00 next 1193 of size 256\n2020-06-25 16:43:23.694992: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcc00 next 1194 of size 256\n2020-06-25 16:43:23.695014: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcd00 next 1195 of size 256\n2020-06-25 16:43:23.695035: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdce00 next 1196 of size 256\n2020-06-25 16:43:23.695056: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcf00 next 1197 of size 256\n2020-06-25 16:43:23.695078: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd000 next 1198 of size 256\n2020-06-25 16:43:23.695098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd100 next 1199 of size 256\n2020-06-25 16:43:23.695117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd200 next 1200 of size 256\n2020-06-25 16:43:23.695155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd300 next 1201 of size 256\n2020-06-25 16:43:23.695183: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd400 next 1202 of size 256\n2020-06-25 16:43:23.695205: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd500 next 1203 of size 256\n2020-06-25 16:43:23.695226: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd600 next 1204 of size 256\n2020-06-25 16:43:23.695247: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd700 next 1205 of size 256\n2020-06-25 16:43:23.695270: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd800 next 1206 of size 256\n2020-06-25 16:43:23.695291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd900 next 1207 of size 256\n2020-06-25 16:43:23.695312: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdda00 next 1208 of size 256\n2020-06-25 16:43:23.695334: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddb00 next 1209 of size 256\n2020-06-25 16:43:23.695356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddc00 next 1210 of size 256\n2020-06-25 16:43:23.695376: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddd00 next 1211 of size 256\n2020-06-25 16:43:23.695396: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdde00 next 1212 of size 256\n2020-06-25 16:43:23.695417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddf00 next 1213 of size 256\n2020-06-25 16:43:23.695438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde000 next 1214 of size 256\n2020-06-25 16:43:23.695458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde100 next 1215 of size 256\n2020-06-25 16:43:23.695480: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde200 next 1216 of size 256\n2020-06-25 16:43:23.695502: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde300 next 1217 of size 256\n2020-06-25 16:43:23.695525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde400 next 1218 of size 256\n2020-06-25 16:43:23.695546: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde500 next 1219 of size 256\n2020-06-25 16:43:23.695567: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde600 next 1220 of size 256\n2020-06-25 16:43:23.695588: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde700 next 1221 of size 256\n2020-06-25 16:43:23.695610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde800 next 1222 of size 256\n2020-06-25 16:43:23.695630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde900 next 1223 of size 256\n2020-06-25 16:43:23.695650: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdea00 next 1224 of size 256\n2020-06-25 16:43:23.695687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdeb00 next 1225 of size 256\n2020-06-25 16:43:23.695707: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdec00 next 1226 of size 256\n2020-06-25 16:43:23.695728: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bded00 next 1227 of size 256\n2020-06-25 16:43:23.695747: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdee00 next 1228 of size 256\n2020-06-25 16:43:23.695768: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdef00 next 1229 of size 256\n2020-06-25 16:43:23.695789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf000 next 1230 of size 256\n2020-06-25 16:43:23.695830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf100 next 1231 of size 256\n2020-06-25 16:43:23.695860: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf200 next 1232 of size 4096\n2020-06-25 16:43:23.695881: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0200 next 1233 of size 256\n2020-06-25 16:43:23.695902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0300 next 1234 of size 4096\n2020-06-25 16:43:23.695923: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1300 next 1235 of size 256\n2020-06-25 16:43:23.695945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1400 next 1236 of size 1024\n2020-06-25 16:43:23.695964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1800 next 1237 of size 256\n2020-06-25 16:43:23.695985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1900 next 1238 of size 1024\n2020-06-25 16:43:23.696005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1d00 next 1239 of size 512\n2020-06-25 16:43:23.696026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1f00 next 1240 of size 256\n2020-06-25 16:43:23.696047: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2000 next 1241 of size 1024\n2020-06-25 16:43:23.696067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2400 next 1242 of size 1024\n2020-06-25 16:43:23.696089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2800 next 1243 of size 1024\n2020-06-25 16:43:23.696109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2c00 next 1358 of size 256\n2020-06-25 16:43:23.696402: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2d00 next 1375 of size 256\n2020-06-25 16:43:23.696447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2e00 next 1380 of size 256\n2020-06-25 16:43:23.696475: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2f00 next 1244 of size 256\n2020-06-25 16:43:23.696499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3000 next 1245 of size 1024\n2020-06-25 16:43:23.696516: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3400 next 1246 of size 1024\n2020-06-25 16:43:23.696536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3800 next 1247 of size 1024\n2020-06-25 16:43:23.696555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3c00 next 1248 of size 256\n2020-06-25 16:43:23.696573: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3d00 next 1249 of size 256\n2020-06-25 16:43:23.696590: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3e00 next 1250 of size 256\n2020-06-25 16:43:23.696606: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3f00 next 1251 of size 256\n2020-06-25 16:43:23.696623: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be4000 next 1252 of size 8192\n2020-06-25 16:43:23.696641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6000 next 1253 of size 256\n2020-06-25 16:43:23.696660: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6100 next 1254 of size 256\n2020-06-25 16:43:23.696677: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6200 next 1255 of size 256\n2020-06-25 16:43:23.696693: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6300 next 1256 of size 256\n2020-06-25 16:43:23.696710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6400 next 1257 of size 2048\n2020-06-25 16:43:23.696726: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6c00 next 1258 of size 256\n2020-06-25 16:43:23.696743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6d00 next 1259 of size 256\n2020-06-25 16:43:23.696759: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6e00 next 1260 of size 256\n2020-06-25 16:43:23.696776: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6f00 next 1261 of size 256\n2020-06-25 16:43:23.696792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be7000 next 1262 of size 8192\n2020-06-25 16:43:23.696822: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9000 next 1263 of size 256\n2020-06-25 16:43:23.696845: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9100 next 1264 of size 256\n2020-06-25 16:43:23.696863: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9200 next 1265 of size 256\n2020-06-25 16:43:23.696880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9300 next 1266 of size 2048\n2020-06-25 16:43:23.696897: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9b00 next 1267 of size 256\n2020-06-25 16:43:23.696913: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9c00 next 1268 of size 256\n2020-06-25 16:43:23.696929: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9d00 next 1269 of size 2048\n2020-06-25 16:43:23.696945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea500 next 1270 of size 256\n2020-06-25 16:43:23.696961: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea600 next 1271 of size 2048\n2020-06-25 16:43:23.696977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beae00 next 1272 of size 256\n2020-06-25 16:43:23.696994: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beaf00 next 1273 of size 256\n2020-06-25 16:43:23.697010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb000 next 1274 of size 256\n2020-06-25 16:43:23.697026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb100 next 1275 of size 256\n2020-06-25 16:43:23.697042: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb200 next 1276 of size 256\n2020-06-25 16:43:23.697058: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb300 next 1277 of size 256\n2020-06-25 16:43:23.697074: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb400 next 1278 of size 256\n2020-06-25 16:43:23.697090: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb500 next 1279 of size 1024\n2020-06-25 16:43:23.697105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb900 next 1280 of size 1024\n2020-06-25 16:43:23.697122: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bebd00 next 1281 of size 1024\n2020-06-25 16:43:23.697147: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec100 next 1282 of size 1024\n2020-06-25 16:43:23.697164: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec500 next 1283 of size 512\n2020-06-25 16:43:23.697180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec700 next 1405 of size 256\n2020-06-25 16:43:23.697196: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bec800 next 1284 of size 768\n2020-06-25 16:43:23.697212: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becb00 next 1285 of size 1024\n2020-06-25 16:43:23.697229: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becf00 next 1286 of size 1024\n2020-06-25 16:43:23.697245: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed300 next 1287 of size 1024\n2020-06-25 16:43:23.697260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed700 next 1288 of size 1024\n2020-06-25 16:43:23.697276: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedb00 next 1289 of size 256\n2020-06-25 16:43:23.697292: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedc00 next 1290 of size 256\n2020-06-25 16:43:23.697307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedd00 next 1291 of size 256\n2020-06-25 16:43:23.697323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bede00 next 1292 of size 256\n2020-06-25 16:43:23.697339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedf00 next 1293 of size 256\n2020-06-25 16:43:23.697355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bee000 next 1294 of size 256\n2020-06-25 16:43:23.697370: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bee100 next 1295 of size 8192\n2020-06-25 16:43:23.697386: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf0100 next 1296 of size 8192\n2020-06-25 16:43:23.697402: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2100 next 1297 of size 256\n2020-06-25 16:43:23.697418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2200 next 1298 of size 256\n2020-06-25 16:43:23.697433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2300 next 1299 of size 256\n2020-06-25 16:43:23.697450: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2400 next 1300 of size 33554432\n2020-06-25 16:43:23.697466: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bf2400 next 1301 of size 32768\n2020-06-25 16:43:23.697482: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bfa400 next 1302 of size 524288\n2020-06-25 16:43:23.697498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7a400 next 1303 of size 4096\n2020-06-25 16:43:23.697514: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7b400 next 1304 of size 12288\n2020-06-25 16:43:23.697529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e400 next 1305 of size 256\n2020-06-25 16:43:23.697545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e500 next 1306 of size 524288\n2020-06-25 16:43:23.697561: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cfe500 next 1307 of size 4096\n2020-06-25 16:43:23.697577: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cff500 next 1308 of size 32768\n2020-06-25 16:43:23.697592: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d07500 next 1309 of size 32768\n2020-06-25 16:43:23.697619: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d0f500 next 1310 of size 8388608\n2020-06-25 16:43:23.697647: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98950f500 next 1311 of size 16384\n2020-06-25 16:43:23.697673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989513500 next 1312 of size 131072\n2020-06-25 16:43:23.697758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989533500 next 1313 of size 131072\n2020-06-25 16:43:23.697794: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989553500 next 1314 of size 524288\n2020-06-25 16:43:23.697826: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d3500 next 1315 of size 4096\n2020-06-25 16:43:23.697849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d4500 next 1316 of size 8388608\n2020-06-25 16:43:23.697866: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd4500 next 1317 of size 16384\n2020-06-25 16:43:23.697882: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd8500 next 1318 of size 134217728\n2020-06-25 16:43:23.697899: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dd8500 next 1319 of size 65536\n2020-06-25 16:43:23.697915: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991de8500 next 1320 of size 8192\n2020-06-25 16:43:23.697931: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dea500 next 1321 of size 12288\n2020-06-25 16:43:23.697946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded500 next 1322 of size 256\n2020-06-25 16:43:23.697962: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded600 next 1323 of size 2097152\n2020-06-25 16:43:23.697978: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fed600 next 1324 of size 8192\n2020-06-25 16:43:23.697993: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fef600 next 1325 of size 2097152\n2020-06-25 16:43:23.698009: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921ef600 next 1326 of size 8192\n2020-06-25 16:43:23.698024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921f1600 next 1327 of size 2097152\n2020-06-25 16:43:23.698040: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f1600 next 1328 of size 8192\n2020-06-25 16:43:23.698056: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3600 next 1389 of size 256\n2020-06-25 16:43:23.698071: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3700 next 1392 of size 256\n2020-06-25 16:43:23.698086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3800 next 1394 of size 256\n2020-06-25 16:43:23.698102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3900 next 1398 of size 1024\n2020-06-25 16:43:23.698117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9923f3d00 next 1330 of size 2304\n2020-06-25 16:43:23.698140: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f4600 next 1331 of size 32768\n2020-06-25 16:43:23.698182: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923fc600 next 1332 of size 32768\n2020-06-25 16:43:23.698211: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992404600 next 1333 of size 12288\n2020-06-25 16:43:23.698226: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407600 next 1334 of size 256\n2020-06-25 16:43:23.698244: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407700 next 1335 of size 12288\n2020-06-25 16:43:23.698260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a700 next 1336 of size 256\n2020-06-25 16:43:23.698275: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a800 next 1337 of size 8388608\n2020-06-25 16:43:23.698291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0a800 next 1338 of size 16384\n2020-06-25 16:43:23.698306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0e800 next 1339 of size 2097152\n2020-06-25 16:43:23.698322: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e0e800 next 1340 of size 8192\n2020-06-25 16:43:23.698337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e10800 next 1341 of size 524288\n2020-06-25 16:43:23.698353: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e90800 next 1342 of size 4096\n2020-06-25 16:43:23.698369: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e91800 next 1343 of size 131072\n2020-06-25 16:43:23.698385: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992eb1800 next 1344 of size 131072\n2020-06-25 16:43:23.698401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992ed1800 next 1345 of size 33554432\n2020-06-25 16:43:23.698416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994ed1800 next 1346 of size 32768\n2020-06-25 16:43:23.698433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x994ed9800 next 1347 of size 8192\n2020-06-25 16:43:23.698449: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994edb800 next 1348 of size 8388608\n2020-06-25 16:43:23.698464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956db800 next 1349 of size 16384\n2020-06-25 16:43:23.698480: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956df800 next 1350 of size 134217728\n2020-06-25 16:43:23.698509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6df800 next 1351 of size 65536\n2020-06-25 16:43:23.698550: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6ef800 next 1352 of size 33554432\n2020-06-25 16:43:23.698566: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6ef800 next 1353 of size 32768\n2020-06-25 16:43:23.698582: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7800 next 1354 of size 1024\n2020-06-25 16:43:23.698598: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7c00 next 1355 of size 524288\n2020-06-25 16:43:23.698613: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f777c00 next 1356 of size 4096\n2020-06-25 16:43:23.698629: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f778c00 next 1357 of size 12288\n2020-06-25 16:43:23.698646: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f77bc00 next 1359 of size 524288\n2020-06-25 16:43:23.698663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fbc00 next 1360 of size 4096\n2020-06-25 16:43:23.698680: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fcc00 next 1361 of size 8192\n2020-06-25 16:43:23.698696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fec00 next 1362 of size 2097152\n2020-06-25 16:43:23.698712: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f9fec00 next 1363 of size 32768\n2020-06-25 16:43:23.698728: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa06c00 next 1364 of size 32768\n2020-06-25 16:43:23.698744: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa0ec00 next 1365 of size 8388608\n2020-06-25 16:43:23.698760: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a020ec00 next 1366 of size 16384\n2020-06-25 16:43:23.698776: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0212c00 next 1367 of size 2048\n2020-06-25 16:43:23.698792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0213400 next 1368 of size 131072\n2020-06-25 16:43:23.698981: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0233400 next 1369 of size 131072\n2020-06-25 16:43:23.699004: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0253400 next 1370 of size 524288\n2020-06-25 16:43:23.699022: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3400 next 1371 of size 4096\n2020-06-25 16:43:23.699040: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d4400 next 1372 of size 8388608\n2020-06-25 16:43:23.699057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ad4400 next 1373 of size 16384\n2020-06-25 16:43:23.699073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ad8400 next 1381 of size 65536\n2020-06-25 16:43:23.699090: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ae8400 next 1382 of size 12288\n2020-06-25 16:43:23.699107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0aeb400 next 1376 of size 2294016\n2020-06-25 16:43:23.699124: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0d1b500 next 1377 of size 798976\n2020-06-25 16:43:23.699150: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0dde600 next 1378 of size 798976\n2020-06-25 16:43:23.796773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ea1700 next 1379 of size 4194304\n2020-06-25 16:43:23.796865: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a12a1700 next 1374 of size 4194304\n2020-06-25 16:43:23.796898: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1700 next 1383 of size 2048\n2020-06-25 16:43:23.796921: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1f00 next 1384 of size 2097152\n2020-06-25 16:43:23.796941: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a1f00 next 1385 of size 8192\n2020-06-25 16:43:23.796962: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a3f00 next 1386 of size 2097152\n2020-06-25 16:43:23.796982: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa3f00 next 1387 of size 8192\n2020-06-25 16:43:23.797000: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa5f00 next 1388 of size 33554432\n2020-06-25 16:43:23.797018: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aa5f00 next 1329 of size 32768\n2020-06-25 16:43:23.797035: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aadf00 next 1390 of size 32768\n2020-06-25 16:43:23.797053: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab5f00 next 1391 of size 12288\n2020-06-25 16:43:23.797071: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab8f00 next 1393 of size 12288\n2020-06-25 16:43:23.797090: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3abbf00 next 1395 of size 2097152\n2020-06-25 16:43:23.797103: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3cbbf00 next 1396 of size 8388608\n2020-06-25 16:43:23.797135: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bbf00 next 1397 of size 16384\n2020-06-25 16:43:23.797156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bff00 next 1399 of size 2097152\n2020-06-25 16:43:23.797193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46bff00 next 1400 of size 8192\n2020-06-25 16:43:23.797221: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46c1f00 next 1401 of size 524288\n2020-06-25 16:43:23.797243: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4741f00 next 1402 of size 4096\n2020-06-25 16:43:23.797264: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4742f00 next 1403 of size 131072\n2020-06-25 16:43:23.797284: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4762f00 next 1404 of size 131072\n2020-06-25 16:43:23.797306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4782f00 next 18446744073709551615 of size 45197824\n2020-06-25 16:43:23.797325: I tensorflow/core/common_runtime/bfc_allocator.cc:914] Summary of in-use Chunks by size: \n2020-06-25 16:43:23.797354: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 354 Chunks of size 256 totalling 88.5KiB\n2020-06-25 16:43:23.797381: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 82 Chunks of size 512 totalling 41.0KiB\n2020-06-25 16:43:23.797424: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 464 Chunks of size 1024 totalling 464.0KiB\n2020-06-25 16:43:23.797448: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 1280 totalling 1.2KiB\n2020-06-25 16:43:23.797471: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 42 Chunks of size 2048 totalling 84.0KiB\n2020-06-25 16:43:23.797494: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 20 Chunks of size 4096 totalling 80.0KiB\n2020-06-25 16:43:23.797518: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 39 Chunks of size 8192 totalling 312.0KiB\n2020-06-25 16:43:23.797552: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 12288 totalling 288.0KiB\n2020-06-25 16:43:23.797574: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 7 Chunks of size 16384 totalling 112.0KiB\n2020-06-25 16:43:23.797596: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 32768 totalling 608.0KiB\n2020-06-25 16:43:23.797618: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 37632 totalling 588.0KiB\n2020-06-25 16:43:23.797640: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 3 Chunks of size 65536 totalling 192.0KiB\n2020-06-25 16:43:23.797663: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 131072 totalling 2.00MiB\n2020-06-25 16:43:23.797683: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 262144 totalling 6.00MiB\n2020-06-25 16:43:23.797703: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 15 Chunks of size 294912 totalling 4.22MiB\n2020-06-25 16:43:23.797740: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 447232 totalling 436.8KiB\n2020-06-25 16:43:23.797763: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 32 Chunks of size 524288 totalling 16.00MiB\n2020-06-25 16:43:23.797784: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 2 Chunks of size 798976 totalling 1.52MiB\n2020-06-25 16:43:23.797807: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 1179648 totalling 18.00MiB\n2020-06-25 16:43:23.797863: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 33 Chunks of size 2097152 totalling 66.00MiB\n2020-06-25 16:43:23.797888: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 2294016 totalling 2.19MiB\n2020-06-25 16:43:23.797943: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 122 Chunks of size 2359296 totalling 274.50MiB\n2020-06-25 16:43:23.797974: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3070464 totalling 2.93MiB\n2020-06-25 16:43:23.797998: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3145728 totalling 3.00MiB\n2020-06-25 16:43:23.798021: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3266560 totalling 3.12MiB\n2020-06-25 16:43:23.798042: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3400960 totalling 3.24MiB\n2020-06-25 16:43:23.798064: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 4 Chunks of size 4194304 totalling 16.00MiB\n2020-06-25 16:43:23.798086: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 23 Chunks of size 8388608 totalling 184.00MiB\n2020-06-25 16:43:23.798111: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 33554432 totalling 608.00MiB\n2020-06-25 16:43:23.798135: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 45197824 totalling 43.10MiB\n2020-06-25 16:43:23.798160: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 56033280 totalling 53.44MiB\n2020-06-25 16:43:23.798209: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 9 Chunks of size 134217728 totalling 1.12GiB\n2020-06-25 16:43:23.798239: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 158075648 totalling 150.75MiB\n2020-06-25 16:43:23.798264: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 8 Chunks of size 1073741824 totalling 8.00GiB\n2020-06-25 16:43:23.798288: I tensorflow/core/common_runtime/bfc_allocator.cc:921] Sum Total of in-use chunks: 10.55GiB\n2020-06-25 16:43:23.798320: I tensorflow/core/common_runtime/bfc_allocator.cc:923] total_region_allocated_bytes_: 11330115840 memory_limit_: 11330115994 available bytes: 154 curr_region_allocation_bytes_: 17179869184\n2020-06-25 16:43:23.798359: I tensorflow/core/common_runtime/bfc_allocator.cc:929] Stats: \nLimit: 11330115994\nInUse: 11330104576\nMaxInUse: 11330112768\nNumAllocs: 1643\nMaxAllocSize: 1073741824\n\n2020-06-25 16:43:23.798475: W tensorflow/core/common_runtime/bfc_allocator.cc:424] ****************************************************************************************************\n2020-06-25 16:43:23.798545: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at cwise_ops_common.h:259 : Resource exhausted: OOM when allocating tensor with shape[1,4096] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc\n2020-06-25 16:43:33.798799: W tensorflow/core/common_runtime/bfc_allocator.cc:419] Allocator (GPU_0_bfc) ran out of memory trying to allocate 128.00MiB (rounded to 134217728). Current allocation summary follows.\n2020-06-25 16:43:33.799001: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (256): \tTotal Chunks: 354, Chunks in use: 354. 88.5KiB allocated for chunks. 88.5KiB in use in bin. 23.6KiB client-requested in use in bin.\n2020-06-25 16:43:33.799038: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (512): \tTotal Chunks: 83, Chunks in use: 82. 41.8KiB allocated for chunks. 41.0KiB in use in bin. 41.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799063: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (1024): \tTotal Chunks: 465, Chunks in use: 465. 465.2KiB allocated for chunks. 465.2KiB in use in bin. 465.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799086: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (2048): \tTotal Chunks: 43, Chunks in use: 42. 86.2KiB allocated for chunks. 84.0KiB in use in bin. 84.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799108: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (4096): \tTotal Chunks: 20, Chunks in use: 20. 80.0KiB allocated for chunks. 80.0KiB in use in bin. 80.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799129: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (8192): \tTotal Chunks: 64, Chunks in use: 63. 608.0KiB allocated for chunks. 600.0KiB in use in bin. 600.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799163: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (16384): \tTotal Chunks: 7, Chunks in use: 7. 112.0KiB allocated for chunks. 112.0KiB in use in bin. 112.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799195: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (32768): \tTotal Chunks: 35, Chunks in use: 35. 1.17MiB allocated for chunks. 1.17MiB in use in bin. 1.17MiB client-requested in use in bin.\n2020-06-25 16:43:33.799218: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (65536): \tTotal Chunks: 3, Chunks in use: 3. 192.0KiB allocated for chunks. 192.0KiB in use in bin. 192.0KiB client-requested in use in bin.\n2020-06-25 16:43:33.799239: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (131072): \tTotal Chunks: 16, Chunks in use: 16. 2.00MiB allocated for chunks. 2.00MiB in use in bin. 2.00MiB client-requested in use in bin.\n2020-06-25 16:43:33.799259: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (262144): \tTotal Chunks: 40, Chunks in use: 40. 10.64MiB allocated for chunks. 10.64MiB in use in bin. 10.50MiB client-requested in use in bin.\n2020-06-25 16:43:33.799280: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (524288): \tTotal Chunks: 34, Chunks in use: 34. 17.52MiB allocated for chunks. 17.52MiB in use in bin. 17.52MiB client-requested in use in bin.\n2020-06-25 16:43:33.799300: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (1048576): \tTotal Chunks: 16, Chunks in use: 16. 18.00MiB allocated for chunks. 18.00MiB in use in bin. 18.00MiB client-requested in use in bin.\n2020-06-25 16:43:33.799322: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (2097152): \tTotal Chunks: 160, Chunks in use: 160. 354.97MiB allocated for chunks. 354.97MiB in use in bin. 351.50MiB client-requested in use in bin.\n2020-06-25 16:43:33.799343: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (4194304): \tTotal Chunks: 4, Chunks in use: 4. 16.00MiB allocated for chunks. 16.00MiB in use in bin. 12.50MiB client-requested in use in bin.\n2020-06-25 16:43:33.799364: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (8388608): \tTotal Chunks: 23, Chunks in use: 23. 184.00MiB allocated for chunks. 184.00MiB in use in bin. 184.00MiB client-requested in use in bin.\n2020-06-25 16:43:33.799383: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (16777216): \tTotal Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.\n2020-06-25 16:43:33.799404: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (33554432): \tTotal Chunks: 21, Chunks in use: 21. 704.54MiB allocated for chunks. 704.54MiB in use in bin. 672.00MiB client-requested in use in bin.\n2020-06-25 16:43:33.799424: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (67108864): \tTotal Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.\n2020-06-25 16:43:33.799455: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (134217728): \tTotal Chunks: 10, Chunks in use: 10. 1.27GiB allocated for chunks. 1.27GiB in use in bin. 1.25GiB client-requested in use in bin.\n2020-06-25 16:43:33.799476: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (268435456): \tTotal Chunks: 8, Chunks in use: 8. 8.00GiB allocated for chunks. 8.00GiB in use in bin. 8.00GiB client-requested in use in bin.\n2020-06-25 16:43:33.799496: I tensorflow/core/common_runtime/bfc_allocator.cc:885] Bin for 128.00MiB was 128.00MiB, Chunk State: \n2020-06-25 16:43:33.799515: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1048576\n2020-06-25 16:43:33.799534: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60000 next 1 of size 2048\n2020-06-25 16:43:33.799552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60800 next 2 of size 256\n2020-06-25 16:43:33.799570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60900 next 3 of size 1024\n2020-06-25 16:43:33.799586: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60d00 next 4 of size 1024\n2020-06-25 16:43:33.799603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61100 next 5 of size 256\n2020-06-25 16:43:33.799645: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61200 next 6 of size 256\n2020-06-25 16:43:33.799673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61300 next 7 of size 2048\n2020-06-25 16:43:33.799691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61b00 next 8 of size 256\n2020-06-25 16:43:33.799704: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61c00 next 9 of size 256\n2020-06-25 16:43:33.799719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61d00 next 10 of size 256\n2020-06-25 16:43:33.799735: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61e00 next 11 of size 1024\n2020-06-25 16:43:33.799752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62200 next 12 of size 256\n2020-06-25 16:43:33.799768: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62300 next 13 of size 1024\n2020-06-25 16:43:33.799784: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62700 next 14 of size 256\n2020-06-25 16:43:33.799800: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62800 next 15 of size 512\n2020-06-25 16:43:33.799840: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62a00 next 16 of size 256\n2020-06-25 16:43:33.799861: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62b00 next 17 of size 512\n2020-06-25 16:43:33.799878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62d00 next 18 of size 512\n2020-06-25 16:43:33.799894: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62f00 next 19 of size 256\n2020-06-25 16:43:33.799909: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63000 next 20 of size 1024\n2020-06-25 16:43:33.799937: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63400 next 21 of size 256\n2020-06-25 16:43:33.799965: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63500 next 22 of size 512\n2020-06-25 16:43:33.799994: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63700 next 23 of size 1024\n2020-06-25 16:43:33.800010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63b00 next 24 of size 1024\n2020-06-25 16:43:33.800026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63f00 next 25 of size 512\n2020-06-25 16:43:33.800043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64100 next 26 of size 256\n2020-06-25 16:43:33.800060: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64200 next 27 of size 512\n2020-06-25 16:43:33.800076: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64400 next 28 of size 256\n2020-06-25 16:43:33.800091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64500 next 29 of size 256\n2020-06-25 16:43:33.800107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64600 next 30 of size 1024\n2020-06-25 16:43:33.800123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64a00 next 31 of size 512\n2020-06-25 16:43:33.800138: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64c00 next 32 of size 1024\n2020-06-25 16:43:33.800168: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65000 next 33 of size 1024\n2020-06-25 16:43:33.800195: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65400 next 34 of size 256\n2020-06-25 16:43:33.800213: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65500 next 35 of size 256\n2020-06-25 16:43:33.800228: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65600 next 36 of size 1024\n2020-06-25 16:43:33.800244: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65a00 next 37 of size 1024\n2020-06-25 16:43:33.800260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65e00 next 38 of size 1024\n2020-06-25 16:43:33.800278: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66200 next 39 of size 256\n2020-06-25 16:43:33.800294: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66300 next 40 of size 256\n2020-06-25 16:43:33.800311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66400 next 41 of size 256\n2020-06-25 16:43:33.800327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66500 next 42 of size 1024\n2020-06-25 16:43:33.800342: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66900 next 43 of size 256\n2020-06-25 16:43:33.800357: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66a00 next 44 of size 512\n2020-06-25 16:43:33.800373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66c00 next 45 of size 1024\n2020-06-25 16:43:33.800388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67000 next 46 of size 1024\n2020-06-25 16:43:33.800403: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67400 next 47 of size 256\n2020-06-25 16:43:33.800418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67500 next 48 of size 256\n2020-06-25 16:43:33.800434: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67600 next 49 of size 256\n2020-06-25 16:43:33.800449: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67700 next 50 of size 1024\n2020-06-25 16:43:33.800464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67b00 next 51 of size 1024\n2020-06-25 16:43:33.800479: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67f00 next 52 of size 1024\n2020-06-25 16:43:33.800495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68300 next 53 of size 2048\n2020-06-25 16:43:33.800510: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68b00 next 54 of size 256\n2020-06-25 16:43:33.800525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68c00 next 55 of size 256\n2020-06-25 16:43:33.800540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68d00 next 56 of size 1024\n2020-06-25 16:43:33.800556: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69100 next 57 of size 1024\n2020-06-25 16:43:33.800583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69500 next 58 of size 1024\n2020-06-25 16:43:33.800598: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69900 next 59 of size 1024\n2020-06-25 16:43:33.800614: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69d00 next 60 of size 256\n2020-06-25 16:43:33.800630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69e00 next 61 of size 256\n2020-06-25 16:43:33.800646: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69f00 next 62 of size 256\n2020-06-25 16:43:33.800662: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a000 next 63 of size 1024\n2020-06-25 16:43:33.800679: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a400 next 64 of size 1024\n2020-06-25 16:43:33.800693: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a800 next 65 of size 1024\n2020-06-25 16:43:33.800709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ac00 next 66 of size 256\n2020-06-25 16:43:33.800725: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ad00 next 67 of size 256\n2020-06-25 16:43:33.800741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ae00 next 68 of size 256\n2020-06-25 16:43:33.800757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6af00 next 69 of size 1024\n2020-06-25 16:43:33.800773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6b300 next 70 of size 1024\n2020-06-25 16:43:33.800789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6b700 next 71 of size 1024\n2020-06-25 16:43:33.800805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6bb00 next 72 of size 2048\n2020-06-25 16:43:33.800838: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c300 next 73 of size 512\n2020-06-25 16:43:33.800855: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c500 next 74 of size 256\n2020-06-25 16:43:33.800871: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c600 next 75 of size 256\n2020-06-25 16:43:33.800888: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c700 next 76 of size 1024\n2020-06-25 16:43:33.800904: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6cb00 next 77 of size 1024\n2020-06-25 16:43:33.800922: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6cf00 next 78 of size 1024\n2020-06-25 16:43:33.800938: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d300 next 79 of size 512\n2020-06-25 16:43:33.800954: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d500 next 80 of size 512\n2020-06-25 16:43:33.800969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d700 next 81 of size 256\n2020-06-25 16:43:33.800985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d800 next 82 of size 256\n2020-06-25 16:43:33.801001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d900 next 83 of size 256\n2020-06-25 16:43:33.801016: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6da00 next 84 of size 1024\n2020-06-25 16:43:33.801033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6de00 next 85 of size 4096\n2020-06-25 16:43:33.801049: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ee00 next 86 of size 1024\n2020-06-25 16:43:33.801065: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f200 next 87 of size 256\n2020-06-25 16:43:33.801081: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f300 next 88 of size 256\n2020-06-25 16:43:33.801097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f400 next 89 of size 1024\n2020-06-25 16:43:33.801113: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f800 next 90 of size 256\n2020-06-25 16:43:33.801128: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f900 next 91 of size 1024\n2020-06-25 16:43:33.801145: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6fd00 next 92 of size 1024\n2020-06-25 16:43:33.801161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70100 next 93 of size 256\n2020-06-25 16:43:33.801184: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70200 next 94 of size 1024\n2020-06-25 16:43:33.801203: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70600 next 95 of size 256\n2020-06-25 16:43:33.801219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70700 next 96 of size 1024\n2020-06-25 16:43:33.801235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70b00 next 97 of size 1024\n2020-06-25 16:43:33.801251: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70f00 next 98 of size 256\n2020-06-25 16:43:33.801267: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71000 next 99 of size 1024\n2020-06-25 16:43:33.801283: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71400 next 100 of size 1024\n2020-06-25 16:43:33.801299: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71800 next 101 of size 8192\n2020-06-25 16:43:33.801315: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73800 next 102 of size 256\n2020-06-25 16:43:33.801331: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73900 next 103 of size 1024\n2020-06-25 16:43:33.801347: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73d00 next 104 of size 256\n2020-06-25 16:43:33.801362: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73e00 next 105 of size 1024\n2020-06-25 16:43:33.801378: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74200 next 106 of size 1024\n2020-06-25 16:43:33.801394: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74600 next 107 of size 1024\n2020-06-25 16:43:33.801410: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74a00 next 108 of size 256\n2020-06-25 16:43:33.801426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74b00 next 109 of size 1024\n2020-06-25 16:43:33.801452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74f00 next 110 of size 1024\n2020-06-25 16:43:33.801468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75300 next 111 of size 256\n2020-06-25 16:43:33.801485: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75400 next 112 of size 256\n2020-06-25 16:43:33.827269: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75500 next 113 of size 1024\n2020-06-25 16:43:33.827296: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75900 next 114 of size 1024\n2020-06-25 16:43:33.827308: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75d00 next 115 of size 1024\n2020-06-25 16:43:33.827318: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76100 next 116 of size 1024\n2020-06-25 16:43:33.827327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76500 next 117 of size 256\n2020-06-25 16:43:33.827337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76600 next 118 of size 1024\n2020-06-25 16:43:33.827347: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76a00 next 119 of size 1024\n2020-06-25 16:43:33.827356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76e00 next 120 of size 256\n2020-06-25 16:43:33.827365: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76f00 next 121 of size 1024\n2020-06-25 16:43:33.827374: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77300 next 122 of size 1024\n2020-06-25 16:43:33.827384: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77700 next 123 of size 1024\n2020-06-25 16:43:33.827393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77b00 next 124 of size 256\n2020-06-25 16:43:33.827402: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77c00 next 125 of size 1024\n2020-06-25 16:43:33.827412: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78000 next 126 of size 256\n2020-06-25 16:43:33.827421: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78100 next 127 of size 1024\n2020-06-25 16:43:33.827431: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78500 next 128 of size 1024\n2020-06-25 16:43:33.827442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78900 next 129 of size 512\n2020-06-25 16:43:33.827452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78b00 next 130 of size 1024\n2020-06-25 16:43:33.827463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78f00 next 131 of size 256\n2020-06-25 16:43:33.827474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79000 next 132 of size 1024\n2020-06-25 16:43:33.827486: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79400 next 133 of size 1024\n2020-06-25 16:43:33.827497: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79800 next 134 of size 256\n2020-06-25 16:43:33.827509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79900 next 135 of size 1024\n2020-06-25 16:43:33.827520: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79d00 next 136 of size 256\n2020-06-25 16:43:33.827533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79e00 next 137 of size 1024\n2020-06-25 16:43:33.827545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a200 next 138 of size 256\n2020-06-25 16:43:33.827557: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a300 next 139 of size 1024\n2020-06-25 16:43:33.827574: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a700 next 140 of size 1024\n2020-06-25 16:43:33.827592: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ab00 next 141 of size 1024\n2020-06-25 16:43:33.827610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7af00 next 142 of size 1024\n2020-06-25 16:43:33.827625: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b300 next 143 of size 256\n2020-06-25 16:43:33.827640: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b400 next 144 of size 256\n2020-06-25 16:43:33.827667: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b500 next 145 of size 1024\n2020-06-25 16:43:33.827682: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b900 next 146 of size 256\n2020-06-25 16:43:33.827694: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ba00 next 147 of size 1024\n2020-06-25 16:43:33.827709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7be00 next 148 of size 1024\n2020-06-25 16:43:33.827724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7c200 next 149 of size 1024\n2020-06-25 16:43:33.827739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7c600 next 150 of size 1024\n2020-06-25 16:43:33.827754: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ca00 next 151 of size 1024\n2020-06-25 16:43:33.827770: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ce00 next 152 of size 512\n2020-06-25 16:43:33.827785: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d000 next 153 of size 256\n2020-06-25 16:43:33.827799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d100 next 154 of size 256\n2020-06-25 16:43:33.827842: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d200 next 155 of size 1024\n2020-06-25 16:43:33.827862: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d600 next 156 of size 1024\n2020-06-25 16:43:33.827878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7da00 next 157 of size 1024\n2020-06-25 16:43:33.827894: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7de00 next 158 of size 1024\n2020-06-25 16:43:33.827909: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e200 next 159 of size 1024\n2020-06-25 16:43:33.827924: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e600 next 160 of size 256\n2020-06-25 16:43:33.827939: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e700 next 161 of size 1024\n2020-06-25 16:43:33.827955: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7eb00 next 162 of size 256\n2020-06-25 16:43:33.827970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ec00 next 163 of size 256\n2020-06-25 16:43:33.827985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ed00 next 164 of size 256\n2020-06-25 16:43:33.828001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ee00 next 165 of size 512\n2020-06-25 16:43:33.828015: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f000 next 166 of size 256\n2020-06-25 16:43:33.828030: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f100 next 167 of size 1024\n2020-06-25 16:43:33.828045: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f500 next 168 of size 256\n2020-06-25 16:43:33.828072: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f600 next 169 of size 1024\n2020-06-25 16:43:33.828087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fa00 next 170 of size 256\n2020-06-25 16:43:33.828114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fb00 next 171 of size 256\n2020-06-25 16:43:33.828130: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fc00 next 172 of size 256\n2020-06-25 16:43:33.828146: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fd00 next 173 of size 1024\n2020-06-25 16:43:33.828161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80100 next 174 of size 256\n2020-06-25 16:43:33.828199: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80200 next 175 of size 256\n2020-06-25 16:43:33.828232: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80300 next 176 of size 1024\n2020-06-25 16:43:33.828249: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80700 next 177 of size 256\n2020-06-25 16:43:33.828265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80800 next 178 of size 256\n2020-06-25 16:43:33.828294: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80900 next 179 of size 512\n2020-06-25 16:43:33.828323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80b00 next 180 of size 1024\n2020-06-25 16:43:33.828976: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80f00 next 181 of size 256\n2020-06-25 16:43:33.829005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81000 next 182 of size 1024\n2020-06-25 16:43:33.829020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81400 next 183 of size 1024\n2020-06-25 16:43:33.829032: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81800 next 184 of size 1024\n2020-06-25 16:43:33.829044: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81c00 next 185 of size 256\n2020-06-25 16:43:33.829055: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81d00 next 186 of size 256\n2020-06-25 16:43:33.829066: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81e00 next 187 of size 1024\n2020-06-25 16:43:33.829079: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82200 next 188 of size 1024\n2020-06-25 16:43:33.829096: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82600 next 189 of size 256\n2020-06-25 16:43:33.829113: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82700 next 190 of size 256\n2020-06-25 16:43:33.829129: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82800 next 191 of size 1024\n2020-06-25 16:43:33.829145: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82c00 next 192 of size 1024\n2020-06-25 16:43:33.829160: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83000 next 193 of size 256\n2020-06-25 16:43:33.829176: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83100 next 194 of size 1024\n2020-06-25 16:43:33.829202: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83500 next 195 of size 1024\n2020-06-25 16:43:33.829218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83900 next 196 of size 1024\n2020-06-25 16:43:33.829234: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83d00 next 197 of size 512\n2020-06-25 16:43:33.829250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83f00 next 198 of size 256\n2020-06-25 16:43:33.829265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84000 next 199 of size 256\n2020-06-25 16:43:33.829280: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84100 next 200 of size 1024\n2020-06-25 16:43:33.829295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84500 next 201 of size 256\n2020-06-25 16:43:33.829310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84600 next 202 of size 1024\n2020-06-25 16:43:33.829326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84a00 next 203 of size 1024\n2020-06-25 16:43:33.829342: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84e00 next 204 of size 1024\n2020-06-25 16:43:33.829357: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85200 next 205 of size 2048\n2020-06-25 16:43:33.829372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85a00 next 206 of size 256\n2020-06-25 16:43:33.829387: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85b00 next 207 of size 256\n2020-06-25 16:43:33.829403: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85c00 next 208 of size 1024\n2020-06-25 16:43:33.829418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86000 next 209 of size 1024\n2020-06-25 16:43:33.829433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86400 next 210 of size 256\n2020-06-25 16:43:33.829447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86500 next 211 of size 1024\n2020-06-25 16:43:33.829463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86900 next 212 of size 1024\n2020-06-25 16:43:33.829681: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86d00 next 213 of size 1024\n2020-06-25 16:43:33.829706: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87100 next 214 of size 256\n2020-06-25 16:43:33.829720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87200 next 215 of size 1024\n2020-06-25 16:43:33.829731: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87600 next 216 of size 1024\n2020-06-25 16:43:33.829742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87a00 next 217 of size 256\n2020-06-25 16:43:33.829752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87b00 next 218 of size 256\n2020-06-25 16:43:33.829764: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87c00 next 219 of size 1024\n2020-06-25 16:43:33.829775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88000 next 220 of size 1024\n2020-06-25 16:43:33.829788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88400 next 221 of size 1024\n2020-06-25 16:43:33.829799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88800 next 222 of size 256\n2020-06-25 16:43:33.829832: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88900 next 223 of size 256\n2020-06-25 16:43:33.829850: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88a00 next 224 of size 256\n2020-06-25 16:43:33.829905: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88b00 next 225 of size 1024\n2020-06-25 16:43:33.829944: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88f00 next 226 of size 256\n2020-06-25 16:43:33.829984: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89000 next 227 of size 256\n2020-06-25 16:43:33.830001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89100 next 228 of size 1024\n2020-06-25 16:43:33.830018: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89500 next 229 of size 256\n2020-06-25 16:43:33.830036: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89600 next 230 of size 256\n2020-06-25 16:43:33.830053: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89700 next 231 of size 512\n2020-06-25 16:43:33.830069: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89900 next 232 of size 512\n2020-06-25 16:43:33.830086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89b00 next 233 of size 256\n2020-06-25 16:43:33.830102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89c00 next 234 of size 1024\n2020-06-25 16:43:33.830119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a000 next 235 of size 512\n2020-06-25 16:43:33.830135: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a200 next 236 of size 512\n2020-06-25 16:43:33.830152: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a400 next 237 of size 256\n2020-06-25 16:43:33.830168: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a500 next 238 of size 2048\n2020-06-25 16:43:33.830192: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ad00 next 239 of size 256\n2020-06-25 16:43:33.830210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ae00 next 240 of size 4096\n2020-06-25 16:43:33.830227: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8be00 next 241 of size 1024\n2020-06-25 16:43:33.830243: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c200 next 242 of size 256\n2020-06-25 16:43:33.830260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c300 next 243 of size 256\n2020-06-25 16:43:33.830289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c400 next 244 of size 256\n2020-06-25 16:43:33.830333: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c500 next 245 of size 256\n2020-06-25 16:43:33.830361: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c600 next 246 of size 2048\n2020-06-25 16:43:33.830377: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ce00 next 247 of size 256\n2020-06-25 16:43:33.830392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8cf00 next 248 of size 1024\n2020-06-25 16:43:33.830641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8d300 next 249 of size 8192\n2020-06-25 16:43:33.830668: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f300 next 250 of size 256\n2020-06-25 16:43:33.830683: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f400 next 251 of size 256\n2020-06-25 16:43:33.830696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f500 next 252 of size 256\n2020-06-25 16:43:33.830707: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f600 next 253 of size 256\n2020-06-25 16:43:33.830720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f700 next 254 of size 1024\n2020-06-25 16:43:33.830733: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8fb00 next 255 of size 2048\n2020-06-25 16:43:33.830744: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90300 next 256 of size 256\n2020-06-25 16:43:33.830758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90400 next 257 of size 1024\n2020-06-25 16:43:33.830772: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90800 next 258 of size 256\n2020-06-25 16:43:33.830785: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90900 next 259 of size 256\n2020-06-25 16:43:33.830803: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90a00 next 260 of size 1024\n2020-06-25 16:43:33.830872: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90e00 next 261 of size 256\n2020-06-25 16:43:33.830916: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90f00 next 262 of size 256\n2020-06-25 16:43:33.830946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91000 next 263 of size 1024\n2020-06-25 16:43:33.830964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91400 next 264 of size 256\n2020-06-25 16:43:33.830980: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91500 next 265 of size 256\n2020-06-25 16:43:33.830996: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91600 next 266 of size 1024\n2020-06-25 16:43:33.831024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91a00 next 267 of size 256\n2020-06-25 16:43:33.831040: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91b00 next 268 of size 256\n2020-06-25 16:43:33.831056: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91c00 next 269 of size 256\n2020-06-25 16:43:33.831072: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91d00 next 270 of size 512\n2020-06-25 16:43:33.831088: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91f00 next 271 of size 256\n2020-06-25 16:43:33.831104: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92000 next 272 of size 512\n2020-06-25 16:43:33.831120: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92200 next 273 of size 256\n2020-06-25 16:43:33.831148: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92300 next 274 of size 1024\n2020-06-25 16:43:33.831163: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92700 next 275 of size 256\n2020-06-25 16:43:33.831186: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92800 next 276 of size 1024\n2020-06-25 16:43:33.831204: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92c00 next 277 of size 1024\n2020-06-25 16:43:33.831219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93000 next 278 of size 1024\n2020-06-25 16:43:33.831234: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93400 next 279 of size 1024\n2020-06-25 16:43:33.831249: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93800 next 280 of size 1024\n2020-06-25 16:43:33.831495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93c00 next 281 of size 1024\n2020-06-25 16:43:33.831537: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94000 next 282 of size 1024\n2020-06-25 16:43:33.831552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94400 next 283 of size 1024\n2020-06-25 16:43:33.831570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94800 next 284 of size 1024\n2020-06-25 16:43:33.831587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94c00 next 285 of size 256\n2020-06-25 16:43:33.831598: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94d00 next 286 of size 256\n2020-06-25 16:43:33.831612: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94e00 next 287 of size 256\n2020-06-25 16:43:33.831625: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94f00 next 288 of size 1024\n2020-06-25 16:43:33.831642: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95300 next 289 of size 256\n2020-06-25 16:43:33.831685: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95400 next 290 of size 1024\n2020-06-25 16:43:33.831703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95800 next 291 of size 256\n2020-06-25 16:43:33.831719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95900 next 292 of size 1024\n2020-06-25 16:43:33.831748: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95d00 next 293 of size 1024\n2020-06-25 16:43:33.831778: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96100 next 294 of size 1024\n2020-06-25 16:43:33.831807: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96500 next 295 of size 1024\n2020-06-25 16:43:33.831860: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96900 next 296 of size 256\n2020-06-25 16:43:33.831918: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96a00 next 298 of size 32768\n2020-06-25 16:43:33.831955: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b9ea00 next 299 of size 37632\n2020-06-25 16:43:33.831970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703ba7d00 next 301 of size 294912\n2020-06-25 16:43:33.831986: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703befd00 next 302 of size 12288\n2020-06-25 16:43:33.832003: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703bf2d00 next 18446744073709551615 of size 447232\n2020-06-25 16:43:33.832020: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4194304\n2020-06-25 16:43:33.832049: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703c60000 next 18446744073709551615 of size 4194304\n2020-06-25 16:43:33.832065: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4194304\n2020-06-25 16:43:33.832093: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704060000 next 18446744073709551615 of size 4194304\n2020-06-25 16:43:33.832109: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 8388608\n2020-06-25 16:43:33.832127: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704460000 next 304 of size 1179648\n2020-06-25 16:43:33.832143: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704580000 next 305 of size 1179648\n2020-06-25 16:43:33.832159: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7046a0000 next 306 of size 2359296\n2020-06-25 16:43:33.832176: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7048e0000 next 307 of size 524288\n2020-06-25 16:43:33.832202: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704960000 next 18446744073709551615 of size 3145728\n2020-06-25 16:43:33.832428: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 16777216\n2020-06-25 16:43:33.832457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704c60000 next 309 of size 2097152\n2020-06-25 16:43:33.832472: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704e60000 next 310 of size 2359296\n2020-06-25 16:43:33.832484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7050a0000 next 312 of size 2097152\n2020-06-25 16:43:33.832496: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7052a0000 next 313 of size 2359296\n2020-06-25 16:43:33.832509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7054e0000 next 314 of size 37632\n2020-06-25 16:43:33.832521: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7054e9300 next 315 of size 2359296\n2020-06-25 16:43:33.832540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705729300 next 316 of size 37632\n2020-06-25 16:43:33.832557: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705732600 next 319 of size 2359296\n2020-06-25 16:43:33.832575: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705972600 next 18446744073709551615 of size 3070464\n2020-06-25 16:43:33.832591: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 33554432\n2020-06-25 16:43:33.832607: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705c60000 next 18446744073709551615 of size 33554432\n2020-06-25 16:43:33.832623: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 67108864\n2020-06-25 16:43:33.832639: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x707c60000 next 318 of size 8388608\n2020-06-25 16:43:33.832655: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x708460000 next 320 of size 32768\n2020-06-25 16:43:33.832671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x708468000 next 321 of size 294912\n2020-06-25 16:43:33.832685: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7084b0000 next 322 of size 2359296\n2020-06-25 16:43:33.832698: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7086f0000 next 18446744073709551615 of size 56033280\n2020-06-25 16:43:33.832727: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 134217728\n2020-06-25 16:43:33.832743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70bc60000 next 324 of size 1179648\n2020-06-25 16:43:33.832773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70bd80000 next 325 of size 524288\n2020-06-25 16:43:33.832789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70be00000 next 329 of size 262144\n2020-06-25 16:43:33.832805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70be40000 next 330 of size 2359296\n2020-06-25 16:43:33.832844: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c080000 next 331 of size 262144\n2020-06-25 16:43:33.832864: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c0c0000 next 332 of size 262144\n2020-06-25 16:43:33.833150: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c100000 next 333 of size 12288\n2020-06-25 16:43:33.833191: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c103000 next 334 of size 2359296\n2020-06-25 16:43:33.833210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c343000 next 335 of size 8192\n2020-06-25 16:43:33.833224: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c345000 next 336 of size 2359296\n2020-06-25 16:43:33.833236: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c585000 next 337 of size 2359296\n2020-06-25 16:43:33.833270: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c7c5000 next 338 of size 2359296\n2020-06-25 16:43:33.833301: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ca05000 next 339 of size 2359296\n2020-06-25 16:43:33.833318: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70cc45000 next 340 of size 524288\n2020-06-25 16:43:33.833348: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ccc5000 next 341 of size 2359296\n2020-06-25 16:43:33.833379: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70cf05000 next 342 of size 33554432\n2020-06-25 16:43:33.833395: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef05000 next 343 of size 8192\n2020-06-25 16:43:33.833424: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef07000 next 344 of size 8192\n2020-06-25 16:43:33.833439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef09000 next 345 of size 2359296\n2020-06-25 16:43:33.833456: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f149000 next 346 of size 131072\n2020-06-25 16:43:33.833472: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f169000 next 347 of size 2359296\n2020-06-25 16:43:33.833487: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f3a9000 next 348 of size 2359296\n2020-06-25 16:43:33.833503: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f5e9000 next 349 of size 12288\n2020-06-25 16:43:33.833518: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f5ec000 next 350 of size 2359296\n2020-06-25 16:43:33.833546: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f82c000 next 351 of size 2359296\n2020-06-25 16:43:33.833562: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fa6c000 next 352 of size 2097152\n2020-06-25 16:43:33.833578: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fc6c000 next 353 of size 524288\n2020-06-25 16:43:33.833594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fcec000 next 354 of size 2359296\n2020-06-25 16:43:33.833610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ff2c000 next 355 of size 2359296\n2020-06-25 16:43:33.833626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71016c000 next 356 of size 2097152\n2020-06-25 16:43:33.833641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71036c000 next 357 of size 8388608\n2020-06-25 16:43:33.833657: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x710b6c000 next 358 of size 8388608\n2020-06-25 16:43:33.834051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71136c000 next 359 of size 524288\n2020-06-25 16:43:33.834079: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7113ec000 next 361 of size 12288\n2020-06-25 16:43:33.834095: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7113ef000 next 362 of size 262144\n2020-06-25 16:43:33.834107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71142f000 next 363 of size 262144\n2020-06-25 16:43:33.834119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71146f000 next 364 of size 262144\n2020-06-25 16:43:33.834132: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7114af000 next 365 of size 2359296\n2020-06-25 16:43:33.834144: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7116ef000 next 366 of size 524288\n2020-06-25 16:43:33.834157: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71176f000 next 367 of size 2359296\n2020-06-25 16:43:33.834170: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7119af000 next 368 of size 2359296\n2020-06-25 16:43:33.834199: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x711bef000 next 369 of size 2359296\n2020-06-25 16:43:33.834218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x711e2f000 next 370 of size 2359296\n2020-06-25 16:43:33.834232: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71206f000 next 371 of size 2097152\n2020-06-25 16:43:33.834249: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71226f000 next 372 of size 2359296\n2020-06-25 16:43:33.834266: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7124af000 next 373 of size 2359296\n2020-06-25 16:43:33.834283: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7126ef000 next 374 of size 2359296\n2020-06-25 16:43:33.834300: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71292f000 next 375 of size 8388608\n2020-06-25 16:43:33.834316: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71312f000 next 376 of size 1179648\n2020-06-25 16:43:33.834333: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71324f000 next 378 of size 294912\n2020-06-25 16:43:33.834350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713297000 next 381 of size 37632\n2020-06-25 16:43:33.834367: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7132a0300 next 382 of size 8192\n2020-06-25 16:43:33.834384: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7132a2300 next 383 of size 2097152\n2020-06-25 16:43:33.834400: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134a2300 next 384 of size 131072\n2020-06-25 16:43:33.834417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134c2300 next 385 of size 1280\n2020-06-25 16:43:33.834435: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134c2800 next 386 of size 2359296\n2020-06-25 16:43:33.834451: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713702800 next 387 of size 2359296\n2020-06-25 16:43:33.834468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713942800 next 18446744073709551615 of size 3266560\n2020-06-25 16:43:33.834485: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 268435456\n2020-06-25 16:43:33.834502: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713c60000 next 327 of size 134217728\n2020-06-25 16:43:33.834519: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71bc60000 next 377 of size 33554432\n2020-06-25 16:43:33.834536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dc60000 next 388 of size 2359296\n2020-06-25 16:43:33.834553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0000 next 389 of size 1024\n2020-06-25 16:43:33.834569: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0400 next 390 of size 1024\n2020-06-25 16:43:33.834585: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0800 next 391 of size 1024\n2020-06-25 16:43:33.834602: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0c00 next 392 of size 256\n2020-06-25 16:43:33.834620: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0d00 next 393 of size 524288\n2020-06-25 16:43:33.834650: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71df20d00 next 394 of size 33554432\n2020-06-25 16:43:33.834666: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff20d00 next 395 of size 1024\n2020-06-25 16:43:33.834683: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21100 next 396 of size 512\n2020-06-25 16:43:33.834700: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21300 next 397 of size 1024\n2020-06-25 16:43:33.834717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21700 next 398 of size 131072\n2020-06-25 16:43:33.834733: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41700 next 399 of size 1024\n2020-06-25 16:43:33.834749: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41b00 next 400 of size 1024\n2020-06-25 16:43:33.834764: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41f00 next 401 of size 1024\n2020-06-25 16:43:33.834780: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42300 next 402 of size 1024\n2020-06-25 16:43:33.834796: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42700 next 403 of size 1024\n2020-06-25 16:43:33.834827: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42b00 next 404 of size 2359296\n2020-06-25 16:43:33.834846: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720182b00 next 405 of size 1024\n2020-06-25 16:43:33.834862: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720182f00 next 406 of size 1024\n2020-06-25 16:43:33.834878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720183300 next 407 of size 512\n2020-06-25 16:43:33.834894: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720183500 next 408 of size 2359296\n2020-06-25 16:43:33.834910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3500 next 409 of size 1024\n2020-06-25 16:43:33.834927: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3900 next 410 of size 1024\n2020-06-25 16:43:33.834943: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3d00 next 411 of size 1024\n2020-06-25 16:43:33.834959: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4100 next 412 of size 1024\n2020-06-25 16:43:33.834974: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4500 next 413 of size 256\n2020-06-25 16:43:33.834990: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4600 next 414 of size 1024\n2020-06-25 16:43:33.835006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4a00 next 415 of size 1024\n2020-06-25 16:43:33.835021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4e00 next 416 of size 256\n2020-06-25 16:43:33.835037: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4f00 next 417 of size 1024\n2020-06-25 16:43:33.835053: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5300 next 418 of size 512\n2020-06-25 16:43:33.835069: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5500 next 419 of size 1024\n2020-06-25 16:43:33.835085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5900 next 420 of size 1024\n2020-06-25 16:43:33.835309: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5d00 next 421 of size 2359296\n2020-06-25 16:43:33.835336: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720605d00 next 422 of size 1024\n2020-06-25 16:43:33.835350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720606100 next 423 of size 2359296\n2020-06-25 16:43:33.835362: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720846100 next 424 of size 1024\n2020-06-25 16:43:33.835374: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720846500 next 425 of size 2359296\n2020-06-25 16:43:33.835386: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a86500 next 426 of size 1024\n2020-06-25 16:43:33.835397: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a86900 next 427 of size 12288\n2020-06-25 16:43:33.835411: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89900 next 428 of size 1024\n2020-06-25 16:43:33.835428: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89d00 next 429 of size 256\n2020-06-25 16:43:33.835446: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89e00 next 430 of size 1024\n2020-06-25 16:43:33.835463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8a200 next 431 of size 1024\n2020-06-25 16:43:33.835478: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8a600 next 432 of size 1024\n2020-06-25 16:43:33.835495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8aa00 next 433 of size 1024\n2020-06-25 16:43:33.835511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8ae00 next 434 of size 512\n2020-06-25 16:43:33.835527: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b000 next 435 of size 1024\n2020-06-25 16:43:33.835543: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b400 next 436 of size 1024\n2020-06-25 16:43:33.835559: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b800 next 437 of size 2097152\n2020-06-25 16:43:33.835574: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8b800 next 438 of size 1024\n2020-06-25 16:43:33.835590: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8bc00 next 439 of size 1024\n2020-06-25 16:43:33.835607: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8c000 next 440 of size 2097152\n2020-06-25 16:43:33.835623: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720e8c000 next 441 of size 1024\n2020-06-25 16:43:33.835639: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720e8c400 next 442 of size 524288\n2020-06-25 16:43:33.835655: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0c400 next 443 of size 1024\n2020-06-25 16:43:33.835671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0c800 next 444 of size 1024\n2020-06-25 16:43:33.835685: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0cc00 next 445 of size 1024\n2020-06-25 16:43:33.835701: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d000 next 446 of size 1024\n2020-06-25 16:43:33.835717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d400 next 447 of size 1024\n2020-06-25 16:43:33.835733: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d800 next 448 of size 1024\n2020-06-25 16:43:33.835750: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0dc00 next 449 of size 1024\n2020-06-25 16:43:33.835766: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e000 next 450 of size 1024\n2020-06-25 16:43:33.835781: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e400 next 451 of size 1024\n2020-06-25 16:43:33.835798: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e800 next 452 of size 256\n2020-06-25 16:43:33.835830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e900 next 453 of size 256\n2020-06-25 16:43:33.835849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0ea00 next 454 of size 256\n2020-06-25 16:43:33.835866: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0eb00 next 455 of size 2048\n2020-06-25 16:43:33.835881: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f300 next 456 of size 512\n2020-06-25 16:43:33.835897: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f500 next 457 of size 1024\n2020-06-25 16:43:33.835913: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f900 next 458 of size 1024\n2020-06-25 16:43:33.835929: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0fd00 next 459 of size 1024\n2020-06-25 16:43:33.835946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10100 next 460 of size 1024\n2020-06-25 16:43:33.836248: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10500 next 461 of size 1024\n2020-06-25 16:43:33.836276: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10900 next 462 of size 1024\n2020-06-25 16:43:33.836291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10d00 next 463 of size 256\n2020-06-25 16:43:33.836305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10e00 next 464 of size 8388608\n2020-06-25 16:43:33.836330: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721710e00 next 465 of size 1024\n2020-06-25 16:43:33.836356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721711200 next 466 of size 8388608\n2020-06-25 16:43:33.836367: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f11200 next 468 of size 2048\n2020-06-25 16:43:33.836381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f11a00 next 469 of size 524288\n2020-06-25 16:43:33.836393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f91a00 next 470 of size 262144\n2020-06-25 16:43:33.836410: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721fd1a00 next 471 of size 256\n2020-06-25 16:43:33.836428: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721fd1b00 next 472 of size 262144\n2020-06-25 16:43:33.836444: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722011b00 next 473 of size 1024\n2020-06-25 16:43:33.836460: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722011f00 next 474 of size 1024\n2020-06-25 16:43:33.836476: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722012300 next 475 of size 12288\n2020-06-25 16:43:33.836492: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722015300 next 476 of size 256\n2020-06-25 16:43:33.836509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722015400 next 477 of size 262144\n2020-06-25 16:43:33.836524: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055400 next 478 of size 1024\n2020-06-25 16:43:33.836539: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055800 next 479 of size 1024\n2020-06-25 16:43:33.836555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055c00 next 480 of size 1024\n2020-06-25 16:43:33.836571: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056000 next 481 of size 1024\n2020-06-25 16:43:33.836587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056400 next 482 of size 1024\n2020-06-25 16:43:33.836603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056800 next 483 of size 1024\n2020-06-25 16:43:33.836618: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056c00 next 484 of size 524288\n2020-06-25 16:43:33.836634: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d6c00 next 485 of size 1024\n2020-06-25 16:43:33.836649: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7000 next 486 of size 1024\n2020-06-25 16:43:33.836666: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7400 next 487 of size 256\n2020-06-25 16:43:33.836682: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7500 next 488 of size 1024\n2020-06-25 16:43:33.836696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7900 next 489 of size 256\n2020-06-25 16:43:33.836711: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7a00 next 490 of size 256\n2020-06-25 16:43:33.836727: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7b00 next 491 of size 2359296\n2020-06-25 16:43:33.836743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722317b00 next 492 of size 1024\n2020-06-25 16:43:33.836758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722317f00 next 493 of size 1024\n2020-06-25 16:43:33.836774: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318300 next 494 of size 512\n2020-06-25 16:43:33.836790: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318500 next 495 of size 1024\n2020-06-25 16:43:33.836806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318900 next 496 of size 2048\n2020-06-25 16:43:33.836843: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722319100 next 497 of size 2359296\n2020-06-25 16:43:33.836861: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559100 next 498 of size 256\n2020-06-25 16:43:33.836878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559200 next 499 of size 512\n2020-06-25 16:43:33.836893: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559400 next 500 of size 512\n2020-06-25 16:43:33.836909: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559600 next 501 of size 524288\n2020-06-25 16:43:33.836925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9600 next 502 of size 1024\n2020-06-25 16:43:33.836940: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9a00 next 503 of size 1024\n2020-06-25 16:43:33.836956: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9e00 next 504 of size 512\n2020-06-25 16:43:33.836971: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da000 next 505 of size 256\n2020-06-25 16:43:33.836986: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da100 next 506 of size 1024\n2020-06-25 16:43:33.837001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da500 next 507 of size 256\n2020-06-25 16:43:33.837017: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da600 next 508 of size 512\n2020-06-25 16:43:33.837032: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da800 next 509 of size 2359296\n2020-06-25 16:43:33.837048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281a800 next 510 of size 2048\n2020-06-25 16:43:33.837063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b000 next 511 of size 1024\n2020-06-25 16:43:33.837078: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b400 next 512 of size 1024\n2020-06-25 16:43:33.837094: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b800 next 513 of size 12288\n2020-06-25 16:43:33.837109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281e800 next 514 of size 1179648\n2020-06-25 16:43:33.837124: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293e800 next 515 of size 512\n2020-06-25 16:43:33.837140: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ea00 next 516 of size 512\n2020-06-25 16:43:33.837155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ec00 next 517 of size 512\n2020-06-25 16:43:33.837170: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ee00 next 518 of size 1024\n2020-06-25 16:43:33.837193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f200 next 519 of size 512\n2020-06-25 16:43:33.837210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f400 next 520 of size 1024\n2020-06-25 16:43:33.837225: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f800 next 521 of size 1024\n2020-06-25 16:43:33.837241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293fc00 next 522 of size 294912\n2020-06-25 16:43:33.837256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722987c00 next 523 of size 512\n2020-06-25 16:43:33.837271: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722987e00 next 524 of size 512\n2020-06-25 16:43:33.837286: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988000 next 525 of size 1024\n2020-06-25 16:43:33.837302: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988400 next 526 of size 2048\n2020-06-25 16:43:33.837319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988c00 next 527 of size 2048\n2020-06-25 16:43:33.837335: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989400 next 528 of size 256\n2020-06-25 16:43:33.837350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989500 next 529 of size 512\n2020-06-25 16:43:33.837366: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989700 next 530 of size 512\n2020-06-25 16:43:33.837381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989900 next 531 of size 256\n2020-06-25 16:43:33.837398: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989a00 next 532 of size 512\n2020-06-25 16:43:33.837413: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989c00 next 533 of size 256\n2020-06-25 16:43:33.837972: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989d00 next 534 of size 37632\n2020-06-25 16:43:33.838002: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722993000 next 535 of size 1024\n2020-06-25 16:43:33.838033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722993400 next 536 of size 2359296\n2020-06-25 16:43:33.838047: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3400 next 537 of size 1024\n2020-06-25 16:43:33.838060: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3800 next 538 of size 512\n2020-06-25 16:43:33.838277: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3a00 next 539 of size 512\n2020-06-25 16:43:33.838308: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3c00 next 540 of size 256\n2020-06-25 16:43:33.838336: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3d00 next 541 of size 256\n2020-06-25 16:43:33.838350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3e00 next 542 of size 2097152\n2020-06-25 16:43:33.838362: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd3e00 next 543 of size 1024\n2020-06-25 16:43:33.838373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4200 next 544 of size 256\n2020-06-25 16:43:33.838591: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4300 next 545 of size 256\n2020-06-25 16:43:33.838623: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4400 next 546 of size 2359296\n2020-06-25 16:43:33.838641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014400 next 547 of size 256\n2020-06-25 16:43:33.838654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014500 next 548 of size 256\n2020-06-25 16:43:33.838666: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014600 next 549 of size 8192\n2020-06-25 16:43:33.838678: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016600 next 550 of size 1024\n2020-06-25 16:43:33.838991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016a00 next 551 of size 256\n2020-06-25 16:43:33.839033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016b00 next 552 of size 1024\n2020-06-25 16:43:33.839063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016f00 next 553 of size 1024\n2020-06-25 16:43:33.839089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017300 next 554 of size 1024\n2020-06-25 16:43:33.839102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017700 next 555 of size 2048\n2020-06-25 16:43:33.839127: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017f00 next 556 of size 1024\n2020-06-25 16:43:33.839367: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723018300 next 557 of size 1024\n2020-06-25 16:43:33.839389: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723018700 next 558 of size 2359296\n2020-06-25 16:43:33.839402: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723258700 next 559 of size 2359296\n2020-06-25 16:43:33.839413: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498700 next 560 of size 1024\n2020-06-25 16:43:33.839426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498b00 next 561 of size 256\n2020-06-25 16:43:33.839437: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498c00 next 562 of size 2359296\n2020-06-25 16:43:33.839452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d8c00 next 563 of size 1024\n2020-06-25 16:43:33.839470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9000 next 564 of size 1024\n2020-06-25 16:43:33.839487: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9400 next 565 of size 1024\n2020-06-25 16:43:33.839504: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9800 next 566 of size 1024\n2020-06-25 16:43:33.839520: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9c00 next 567 of size 1024\n2020-06-25 16:43:33.839537: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da000 next 568 of size 1024\n2020-06-25 16:43:33.839553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da400 next 569 of size 1024\n2020-06-25 16:43:33.839569: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da800 next 570 of size 1024\n2020-06-25 16:43:33.839585: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236dac00 next 571 of size 2359296\n2020-06-25 16:43:33.839614: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ac00 next 572 of size 512\n2020-06-25 16:43:33.839630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ae00 next 573 of size 256\n2020-06-25 16:43:33.839646: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391af00 next 574 of size 1024\n2020-06-25 16:43:33.839662: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391b300 next 575 of size 1024\n2020-06-25 16:43:33.839677: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391b700 next 576 of size 1024\n2020-06-25 16:43:33.839692: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391bb00 next 577 of size 1024\n2020-06-25 16:43:33.839707: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391bf00 next 578 of size 2048\n2020-06-25 16:43:33.839723: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391c700 next 579 of size 1024\n2020-06-25 16:43:33.839740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391cb00 next 580 of size 1024\n2020-06-25 16:43:33.839756: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391cf00 next 581 of size 1024\n2020-06-25 16:43:33.839774: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391d300 next 582 of size 1024\n2020-06-25 16:43:33.839789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391d700 next 583 of size 1024\n2020-06-25 16:43:33.839805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391db00 next 584 of size 2048\n2020-06-25 16:43:33.839842: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391e300 next 585 of size 2048\n2020-06-25 16:43:33.839859: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391eb00 next 586 of size 1024\n2020-06-25 16:43:33.839876: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ef00 next 587 of size 1024\n2020-06-25 16:43:33.839893: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391f300 next 588 of size 2048\n2020-06-25 16:43:33.839909: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391fb00 next 589 of size 512\n2020-06-25 16:43:33.839924: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391fd00 next 590 of size 1024\n2020-06-25 16:43:33.839942: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920100 next 591 of size 1024\n2020-06-25 16:43:33.839958: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920500 next 592 of size 1024\n2020-06-25 16:43:33.839974: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920900 next 593 of size 1024\n2020-06-25 16:43:33.839989: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920d00 next 594 of size 1024\n2020-06-25 16:43:33.840005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921100 next 595 of size 1024\n2020-06-25 16:43:33.840020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921500 next 596 of size 512\n2020-06-25 16:43:33.840048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921700 next 597 of size 1024\n2020-06-25 16:43:33.840066: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921b00 next 18446744073709551615 of size 3400960\n2020-06-25 16:43:33.840083: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1073741824\n2020-06-25 16:43:33.840100: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723c60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:33.840116: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1073741824\n2020-06-25 16:43:33.840133: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x763c60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:33.840161: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2147483648\n2020-06-25 16:43:33.840185: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7a3c60000 next 380 of size 134217728\n2020-06-25 16:43:33.840205: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7abc60000 next 467 of size 1073741824\n2020-06-25 16:43:33.840222: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60000 next 598 of size 1024\n2020-06-25 16:43:33.840238: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60400 next 599 of size 1024\n2020-06-25 16:43:33.840256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60800 next 600 of size 1024\n2020-06-25 16:43:33.840273: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60c00 next 601 of size 1024\n2020-06-25 16:43:33.840302: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc61000 next 602 of size 2359296\n2020-06-25 16:43:33.840318: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebea1000 next 603 of size 2359296\n2020-06-25 16:43:33.840336: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec0e1000 next 604 of size 8388608\n2020-06-25 16:43:33.840365: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec8e1000 next 605 of size 1024\n2020-06-25 16:43:33.840381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec8e1400 next 606 of size 33554432\n2020-06-25 16:43:33.840397: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e1400 next 607 of size 4096\n2020-06-25 16:43:33.840412: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2400 next 608 of size 512\n2020-06-25 16:43:33.840428: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2600 next 609 of size 1024\n2020-06-25 16:43:33.840443: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2a00 next 610 of size 1024\n2020-06-25 16:43:33.840459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2e00 next 611 of size 1024\n2020-06-25 16:43:33.840475: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3200 next 612 of size 1024\n2020-06-25 16:43:33.840490: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3600 next 613 of size 512\n2020-06-25 16:43:33.840506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3800 next 614 of size 512\n2020-06-25 16:43:33.840522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3a00 next 615 of size 294912\n2020-06-25 16:43:33.840539: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92ba00 next 616 of size 1024\n2020-06-25 16:43:33.840555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92be00 next 617 of size 1024\n2020-06-25 16:43:33.840571: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92c200 next 618 of size 32768\n2020-06-25 16:43:33.840587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee934200 next 619 of size 1024\n2020-06-25 16:43:33.840602: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee934600 next 620 of size 4096\n2020-06-25 16:43:33.840618: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935600 next 621 of size 1024\n2020-06-25 16:43:33.840634: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935a00 next 622 of size 1024\n2020-06-25 16:43:33.840650: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935e00 next 623 of size 1024\n2020-06-25 16:43:33.840666: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936200 next 624 of size 1024\n2020-06-25 16:43:33.840694: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936600 next 625 of size 1024\n2020-06-25 16:43:33.840724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936a00 next 626 of size 33554432\n2020-06-25 16:43:33.840741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0936a00 next 627 of size 1024\n2020-06-25 16:43:33.840757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0936e00 next 628 of size 512\n2020-06-25 16:43:33.840770: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937000 next 629 of size 512\n2020-06-25 16:43:33.840783: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937200 next 630 of size 512\n2020-06-25 16:43:33.840799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937400 next 631 of size 1024\n2020-06-25 16:43:33.840849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937800 next 632 of size 2097152\n2020-06-25 16:43:33.840870: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b37800 next 633 of size 1024\n2020-06-25 16:43:33.840887: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b37c00 next 634 of size 1024\n2020-06-25 16:43:33.840903: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38000 next 635 of size 2048\n2020-06-25 16:43:33.840920: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38800 next 636 of size 1024\n2020-06-25 16:43:33.840949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38c00 next 637 of size 2359296\n2020-06-25 16:43:33.840964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d78c00 next 638 of size 1024\n2020-06-25 16:43:33.840979: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79000 next 639 of size 1024\n2020-06-25 16:43:33.840995: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79400 next 640 of size 1024\n2020-06-25 16:43:33.841011: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79800 next 641 of size 1024\n2020-06-25 16:43:33.841026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79c00 next 642 of size 512\n2020-06-25 16:43:33.841041: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79e00 next 643 of size 512\n2020-06-25 16:43:33.841057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d7a000 next 644 of size 2048\n2020-06-25 16:43:33.841073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d7a800 next 645 of size 131072\n2020-06-25 16:43:33.841088: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d9a800 next 646 of size 2359296\n2020-06-25 16:43:33.841104: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0fda800 next 647 of size 512\n2020-06-25 16:43:33.841119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0fdaa00 next 648 of size 2359296\n2020-06-25 16:43:33.841137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f121aa00 next 649 of size 1024\n2020-06-25 16:43:33.841153: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f121ae00 next 650 of size 2359296\n2020-06-25 16:43:33.841169: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f145ae00 next 651 of size 1024\n2020-06-25 16:43:33.841192: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f145b200 next 652 of size 33554432\n2020-06-25 16:43:33.841209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f345b200 next 653 of size 1179648\n2020-06-25 16:43:33.841224: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357b200 next 654 of size 1024\n2020-06-25 16:43:33.841240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357b600 next 655 of size 1024\n2020-06-25 16:43:33.841255: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357ba00 next 656 of size 1024\n2020-06-25 16:43:33.841271: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357be00 next 657 of size 1024\n2020-06-25 16:43:33.841287: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357c200 next 658 of size 32768\n2020-06-25 16:43:33.841302: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584200 next 659 of size 256\n2020-06-25 16:43:33.841319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584300 next 660 of size 512\n2020-06-25 16:43:33.841334: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584500 next 661 of size 512\n2020-06-25 16:43:33.841350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584700 next 662 of size 512\n2020-06-25 16:43:33.841365: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584900 next 663 of size 524288\n2020-06-25 16:43:33.841381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3604900 next 664 of size 8192\n2020-06-25 16:43:33.841396: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3606900 next 665 of size 1024\n2020-06-25 16:43:33.841413: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3606d00 next 666 of size 2097152\n2020-06-25 16:43:33.841429: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3806d00 next 667 of size 256\n2020-06-25 16:43:33.841468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3806e00 next 668 of size 1024\n2020-06-25 16:43:33.841498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3807200 next 669 of size 256\n2020-06-25 16:43:33.841528: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3807300 next 670 of size 37632\n2020-06-25 16:43:33.841545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810600 next 671 of size 1024\n2020-06-25 16:43:33.841561: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810a00 next 672 of size 1024\n2020-06-25 16:43:33.841589: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810e00 next 673 of size 1024\n2020-06-25 16:43:33.841606: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811200 next 674 of size 256\n2020-06-25 16:43:33.841623: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811300 next 675 of size 512\n2020-06-25 16:43:33.841639: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811500 next 676 of size 256\n2020-06-25 16:43:33.841656: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811600 next 679 of size 262144\n2020-06-25 16:43:33.841672: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3851600 next 680 of size 2359296\n2020-06-25 16:43:33.841687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91600 next 681 of size 256\n2020-06-25 16:43:33.841717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91700 next 682 of size 256\n2020-06-25 16:43:33.841745: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91800 next 683 of size 256\n2020-06-25 16:43:33.841761: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91900 next 684 of size 1024\n2020-06-25 16:43:33.841792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91d00 next 685 of size 256\n2020-06-25 16:43:33.841822: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91e00 next 686 of size 2359296\n2020-06-25 16:43:33.841844: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3cd1e00 next 687 of size 1024\n2020-06-25 16:43:33.841861: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3cd2200 next 688 of size 2359296\n2020-06-25 16:43:33.842085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12200 next 689 of size 1024\n2020-06-25 16:43:33.842112: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12600 next 690 of size 256\n2020-06-25 16:43:33.842144: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12700 next 691 of size 1024\n2020-06-25 16:43:33.842159: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12b00 next 692 of size 256\n2020-06-25 16:43:33.842172: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12c00 next 693 of size 256\n2020-06-25 16:43:33.842407: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12d00 next 694 of size 1179648\n2020-06-25 16:43:33.842439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4032d00 next 695 of size 1024\n2020-06-25 16:43:33.842459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4033100 next 696 of size 1179648\n2020-06-25 16:43:33.842472: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4153100 next 697 of size 4096\n2020-06-25 16:43:33.842484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4154100 next 698 of size 12288\n2020-06-25 16:43:33.842495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157100 next 699 of size 1024\n2020-06-25 16:43:33.842727: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157500 next 700 of size 256\n2020-06-25 16:43:33.842758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157600 next 701 of size 1024\n2020-06-25 16:43:33.842776: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157a00 next 702 of size 1024\n2020-06-25 16:43:33.842789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157e00 next 703 of size 1024\n2020-06-25 16:43:33.842844: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158200 next 704 of size 256\n2020-06-25 16:43:33.843089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158300 next 705 of size 256\n2020-06-25 16:43:33.843110: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158400 next 706 of size 256\n2020-06-25 16:43:33.843140: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158500 next 707 of size 512\n2020-06-25 16:43:33.843154: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158700 next 708 of size 256\n2020-06-25 16:43:33.843167: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158800 next 709 of size 262144\n2020-06-25 16:43:33.843397: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4198800 next 710 of size 1024\n2020-06-25 16:43:33.843429: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4198c00 next 711 of size 1024\n2020-06-25 16:43:33.843461: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4199000 next 712 of size 294912\n2020-06-25 16:43:33.843476: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f41e1000 next 713 of size 2359296\n2020-06-25 16:43:33.843488: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421000 next 714 of size 1024\n2020-06-25 16:43:33.843712: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421400 next 715 of size 256\n2020-06-25 16:43:33.843745: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421500 next 716 of size 8388608\n2020-06-25 16:43:33.843775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4c21500 next 717 of size 1024\n2020-06-25 16:43:33.843791: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4c21900 next 718 of size 2359296\n2020-06-25 16:43:33.843803: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61900 next 719 of size 256\n2020-06-25 16:43:33.843841: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61a00 next 720 of size 512\n2020-06-25 16:43:33.843957: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61c00 next 721 of size 1024\n2020-06-25 16:43:33.843979: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e62000 next 722 of size 1024\n2020-06-25 16:43:33.843998: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e62400 next 723 of size 262144\n2020-06-25 16:43:33.844016: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4ea2400 next 724 of size 1024\n2020-06-25 16:43:33.844034: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4ea2800 next 725 of size 2359296\n2020-06-25 16:43:33.844051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2800 next 726 of size 1024\n2020-06-25 16:43:33.844068: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2c00 next 727 of size 256\n2020-06-25 16:43:33.844085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2d00 next 728 of size 1024\n2020-06-25 16:43:33.844102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e3100 next 729 of size 4096\n2020-06-25 16:43:33.844121: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e4100 next 730 of size 37632\n2020-06-25 16:43:33.844138: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ed400 next 731 of size 2048\n2020-06-25 16:43:33.844155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50edc00 next 732 of size 1024\n2020-06-25 16:43:33.844171: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ee000 next 733 of size 1024\n2020-06-25 16:43:33.844200: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ee400 next 734 of size 294912\n2020-06-25 16:43:33.844218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5136400 next 735 of size 2048\n2020-06-25 16:43:33.844235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5136c00 next 736 of size 1024\n2020-06-25 16:43:33.844252: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137000 next 737 of size 1024\n2020-06-25 16:43:33.844269: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137400 next 738 of size 1024\n2020-06-25 16:43:33.844286: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137800 next 739 of size 2359296\n2020-06-25 16:43:33.844303: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5377800 next 740 of size 1024\n2020-06-25 16:43:33.844320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5377c00 next 741 of size 1024\n2020-06-25 16:43:33.844337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378000 next 742 of size 1024\n2020-06-25 16:43:33.844355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378400 next 743 of size 256\n2020-06-25 16:43:33.844373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378500 next 744 of size 256\n2020-06-25 16:43:33.844390: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378600 next 745 of size 256\n2020-06-25 16:43:33.844407: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378700 next 746 of size 1024\n2020-06-25 16:43:33.844424: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378b00 next 747 of size 1024\n2020-06-25 16:43:33.844441: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378f00 next 748 of size 512\n2020-06-25 16:43:33.844457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379100 next 749 of size 256\n2020-06-25 16:43:33.844474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379200 next 750 of size 2048\n2020-06-25 16:43:33.844491: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379a00 next 751 of size 256\n2020-06-25 16:43:33.844508: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379b00 next 752 of size 1024\n2020-06-25 16:43:33.844524: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379f00 next 753 of size 1024\n2020-06-25 16:43:33.844541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f537a300 next 754 of size 1024\n2020-06-25 16:43:33.844558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f537a700 next 755 of size 134217728\n2020-06-25 16:43:33.844576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37a700 next 756 of size 1024\n2020-06-25 16:43:33.844593: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37ab00 next 757 of size 1024\n2020-06-25 16:43:33.844610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37af00 next 758 of size 1024\n2020-06-25 16:43:33.844626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37b300 next 759 of size 1024\n2020-06-25 16:43:33.844643: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37b700 next 760 of size 1024\n2020-06-25 16:43:33.844660: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37bb00 next 761 of size 1024\n2020-06-25 16:43:33.844676: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37bf00 next 762 of size 512\n2020-06-25 16:43:33.844692: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37c100 next 763 of size 37632\n2020-06-25 16:43:33.844708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385400 next 764 of size 256\n2020-06-25 16:43:33.844725: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385500 next 765 of size 256\n2020-06-25 16:43:33.844742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385600 next 766 of size 256\n2020-06-25 16:43:33.844759: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385700 next 767 of size 1024\n2020-06-25 16:43:33.844776: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385b00 next 768 of size 1024\n2020-06-25 16:43:33.844793: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385f00 next 769 of size 512\n2020-06-25 16:43:33.844825: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386100 next 770 of size 512\n2020-06-25 16:43:33.844846: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386300 next 771 of size 256\n2020-06-25 16:43:33.844863: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386400 next 772 of size 256\n2020-06-25 16:43:33.844881: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386500 next 773 of size 256\n2020-06-25 16:43:33.844898: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386600 next 774 of size 1024\n2020-06-25 16:43:33.844915: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386a00 next 775 of size 1024\n2020-06-25 16:43:33.844932: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386e00 next 776 of size 1024\n2020-06-25 16:43:33.844948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd387200 next 777 of size 8192\n2020-06-25 16:43:33.844965: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389200 next 778 of size 1024\n2020-06-25 16:43:33.844981: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389600 next 779 of size 1024\n2020-06-25 16:43:33.844998: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389a00 next 780 of size 1024\n2020-06-25 16:43:33.845015: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389e00 next 781 of size 1024\n2020-06-25 16:43:33.845031: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a200 next 782 of size 256\n2020-06-25 16:43:33.845048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a300 next 783 of size 256\n2020-06-25 16:43:33.845065: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a400 next 784 of size 256\n2020-06-25 16:43:33.845082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a500 next 785 of size 256\n2020-06-25 16:43:33.845098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a600 next 786 of size 256\n2020-06-25 16:43:33.845115: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a700 next 787 of size 256\n2020-06-25 16:43:33.845131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a800 next 788 of size 256\n2020-06-25 16:43:33.845148: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a900 next 789 of size 1024\n2020-06-25 16:43:33.845164: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38ad00 next 790 of size 1024\n2020-06-25 16:43:33.845186: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b100 next 791 of size 256\n2020-06-25 16:43:33.845205: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b200 next 792 of size 1024\n2020-06-25 16:43:33.845221: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b600 next 793 of size 512\n2020-06-25 16:43:33.845238: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b800 next 794 of size 1024\n2020-06-25 16:43:33.845255: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38bc00 next 795 of size 1024\n2020-06-25 16:43:33.845271: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c000 next 796 of size 1024\n2020-06-25 16:43:33.845288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c400 next 797 of size 1024\n2020-06-25 16:43:33.845305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c800 next 798 of size 1024\n2020-06-25 16:43:33.845321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38cc00 next 799 of size 1024\n2020-06-25 16:43:33.845338: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d000 next 800 of size 1024\n2020-06-25 16:43:33.845355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d400 next 801 of size 1024\n2020-06-25 16:43:33.845371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d800 next 802 of size 4096\n2020-06-25 16:43:33.845388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38e800 next 803 of size 134217728\n2020-06-25 16:43:33.845405: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80538e800 next 804 of size 8192\n2020-06-25 16:43:33.845421: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390800 next 805 of size 256\n2020-06-25 16:43:33.845438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390900 next 806 of size 256\n2020-06-25 16:43:33.845454: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390a00 next 807 of size 256\n2020-06-25 16:43:33.845471: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390b00 next 808 of size 2097152\n2020-06-25 16:43:33.845488: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590b00 next 809 of size 256\n2020-06-25 16:43:33.845504: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590c00 next 810 of size 256\n2020-06-25 16:43:33.845521: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590d00 next 811 of size 1024\n2020-06-25 16:43:33.845538: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591100 next 812 of size 1024\n2020-06-25 16:43:33.845555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591500 next 813 of size 1024\n2020-06-25 16:43:33.845571: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591900 next 814 of size 256\n2020-06-25 16:43:33.845587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591a00 next 815 of size 1024\n2020-06-25 16:43:33.845605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591e00 next 816 of size 256\n2020-06-25 16:43:33.845621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591f00 next 817 of size 256\n2020-06-25 16:43:33.845637: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592000 next 818 of size 1024\n2020-06-25 16:43:33.845654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592400 next 819 of size 256\n2020-06-25 16:43:33.845670: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592500 next 820 of size 2048\n2020-06-25 16:43:33.845685: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592d00 next 821 of size 256\n2020-06-25 16:43:33.845703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592e00 next 822 of size 256\n2020-06-25 16:43:33.845720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592f00 next 823 of size 512\n2020-06-25 16:43:33.845736: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593100 next 824 of size 1024\n2020-06-25 16:43:33.845753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593500 next 825 of size 256\n2020-06-25 16:43:33.845769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593600 next 826 of size 1024\n2020-06-25 16:43:33.845786: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593a00 next 827 of size 1024\n2020-06-25 16:43:33.845802: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593e00 next 828 of size 1024\n2020-06-25 16:43:33.845834: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594200 next 829 of size 1024\n2020-06-25 16:43:33.845852: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594600 next 830 of size 1024\n2020-06-25 16:43:33.845869: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594a00 next 831 of size 1024\n2020-06-25 16:43:33.845887: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594e00 next 832 of size 1024\n2020-06-25 16:43:33.845904: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805595200 next 833 of size 2048\n2020-06-25 16:43:33.845921: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805595a00 next 834 of size 8192\n2020-06-25 16:43:33.845937: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805597a00 next 835 of size 1024\n2020-06-25 16:43:33.845954: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805597e00 next 836 of size 4096\n2020-06-25 16:43:33.845970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805598e00 next 837 of size 512\n2020-06-25 16:43:33.845987: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599000 next 838 of size 1024\n2020-06-25 16:43:33.846003: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599400 next 839 of size 1024\n2020-06-25 16:43:33.846021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599800 next 840 of size 1024\n2020-06-25 16:43:33.846037: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599c00 next 841 of size 1024\n2020-06-25 16:43:33.846054: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a000 next 842 of size 1024\n2020-06-25 16:43:33.846070: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a400 next 843 of size 1024\n2020-06-25 16:43:33.846087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a800 next 844 of size 1024\n2020-06-25 16:43:33.846104: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ac00 next 845 of size 256\n2020-06-25 16:43:33.846120: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ad00 next 846 of size 8192\n2020-06-25 16:43:33.846137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559cd00 next 847 of size 256\n2020-06-25 16:43:33.846153: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ce00 next 848 of size 256\n2020-06-25 16:43:33.846169: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559cf00 next 849 of size 8192\n2020-06-25 16:43:33.846195: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ef00 next 850 of size 256\n2020-06-25 16:43:33.846213: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f000 next 851 of size 512\n2020-06-25 16:43:33.846229: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f200 next 852 of size 512\n2020-06-25 16:43:33.846246: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f400 next 853 of size 1024\n2020-06-25 16:43:33.846262: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f800 next 854 of size 1024\n2020-06-25 16:43:33.846279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559fc00 next 855 of size 8192\n2020-06-25 16:43:33.846295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a1c00 next 856 of size 1024\n2020-06-25 16:43:33.846312: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2000 next 857 of size 1024\n2020-06-25 16:43:33.846328: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2400 next 858 of size 1024\n2020-06-25 16:43:33.846344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2800 next 859 of size 1024\n2020-06-25 16:43:33.846360: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2c00 next 860 of size 1024\n2020-06-25 16:43:33.846377: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3000 next 861 of size 1024\n2020-06-25 16:43:33.846393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3400 next 862 of size 256\n2020-06-25 16:43:33.846409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3500 next 863 of size 256\n2020-06-25 16:43:33.846426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3600 next 864 of size 1024\n2020-06-25 16:43:33.846442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3a00 next 865 of size 256\n2020-06-25 16:43:33.846458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3b00 next 866 of size 8192\n2020-06-25 16:43:33.846475: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a5b00 next 867 of size 1024\n2020-06-25 16:43:33.846491: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a5f00 next 868 of size 1024\n2020-06-25 16:43:33.846507: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6300 next 869 of size 1024\n2020-06-25 16:43:33.846524: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6700 next 870 of size 1024\n2020-06-25 16:43:33.846541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6b00 next 871 of size 256\n2020-06-25 16:43:33.846557: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6c00 next 872 of size 1024\n2020-06-25 16:43:33.944345: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7000 next 873 of size 256\n2020-06-25 16:43:33.944419: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7100 next 874 of size 256\n2020-06-25 16:43:33.944450: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7200 next 875 of size 1024\n2020-06-25 16:43:33.944461: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7600 next 876 of size 1024\n2020-06-25 16:43:33.944470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7a00 next 877 of size 1024\n2020-06-25 16:43:33.944507: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7e00 next 878 of size 1024\n2020-06-25 16:43:33.944516: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8200 next 879 of size 1024\n2020-06-25 16:43:33.944525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8600 next 880 of size 1024\n2020-06-25 16:43:33.944533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8a00 next 881 of size 1024\n2020-06-25 16:43:33.944542: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8e00 next 882 of size 1024\n2020-06-25 16:43:33.944552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9200 next 883 of size 2048\n2020-06-25 16:43:33.944562: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9a00 next 884 of size 256\n2020-06-25 16:43:33.944572: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9b00 next 885 of size 256\n2020-06-25 16:43:33.944593: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9c00 next 886 of size 2048\n2020-06-25 16:43:33.944602: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa400 next 887 of size 256\n2020-06-25 16:43:33.944611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa500 next 888 of size 512\n2020-06-25 16:43:33.944621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa700 next 889 of size 1024\n2020-06-25 16:43:33.944632: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aab00 next 890 of size 1024\n2020-06-25 16:43:33.944643: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aaf00 next 891 of size 2048\n2020-06-25 16:43:33.944653: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ab700 next 892 of size 1024\n2020-06-25 16:43:33.944698: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055abb00 next 893 of size 1024\n2020-06-25 16:43:33.944716: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055abf00 next 894 of size 256\n2020-06-25 16:43:33.944739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac000 next 895 of size 256\n2020-06-25 16:43:33.944762: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac100 next 896 of size 512\n2020-06-25 16:43:33.944786: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac300 next 897 of size 512\n2020-06-25 16:43:33.944797: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac500 next 898 of size 512\n2020-06-25 16:43:33.945158: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac700 next 899 of size 256\n2020-06-25 16:43:33.945192: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac800 next 900 of size 1024\n2020-06-25 16:43:33.945207: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055acc00 next 901 of size 1024\n2020-06-25 16:43:33.945218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad000 next 902 of size 1024\n2020-06-25 16:43:33.945229: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad400 next 903 of size 1024\n2020-06-25 16:43:33.945239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad800 next 904 of size 1024\n2020-06-25 16:43:33.946845: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055adc00 next 905 of size 1024\n2020-06-25 16:43:33.946874: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae000 next 906 of size 1024\n2020-06-25 16:43:33.946887: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae400 next 907 of size 256\n2020-06-25 16:43:33.946897: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae500 next 908 of size 1024\n2020-06-25 16:43:33.946908: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae900 next 909 of size 1024\n2020-06-25 16:43:33.946919: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aed00 next 910 of size 256\n2020-06-25 16:43:33.946929: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aee00 next 911 of size 1024\n2020-06-25 16:43:33.946939: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af200 next 912 of size 256\n2020-06-25 16:43:33.946949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af300 next 913 of size 1024\n2020-06-25 16:43:33.946970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af700 next 914 of size 512\n2020-06-25 16:43:33.946981: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af900 next 915 of size 256\n2020-06-25 16:43:33.946992: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055afa00 next 916 of size 32768\n2020-06-25 16:43:33.947014: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055b7a00 next 917 of size 32768\n2020-06-25 16:43:33.947024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055bfa00 next 918 of size 4096\n2020-06-25 16:43:33.947035: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055c0a00 next 919 of size 2359296\n2020-06-25 16:43:33.947045: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805800a00 next 920 of size 2359296\n2020-06-25 16:43:33.947055: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40a00 next 921 of size 256\n2020-06-25 16:43:33.947065: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40b00 next 922 of size 512\n2020-06-25 16:43:33.947089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40d00 next 923 of size 1024\n2020-06-25 16:43:33.947471: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41100 next 924 of size 1024\n2020-06-25 16:43:33.947498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41500 next 925 of size 256\n2020-06-25 16:43:33.947512: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41600 next 926 of size 1024\n2020-06-25 16:43:33.947524: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41a00 next 927 of size 1024\n2020-06-25 16:43:33.947535: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41e00 next 928 of size 1024\n2020-06-25 16:43:33.947545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42200 next 929 of size 1024\n2020-06-25 16:43:33.947555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42600 next 930 of size 1024\n2020-06-25 16:43:33.947566: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42a00 next 931 of size 1024\n2020-06-25 16:43:33.947576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42e00 next 932 of size 256\n2020-06-25 16:43:33.947585: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42f00 next 933 of size 1024\n2020-06-25 16:43:33.947594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43300 next 934 of size 1024\n2020-06-25 16:43:33.947603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43700 next 935 of size 1024\n2020-06-25 16:43:33.947613: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43b00 next 936 of size 1024\n2020-06-25 16:43:33.947622: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43f00 next 937 of size 512\n2020-06-25 16:43:33.947644: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44100 next 938 of size 1024\n2020-06-25 16:43:33.947654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44500 next 939 of size 1179648\n2020-06-25 16:43:33.947664: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805b64500 next 940 of size 1179648\n2020-06-25 16:43:33.947673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805c84500 next 941 of size 33554432\n2020-06-25 16:43:33.947697: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x807c84500 next 942 of size 33554432\n2020-06-25 16:43:33.947708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809c84500 next 943 of size 294912\n2020-06-25 16:43:33.947718: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809ccc500 next 944 of size 294912\n2020-06-25 16:43:33.947728: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14500 next 945 of size 256\n2020-06-25 16:43:33.947738: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14600 next 946 of size 256\n2020-06-25 16:43:33.947748: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14700 next 947 of size 2097152\n2020-06-25 16:43:33.947758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809f14700 next 948 of size 2097152\n2020-06-25 16:43:33.947769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114700 next 949 of size 1024\n2020-06-25 16:43:33.947779: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114b00 next 950 of size 2048\n2020-06-25 16:43:33.947788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115300 next 951 of size 1024\n2020-06-25 16:43:33.947797: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115700 next 952 of size 8192\n2020-06-25 16:43:33.947807: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117700 next 953 of size 1024\n2020-06-25 16:43:33.947845: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117b00 next 954 of size 2359296\n2020-06-25 16:43:33.947857: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a357b00 next 955 of size 2359296\n2020-06-25 16:43:33.947867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a597b00 next 956 of size 1179648\n2020-06-25 16:43:33.947877: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a6b7b00 next 957 of size 1179648\n2020-06-25 16:43:33.947888: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a7d7b00 next 958 of size 2097152\n2020-06-25 16:43:33.947897: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a9d7b00 next 959 of size 2097152\n2020-06-25 16:43:33.947907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80abd7b00 next 960 of size 2359296\n2020-06-25 16:43:33.947917: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ae17b00 next 961 of size 2359296\n2020-06-25 16:43:33.947928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b057b00 next 963 of size 8192\n2020-06-25 16:43:33.947939: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b059b00 next 964 of size 8192\n2020-06-25 16:43:33.947949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05bb00 next 965 of size 8192\n2020-06-25 16:43:33.947960: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05db00 next 966 of size 524288\n2020-06-25 16:43:33.948309: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b0ddb00 next 967 of size 524288\n2020-06-25 16:43:33.948334: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15db00 next 968 of size 1024\n2020-06-25 16:43:33.948346: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15df00 next 969 of size 1024\n2020-06-25 16:43:33.948356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15e300 next 970 of size 2359296\n2020-06-25 16:43:33.948366: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e300 next 971 of size 1024\n2020-06-25 16:43:33.948388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e700 next 972 of size 1024\n2020-06-25 16:43:33.948398: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39eb00 next 974 of size 262144\n2020-06-25 16:43:33.948422: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b3deb00 next 975 of size 2359296\n2020-06-25 16:43:33.948432: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b61eb00 next 976 of size 2359296\n2020-06-25 16:43:33.948442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b85eb00 next 977 of size 2359296\n2020-06-25 16:43:33.948451: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ba9eb00 next 978 of size 2359296\n2020-06-25 16:43:33.948462: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdeb00 next 979 of size 2048\n2020-06-25 16:43:33.948472: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdf300 next 980 of size 2359296\n2020-06-25 16:43:33.948482: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bf1f300 next 981 of size 2359296\n2020-06-25 16:43:33.948493: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c15f300 next 982 of size 4096\n2020-06-25 16:43:33.948502: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160300 next 983 of size 256\n2020-06-25 16:43:33.948512: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160400 next 984 of size 1024\n2020-06-25 16:43:33.948523: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160800 next 985 of size 32768\n2020-06-25 16:43:33.948533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c168800 next 986 of size 32768\n2020-06-25 16:43:33.948543: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c170800 next 987 of size 2359296\n2020-06-25 16:43:33.948553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c3b0800 next 988 of size 2359296\n2020-06-25 16:43:33.948563: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c5f0800 next 989 of size 2359296\n2020-06-25 16:43:33.948573: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c830800 next 990 of size 2359296\n2020-06-25 16:43:33.948583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ca70800 next 991 of size 33554432\n2020-06-25 16:43:33.948591: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ea70800 next 992 of size 33554432\n2020-06-25 16:43:33.948602: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810a70800 next 993 of size 2359296\n2020-06-25 16:43:33.948612: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810cb0800 next 994 of size 2359296\n2020-06-25 16:43:33.948622: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810ef0800 next 995 of size 131072\n2020-06-25 16:43:33.950026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f10800 next 996 of size 131072\n2020-06-25 16:43:33.950064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f30800 next 997 of size 2359296\n2020-06-25 16:43:33.950084: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811170800 next 998 of size 2359296\n2020-06-25 16:43:33.950101: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8113b0800 next 1001 of size 2359296\n2020-06-25 16:43:33.950117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8115f0800 next 1002 of size 2359296\n2020-06-25 16:43:33.950137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811830800 next 1003 of size 8388608\n2020-06-25 16:43:33.950155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812030800 next 1004 of size 8388608\n2020-06-25 16:43:33.950172: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830800 next 1005 of size 1024\n2020-06-25 16:43:33.950188: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830c00 next 1006 of size 2359296\n2020-06-25 16:43:33.950204: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812a70c00 next 1007 of size 2359296\n2020-06-25 16:43:33.950222: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb0c00 next 1008 of size 1024\n2020-06-25 16:43:33.950239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1000 next 1009 of size 1024\n2020-06-25 16:43:33.950254: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1400 next 1010 of size 1024\n2020-06-25 16:43:33.950267: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1800 next 1011 of size 1024\n2020-06-25 16:43:33.950283: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1c00 next 1012 of size 262144\n2020-06-25 16:43:33.950301: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cf1c00 next 1013 of size 1179648\n2020-06-25 16:43:33.950318: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812e11c00 next 1014 of size 1179648\n2020-06-25 16:43:33.950336: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f31c00 next 1015 of size 262144\n2020-06-25 16:43:33.950353: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f71c00 next 1016 of size 262144\n2020-06-25 16:43:33.950368: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812fb1c00 next 1017 of size 524288\n2020-06-25 16:43:33.950382: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813031c00 next 1018 of size 524288\n2020-06-25 16:43:33.950399: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8130b1c00 next 1019 of size 2359296\n2020-06-25 16:43:33.950415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8132f1c00 next 1020 of size 2359296\n2020-06-25 16:43:33.950433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813531c00 next 1021 of size 12288\n2020-06-25 16:43:33.950452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813534c00 next 1022 of size 12288\n2020-06-25 16:43:33.950471: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813537c00 next 1023 of size 2048\n2020-06-25 16:43:33.950490: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813538400 next 1024 of size 1179648\n2020-06-25 16:43:33.950508: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813658400 next 1025 of size 1179648\n2020-06-25 16:43:33.950526: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778400 next 1026 of size 256\n2020-06-25 16:43:33.950546: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778500 next 1027 of size 1024\n2020-06-25 16:43:33.950563: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778900 next 1028 of size 1024\n2020-06-25 16:43:33.950580: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778d00 next 1029 of size 2359296\n2020-06-25 16:43:33.950595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b8d00 next 1030 of size 1024\n2020-06-25 16:43:33.950612: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9100 next 1031 of size 1024\n2020-06-25 16:43:33.950630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9500 next 1032 of size 37632\n2020-06-25 16:43:33.950663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139c2800 next 1033 of size 37632\n2020-06-25 16:43:33.950696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139cbb00 next 1034 of size 524288\n2020-06-25 16:43:33.950712: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813a4bb00 next 1035 of size 524288\n2020-06-25 16:43:33.950728: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813acbb00 next 1036 of size 37632\n2020-06-25 16:43:33.950743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ad4e00 next 1037 of size 37632\n2020-06-25 16:43:33.950758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ade100 next 1038 of size 524288\n2020-06-25 16:43:33.950775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813b5e100 next 1039 of size 524288\n2020-06-25 16:43:33.950792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813bde100 next 1040 of size 262144\n2020-06-25 16:43:33.950827: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c1e100 next 1041 of size 262144\n2020-06-25 16:43:33.950856: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c5e100 next 1042 of size 2359296\n2020-06-25 16:43:33.950875: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813e9e100 next 1043 of size 2359296\n2020-06-25 16:43:33.950891: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8140de100 next 1044 of size 8388608\n2020-06-25 16:43:33.950903: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8148de100 next 1045 of size 8388608\n2020-06-25 16:43:33.950917: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8150de100 next 1046 of size 262144\n2020-06-25 16:43:33.950932: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81511e100 next 1047 of size 262144\n2020-06-25 16:43:33.950951: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81515e100 next 1048 of size 2359296\n2020-06-25 16:43:33.950978: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81539e100 next 1049 of size 2359296\n2020-06-25 16:43:33.950999: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8155de100 next 1050 of size 33554432\n2020-06-25 16:43:33.951016: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8175de100 next 1051 of size 33554432\n2020-06-25 16:43:33.951033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195de100 next 1052 of size 131072\n2020-06-25 16:43:33.951049: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe100 next 1053 of size 1024\n2020-06-25 16:43:33.951064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe500 next 1054 of size 1024\n2020-06-25 16:43:33.951080: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe900 next 1055 of size 2097152\n2020-06-25 16:43:33.951095: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fe900 next 1056 of size 1024\n2020-06-25 16:43:33.951111: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fed00 next 1057 of size 131072\n2020-06-25 16:43:33.951126: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981ed00 next 1058 of size 1024\n2020-06-25 16:43:33.951143: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f100 next 1059 of size 1024\n2020-06-25 16:43:33.951161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f500 next 1060 of size 2359296\n2020-06-25 16:43:33.951177: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819a5f500 next 1061 of size 2359296\n2020-06-25 16:43:33.951193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819c9f500 next 1062 of size 2359296\n2020-06-25 16:43:33.951222: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819edf500 next 1063 of size 2359296\n2020-06-25 16:43:33.951257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a11f500 next 1064 of size 2359296\n2020-06-25 16:43:33.951290: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a35f500 next 1065 of size 2359296\n2020-06-25 16:43:33.951309: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a59f500 next 18446744073709551615 of size 158075648\n2020-06-25 16:43:33.951327: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4294967296\n2020-06-25 16:43:33.951344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x823e60000 next 678 of size 1073741824\n2020-06-25 16:43:33.951360: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x863e60000 next 962 of size 1073741824\n2020-06-25 16:43:33.951376: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8a3e60000 next 973 of size 1073741824\n2020-06-25 16:43:33.951392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8e3e60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:33.951408: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2202261760\n2020-06-25 16:43:33.951424: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x923e60000 next 1000 of size 1073741824\n2020-06-25 16:43:33.951465: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x963e60000 next 1066 of size 134217728\n2020-06-25 16:43:33.951487: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be60000 next 1067 of size 12288\n2020-06-25 16:43:33.951505: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be63000 next 1068 of size 12288\n2020-06-25 16:43:33.951534: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be66000 next 1069 of size 33554432\n2020-06-25 16:43:33.951552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96de66000 next 1070 of size 33554432\n2020-06-25 16:43:33.951568: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe66000 next 1071 of size 12288\n2020-06-25 16:43:33.951585: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe69000 next 1072 of size 12288\n2020-06-25 16:43:33.951602: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c000 next 1073 of size 2048\n2020-06-25 16:43:33.951618: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c800 next 1074 of size 262144\n2020-06-25 16:43:33.951634: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feac800 next 1075 of size 262144\n2020-06-25 16:43:33.951659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feec800 next 1076 of size 2359296\n2020-06-25 16:43:33.951675: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97012c800 next 1077 of size 2359296\n2020-06-25 16:43:33.951692: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97036c800 next 1078 of size 294912\n2020-06-25 16:43:33.951708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703b4800 next 1079 of size 294912\n2020-06-25 16:43:33.951724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703fc800 next 1080 of size 2097152\n2020-06-25 16:43:33.951740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fc800 next 1081 of size 1024\n2020-06-25 16:43:33.951756: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fcc00 next 1082 of size 1024\n2020-06-25 16:43:33.951771: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fd000 next 1083 of size 2359296\n2020-06-25 16:43:33.951788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d000 next 1084 of size 1024\n2020-06-25 16:43:33.951804: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d400 next 1085 of size 2048\n2020-06-25 16:43:33.951849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083dc00 next 1086 of size 294912\n2020-06-25 16:43:33.951868: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970885c00 next 1087 of size 294912\n2020-06-25 16:43:33.951885: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9708cdc00 next 1088 of size 294912\n2020-06-25 16:43:33.951902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970915c00 next 1089 of size 294912\n2020-06-25 16:43:33.951918: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97095dc00 next 1090 of size 37632\n2020-06-25 16:43:33.951934: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970966f00 next 1091 of size 37632\n2020-06-25 16:43:33.951950: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970970200 next 1092 of size 2359296\n2020-06-25 16:43:33.951967: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970bb0200 next 1093 of size 2359296\n2020-06-25 16:43:33.951983: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df0200 next 1094 of size 8192\n2020-06-25 16:43:33.951999: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df2200 next 1095 of size 8192\n2020-06-25 16:43:33.952015: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df4200 next 1096 of size 8192\n2020-06-25 16:43:33.952031: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df6200 next 1097 of size 2359296\n2020-06-25 16:43:33.952047: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971036200 next 1098 of size 2359296\n2020-06-25 16:43:33.952063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971276200 next 1099 of size 262144\n2020-06-25 16:43:33.952079: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712b6200 next 1100 of size 262144\n2020-06-25 16:43:33.952095: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712f6200 next 1101 of size 2097152\n2020-06-25 16:43:33.952111: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9714f6200 next 1102 of size 2097152\n2020-06-25 16:43:33.952127: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9716f6200 next 1103 of size 134217728\n2020-06-25 16:43:33.952144: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9796f6200 next 1104 of size 134217728\n2020-06-25 16:43:33.952163: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6200 next 1105 of size 512\n2020-06-25 16:43:33.952180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6400 next 1106 of size 512\n2020-06-25 16:43:33.952196: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6600 next 1107 of size 1024\n2020-06-25 16:43:33.952212: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6a00 next 1108 of size 2359296\n2020-06-25 16:43:33.952227: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981936a00 next 1109 of size 2359296\n2020-06-25 16:43:33.952243: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981b76a00 next 1110 of size 8388608\n2020-06-25 16:43:33.952259: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376a00 next 1111 of size 1024\n2020-06-25 16:43:33.952275: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376e00 next 1112 of size 1024\n2020-06-25 16:43:33.952291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982377200 next 1113 of size 12288\n2020-06-25 16:43:33.952307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237a200 next 1114 of size 12288\n2020-06-25 16:43:33.952322: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237d200 next 1115 of size 2097152\n2020-06-25 16:43:33.952338: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98257d200 next 1116 of size 2097152\n2020-06-25 16:43:33.952354: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98277d200 next 1117 of size 8388608\n2020-06-25 16:43:33.952370: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982f7d200 next 1118 of size 8388608\n2020-06-25 16:43:33.952385: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377d200 next 1119 of size 8192\n2020-06-25 16:43:33.952401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377f200 next 1120 of size 8192\n2020-06-25 16:43:33.952417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983781200 next 1121 of size 524288\n2020-06-25 16:43:33.952433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983801200 next 1122 of size 524288\n2020-06-25 16:43:34.056635: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983881200 next 1123 of size 2359296\n2020-06-25 16:43:34.056705: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983ac1200 next 1124 of size 2359296\n2020-06-25 16:43:34.056738: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983d01200 next 1125 of size 2359296\n2020-06-25 16:43:34.056769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983f41200 next 1126 of size 2359296\n2020-06-25 16:43:34.056788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984181200 next 1127 of size 37632\n2020-06-25 16:43:34.056806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98418a500 next 1128 of size 37632\n2020-06-25 16:43:34.056846: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193800 next 1129 of size 1024\n2020-06-25 16:43:34.056865: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193c00 next 1130 of size 2048\n2020-06-25 16:43:34.056882: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984194400 next 1131 of size 2359296\n2020-06-25 16:43:34.056899: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4400 next 1132 of size 1024\n2020-06-25 16:43:34.056928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4800 next 1133 of size 2359296\n2020-06-25 16:43:34.056945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984614800 next 1134 of size 2359296\n2020-06-25 16:43:34.056961: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984854800 next 1135 of size 2359296\n2020-06-25 16:43:34.056977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984a94800 next 1136 of size 2359296\n2020-06-25 16:43:34.056994: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984cd4800 next 1137 of size 2359296\n2020-06-25 16:43:34.057010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984f14800 next 1138 of size 2359296\n2020-06-25 16:43:34.057027: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154800 next 1139 of size 1024\n2020-06-25 16:43:34.057043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154c00 next 1140 of size 512\n2020-06-25 16:43:34.057059: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154e00 next 1141 of size 8192\n2020-06-25 16:43:34.057075: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985156e00 next 1142 of size 8192\n2020-06-25 16:43:34.057092: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985158e00 next 1143 of size 1024\n2020-06-25 16:43:34.057108: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159200 next 1144 of size 2048\n2020-06-25 16:43:34.057125: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159a00 next 1145 of size 1024\n2020-06-25 16:43:34.057147: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159e00 next 1146 of size 1024\n2020-06-25 16:43:34.057186: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98515a200 next 1147 of size 8388608\n2020-06-25 16:43:34.057211: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98595a200 next 1148 of size 524288\n2020-06-25 16:43:34.057231: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9859da200 next 1149 of size 524288\n2020-06-25 16:43:34.057246: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985a5a200 next 1150 of size 2359296\n2020-06-25 16:43:34.057263: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985c9a200 next 1151 of size 2359296\n2020-06-25 16:43:34.057279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985eda200 next 1152 of size 2097152\n2020-06-25 16:43:34.057295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9860da200 next 1153 of size 2097152\n2020-06-25 16:43:34.057311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9862da200 next 1154 of size 2359296\n2020-06-25 16:43:34.057327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98651a200 next 1155 of size 2359296\n2020-06-25 16:43:34.057343: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a200 next 1156 of size 1024\n2020-06-25 16:43:34.057358: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a600 next 1157 of size 2359296\n2020-06-25 16:43:34.057374: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98699a600 next 1158 of size 2359296\n2020-06-25 16:43:34.057390: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bda600 next 1159 of size 1024\n2020-06-25 16:43:34.057406: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaa00 next 1160 of size 256\n2020-06-25 16:43:34.057421: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdab00 next 1161 of size 256\n2020-06-25 16:43:34.057441: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdac00 next 1162 of size 256\n2020-06-25 16:43:34.057460: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdad00 next 1163 of size 256\n2020-06-25 16:43:34.057477: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdae00 next 1164 of size 256\n2020-06-25 16:43:34.057494: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaf00 next 1165 of size 256\n2020-06-25 16:43:34.057510: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb000 next 1166 of size 256\n2020-06-25 16:43:34.057526: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb100 next 1167 of size 256\n2020-06-25 16:43:34.057543: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb200 next 1168 of size 256\n2020-06-25 16:43:34.057560: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb300 next 1169 of size 256\n2020-06-25 16:43:34.057576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb400 next 1170 of size 256\n2020-06-25 16:43:34.057592: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb500 next 1171 of size 256\n2020-06-25 16:43:34.057621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb600 next 1172 of size 256\n2020-06-25 16:43:34.057638: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb700 next 1173 of size 256\n2020-06-25 16:43:34.057654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb800 next 1174 of size 256\n2020-06-25 16:43:34.057671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb900 next 1175 of size 256\n2020-06-25 16:43:34.057689: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdba00 next 1176 of size 256\n2020-06-25 16:43:34.057706: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbb00 next 1177 of size 256\n2020-06-25 16:43:34.057723: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbc00 next 1178 of size 256\n2020-06-25 16:43:34.057740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbd00 next 1179 of size 256\n2020-06-25 16:43:34.057756: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbe00 next 1180 of size 256\n2020-06-25 16:43:34.057773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbf00 next 1181 of size 256\n2020-06-25 16:43:34.057789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc000 next 1182 of size 256\n2020-06-25 16:43:34.057806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc100 next 1183 of size 256\n2020-06-25 16:43:34.057845: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc200 next 1184 of size 256\n2020-06-25 16:43:34.057864: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc300 next 1185 of size 256\n2020-06-25 16:43:34.057880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc400 next 1186 of size 256\n2020-06-25 16:43:34.057896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc500 next 1187 of size 256\n2020-06-25 16:43:34.057913: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc600 next 1188 of size 256\n2020-06-25 16:43:34.057929: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc700 next 1189 of size 256\n2020-06-25 16:43:34.057945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc800 next 1190 of size 256\n2020-06-25 16:43:34.057961: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc900 next 1191 of size 256\n2020-06-25 16:43:34.057977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdca00 next 1192 of size 256\n2020-06-25 16:43:34.057993: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcb00 next 1193 of size 256\n2020-06-25 16:43:34.058014: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcc00 next 1194 of size 256\n2020-06-25 16:43:34.058070: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcd00 next 1195 of size 256\n2020-06-25 16:43:34.058090: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdce00 next 1196 of size 256\n2020-06-25 16:43:34.058103: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcf00 next 1197 of size 256\n2020-06-25 16:43:34.058114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd000 next 1198 of size 256\n2020-06-25 16:43:34.058905: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd100 next 1199 of size 256\n2020-06-25 16:43:34.058932: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd200 next 1200 of size 256\n2020-06-25 16:43:34.058950: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd300 next 1201 of size 256\n2020-06-25 16:43:34.058968: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd400 next 1202 of size 256\n2020-06-25 16:43:34.058985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd500 next 1203 of size 256\n2020-06-25 16:43:34.059001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd600 next 1204 of size 256\n2020-06-25 16:43:34.059018: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd700 next 1205 of size 256\n2020-06-25 16:43:34.059034: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd800 next 1206 of size 256\n2020-06-25 16:43:34.059050: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd900 next 1207 of size 256\n2020-06-25 16:43:34.059066: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdda00 next 1208 of size 256\n2020-06-25 16:43:34.059082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddb00 next 1209 of size 256\n2020-06-25 16:43:34.059098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddc00 next 1210 of size 256\n2020-06-25 16:43:34.059114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddd00 next 1211 of size 256\n2020-06-25 16:43:34.059130: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdde00 next 1212 of size 256\n2020-06-25 16:43:34.059147: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddf00 next 1213 of size 256\n2020-06-25 16:43:34.059162: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde000 next 1214 of size 256\n2020-06-25 16:43:34.059195: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde100 next 1215 of size 256\n2020-06-25 16:43:34.059211: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde200 next 1216 of size 256\n2020-06-25 16:43:34.059228: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde300 next 1217 of size 256\n2020-06-25 16:43:34.059244: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde400 next 1218 of size 256\n2020-06-25 16:43:34.059259: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde500 next 1219 of size 256\n2020-06-25 16:43:34.059275: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde600 next 1220 of size 256\n2020-06-25 16:43:34.059291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde700 next 1221 of size 256\n2020-06-25 16:43:34.059307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde800 next 1222 of size 256\n2020-06-25 16:43:34.059323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde900 next 1223 of size 256\n2020-06-25 16:43:34.059339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdea00 next 1224 of size 256\n2020-06-25 16:43:34.059356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdeb00 next 1225 of size 256\n2020-06-25 16:43:34.059372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdec00 next 1226 of size 256\n2020-06-25 16:43:34.059388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bded00 next 1227 of size 256\n2020-06-25 16:43:34.059404: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdee00 next 1228 of size 256\n2020-06-25 16:43:34.059420: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdef00 next 1229 of size 256\n2020-06-25 16:43:34.059436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf000 next 1230 of size 256\n2020-06-25 16:43:34.059452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf100 next 1231 of size 256\n2020-06-25 16:43:34.059468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf200 next 1232 of size 4096\n2020-06-25 16:43:34.059484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0200 next 1233 of size 256\n2020-06-25 16:43:34.059500: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0300 next 1234 of size 4096\n2020-06-25 16:43:34.059516: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1300 next 1235 of size 256\n2020-06-25 16:43:34.059532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1400 next 1236 of size 1024\n2020-06-25 16:43:34.059548: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1800 next 1237 of size 256\n2020-06-25 16:43:34.059564: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1900 next 1238 of size 1024\n2020-06-25 16:43:34.059581: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1d00 next 1239 of size 512\n2020-06-25 16:43:34.059603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1f00 next 1240 of size 256\n2020-06-25 16:43:34.059624: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2000 next 1241 of size 1024\n2020-06-25 16:43:34.059641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2400 next 1242 of size 1024\n2020-06-25 16:43:34.059657: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2800 next 1243 of size 1024\n2020-06-25 16:43:34.059674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2c00 next 1358 of size 256\n2020-06-25 16:43:34.059691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2d00 next 1375 of size 256\n2020-06-25 16:43:34.059708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2e00 next 1380 of size 256\n2020-06-25 16:43:34.059724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2f00 next 1244 of size 256\n2020-06-25 16:43:34.059739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3000 next 1245 of size 1024\n2020-06-25 16:43:34.059755: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3400 next 1246 of size 1024\n2020-06-25 16:43:34.059771: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3800 next 1247 of size 1024\n2020-06-25 16:43:34.059788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3c00 next 1248 of size 256\n2020-06-25 16:43:34.059804: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3d00 next 1249 of size 256\n2020-06-25 16:43:34.059849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3e00 next 1250 of size 256\n2020-06-25 16:43:34.059867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3f00 next 1251 of size 256\n2020-06-25 16:43:34.059890: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be4000 next 1252 of size 8192\n2020-06-25 16:43:34.059907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6000 next 1253 of size 256\n2020-06-25 16:43:34.059924: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6100 next 1254 of size 256\n2020-06-25 16:43:34.059940: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6200 next 1255 of size 256\n2020-06-25 16:43:34.059956: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6300 next 1256 of size 256\n2020-06-25 16:43:34.059972: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6400 next 1257 of size 2048\n2020-06-25 16:43:34.059988: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6c00 next 1258 of size 256\n2020-06-25 16:43:34.060004: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6d00 next 1259 of size 256\n2020-06-25 16:43:34.060020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6e00 next 1260 of size 256\n2020-06-25 16:43:34.060036: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6f00 next 1261 of size 256\n2020-06-25 16:43:34.060052: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be7000 next 1262 of size 8192\n2020-06-25 16:43:34.060067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9000 next 1263 of size 256\n2020-06-25 16:43:34.060083: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9100 next 1264 of size 256\n2020-06-25 16:43:34.060099: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9200 next 1265 of size 256\n2020-06-25 16:43:34.060115: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9300 next 1266 of size 2048\n2020-06-25 16:43:34.060130: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9b00 next 1267 of size 256\n2020-06-25 16:43:34.060146: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9c00 next 1268 of size 256\n2020-06-25 16:43:34.060161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9d00 next 1269 of size 2048\n2020-06-25 16:43:34.060186: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea500 next 1270 of size 256\n2020-06-25 16:43:34.155189: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea600 next 1271 of size 2048\n2020-06-25 16:43:34.155239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beae00 next 1272 of size 256\n2020-06-25 16:43:34.155265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beaf00 next 1273 of size 256\n2020-06-25 16:43:34.155285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb000 next 1274 of size 256\n2020-06-25 16:43:34.155306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb100 next 1275 of size 256\n2020-06-25 16:43:34.155337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb200 next 1276 of size 256\n2020-06-25 16:43:34.155360: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb300 next 1277 of size 256\n2020-06-25 16:43:34.155380: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb400 next 1278 of size 256\n2020-06-25 16:43:34.155400: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb500 next 1279 of size 1024\n2020-06-25 16:43:34.155419: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb900 next 1280 of size 1024\n2020-06-25 16:43:34.155439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bebd00 next 1281 of size 1024\n2020-06-25 16:43:34.155459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec100 next 1282 of size 1024\n2020-06-25 16:43:34.155484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec500 next 1283 of size 512\n2020-06-25 16:43:34.155511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec700 next 1405 of size 256\n2020-06-25 16:43:34.155536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bec800 next 1284 of size 768\n2020-06-25 16:43:34.155559: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becb00 next 1285 of size 1024\n2020-06-25 16:43:34.155582: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becf00 next 1286 of size 1024\n2020-06-25 16:43:34.155605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed300 next 1287 of size 1024\n2020-06-25 16:43:34.155641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed700 next 1288 of size 1024\n2020-06-25 16:43:34.155665: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedb00 next 1289 of size 256\n2020-06-25 16:43:34.155688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedc00 next 1290 of size 256\n2020-06-25 16:43:34.155710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedd00 next 1291 of size 256\n2020-06-25 16:43:34.155731: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bede00 next 1292 of size 256\n2020-06-25 16:43:34.155754: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedf00 next 1293 of size 256\n2020-06-25 16:43:34.155776: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bee000 next 1294 of size 256\n2020-06-25 16:43:34.155799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bee100 next 1295 of size 8192\n2020-06-25 16:43:34.155856: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf0100 next 1296 of size 8192\n2020-06-25 16:43:34.155885: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2100 next 1297 of size 256\n2020-06-25 16:43:34.155922: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2200 next 1298 of size 256\n2020-06-25 16:43:34.155946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2300 next 1299 of size 256\n2020-06-25 16:43:34.155982: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2400 next 1300 of size 33554432\n2020-06-25 16:43:34.156005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bf2400 next 1301 of size 32768\n2020-06-25 16:43:34.156020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bfa400 next 1302 of size 524288\n2020-06-25 16:43:34.156039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7a400 next 1303 of size 4096\n2020-06-25 16:43:34.156073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7b400 next 1304 of size 12288\n2020-06-25 16:43:34.156095: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e400 next 1305 of size 256\n2020-06-25 16:43:34.156119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e500 next 1306 of size 524288\n2020-06-25 16:43:34.156165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cfe500 next 1307 of size 4096\n2020-06-25 16:43:34.156196: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cff500 next 1308 of size 32768\n2020-06-25 16:43:34.156221: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d07500 next 1309 of size 32768\n2020-06-25 16:43:34.156245: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d0f500 next 1310 of size 8388608\n2020-06-25 16:43:34.156269: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98950f500 next 1311 of size 16384\n2020-06-25 16:43:34.156294: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989513500 next 1312 of size 131072\n2020-06-25 16:43:34.156342: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989533500 next 1313 of size 131072\n2020-06-25 16:43:34.156372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989553500 next 1314 of size 524288\n2020-06-25 16:43:34.156398: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d3500 next 1315 of size 4096\n2020-06-25 16:43:34.156422: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d4500 next 1316 of size 8388608\n2020-06-25 16:43:34.156458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd4500 next 1317 of size 16384\n2020-06-25 16:43:34.156482: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd8500 next 1318 of size 134217728\n2020-06-25 16:43:34.156506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dd8500 next 1319 of size 65536\n2020-06-25 16:43:34.156530: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991de8500 next 1320 of size 8192\n2020-06-25 16:43:34.156553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dea500 next 1321 of size 12288\n2020-06-25 16:43:34.156604: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded500 next 1322 of size 256\n2020-06-25 16:43:34.156630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded600 next 1323 of size 2097152\n2020-06-25 16:43:34.156654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fed600 next 1324 of size 8192\n2020-06-25 16:43:34.156669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fef600 next 1325 of size 2097152\n2020-06-25 16:43:34.156689: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921ef600 next 1326 of size 8192\n2020-06-25 16:43:34.156733: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921f1600 next 1327 of size 2097152\n2020-06-25 16:43:34.156758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f1600 next 1328 of size 8192\n2020-06-25 16:43:34.156781: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3600 next 1389 of size 256\n2020-06-25 16:43:34.156806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3700 next 1392 of size 256\n2020-06-25 16:43:34.156853: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3800 next 1394 of size 256\n2020-06-25 16:43:34.156877: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3900 next 1398 of size 1024\n2020-06-25 16:43:34.156899: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9923f3d00 next 1330 of size 2304\n2020-06-25 16:43:34.156923: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f4600 next 1331 of size 32768\n2020-06-25 16:43:34.156969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923fc600 next 1332 of size 32768\n2020-06-25 16:43:34.156995: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992404600 next 1333 of size 12288\n2020-06-25 16:43:34.157019: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407600 next 1334 of size 256\n2020-06-25 16:43:34.157041: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407700 next 1335 of size 12288\n2020-06-25 16:43:34.157064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a700 next 1336 of size 256\n2020-06-25 16:43:34.157086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a800 next 1337 of size 8388608\n2020-06-25 16:43:34.157107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0a800 next 1338 of size 16384\n2020-06-25 16:43:34.157129: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0e800 next 1339 of size 2097152\n2020-06-25 16:43:34.157165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e0e800 next 1340 of size 8192\n2020-06-25 16:43:34.157209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e10800 next 1341 of size 524288\n2020-06-25 16:43:34.157236: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e90800 next 1342 of size 4096\n2020-06-25 16:43:34.157259: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e91800 next 1343 of size 131072\n2020-06-25 16:43:34.157295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992eb1800 next 1344 of size 131072\n2020-06-25 16:43:34.157319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992ed1800 next 1345 of size 33554432\n2020-06-25 16:43:34.157343: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994ed1800 next 1346 of size 32768\n2020-06-25 16:43:34.157366: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x994ed9800 next 1347 of size 8192\n2020-06-25 16:43:34.157391: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994edb800 next 1348 of size 8388608\n2020-06-25 16:43:34.157416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956db800 next 1349 of size 16384\n2020-06-25 16:43:34.157459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956df800 next 1350 of size 134217728\n2020-06-25 16:43:34.157488: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6df800 next 1351 of size 65536\n2020-06-25 16:43:34.157514: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6ef800 next 1352 of size 33554432\n2020-06-25 16:43:34.157540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6ef800 next 1353 of size 32768\n2020-06-25 16:43:34.157578: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7800 next 1354 of size 1024\n2020-06-25 16:43:34.157602: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7c00 next 1355 of size 524288\n2020-06-25 16:43:34.157626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f777c00 next 1356 of size 4096\n2020-06-25 16:43:34.157648: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f778c00 next 1357 of size 12288\n2020-06-25 16:43:34.157671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f77bc00 next 1359 of size 524288\n2020-06-25 16:43:34.157695: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fbc00 next 1360 of size 4096\n2020-06-25 16:43:34.157720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fcc00 next 1361 of size 8192\n2020-06-25 16:43:34.157743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fec00 next 1362 of size 2097152\n2020-06-25 16:43:34.157766: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f9fec00 next 1363 of size 32768\n2020-06-25 16:43:34.157788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa06c00 next 1364 of size 32768\n2020-06-25 16:43:34.157828: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa0ec00 next 1365 of size 8388608\n2020-06-25 16:43:34.157872: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a020ec00 next 1366 of size 16384\n2020-06-25 16:43:34.157905: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0212c00 next 1367 of size 2048\n2020-06-25 16:43:34.157930: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0213400 next 1368 of size 131072\n2020-06-25 16:43:34.157952: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0233400 next 1369 of size 131072\n2020-06-25 16:43:34.157973: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0253400 next 1370 of size 524288\n2020-06-25 16:43:34.157993: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3400 next 1371 of size 4096\n2020-06-25 16:43:34.158017: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d4400 next 1372 of size 8388608\n2020-06-25 16:43:34.158040: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ad4400 next 1373 of size 16384\n2020-06-25 16:43:34.158063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ad8400 next 1381 of size 65536\n2020-06-25 16:43:34.158085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ae8400 next 1382 of size 12288\n2020-06-25 16:43:34.158109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0aeb400 next 1376 of size 2294016\n2020-06-25 16:43:34.158133: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0d1b500 next 1377 of size 798976\n2020-06-25 16:43:34.158171: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0dde600 next 1378 of size 798976\n2020-06-25 16:43:34.158193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ea1700 next 1379 of size 4194304\n2020-06-25 16:43:34.158217: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a12a1700 next 1374 of size 4194304\n2020-06-25 16:43:34.158264: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1700 next 1383 of size 2048\n2020-06-25 16:43:34.158299: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1f00 next 1384 of size 2097152\n2020-06-25 16:43:34.158322: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a1f00 next 1385 of size 8192\n2020-06-25 16:43:34.158345: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a3f00 next 1386 of size 2097152\n2020-06-25 16:43:34.158368: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa3f00 next 1387 of size 8192\n2020-06-25 16:43:34.158405: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa5f00 next 1388 of size 33554432\n2020-06-25 16:43:34.158429: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aa5f00 next 1329 of size 32768\n2020-06-25 16:43:34.158451: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aadf00 next 1390 of size 32768\n2020-06-25 16:43:34.158483: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab5f00 next 1391 of size 12288\n2020-06-25 16:43:34.158518: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab8f00 next 1393 of size 12288\n2020-06-25 16:43:34.158540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3abbf00 next 1395 of size 2097152\n2020-06-25 16:43:34.158562: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3cbbf00 next 1396 of size 8388608\n2020-06-25 16:43:34.158586: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bbf00 next 1397 of size 16384\n2020-06-25 16:43:34.158610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bff00 next 1399 of size 2097152\n2020-06-25 16:43:34.158633: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46bff00 next 1400 of size 8192\n2020-06-25 16:43:34.158659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46c1f00 next 1401 of size 524288\n2020-06-25 16:43:34.158690: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4741f00 next 1402 of size 4096\n2020-06-25 16:43:34.158716: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4742f00 next 1403 of size 131072\n2020-06-25 16:43:34.158739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4762f00 next 1404 of size 131072\n2020-06-25 16:43:34.158761: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4782f00 next 18446744073709551615 of size 45197824\n2020-06-25 16:43:34.158784: I tensorflow/core/common_runtime/bfc_allocator.cc:914] Summary of in-use Chunks by size: \n2020-06-25 16:43:34.158832: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 354 Chunks of size 256 totalling 88.5KiB\n2020-06-25 16:43:34.158869: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 82 Chunks of size 512 totalling 41.0KiB\n2020-06-25 16:43:34.158899: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 464 Chunks of size 1024 totalling 464.0KiB\n2020-06-25 16:43:34.158927: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 1280 totalling 1.2KiB\n2020-06-25 16:43:34.158953: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 42 Chunks of size 2048 totalling 84.0KiB\n2020-06-25 16:43:34.158980: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 20 Chunks of size 4096 totalling 80.0KiB\n2020-06-25 16:43:34.159007: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 39 Chunks of size 8192 totalling 312.0KiB\n2020-06-25 16:43:34.159034: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 12288 totalling 288.0KiB\n2020-06-25 16:43:34.159062: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 7 Chunks of size 16384 totalling 112.0KiB\n2020-06-25 16:43:34.159090: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 32768 totalling 608.0KiB\n2020-06-25 16:43:34.159116: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 37632 totalling 588.0KiB\n2020-06-25 16:43:34.159151: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 3 Chunks of size 65536 totalling 192.0KiB\n2020-06-25 16:43:34.159181: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 131072 totalling 2.00MiB\n2020-06-25 16:43:34.159208: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 262144 totalling 6.00MiB\n2020-06-25 16:43:34.159233: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 15 Chunks of size 294912 totalling 4.22MiB\n2020-06-25 16:43:34.159257: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 447232 totalling 436.8KiB\n2020-06-25 16:43:34.159283: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 32 Chunks of size 524288 totalling 16.00MiB\n2020-06-25 16:43:34.159310: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 2 Chunks of size 798976 totalling 1.52MiB\n2020-06-25 16:43:34.159335: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 1179648 totalling 18.00MiB\n2020-06-25 16:43:34.159359: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 33 Chunks of size 2097152 totalling 66.00MiB\n2020-06-25 16:43:34.159384: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 2294016 totalling 2.19MiB\n2020-06-25 16:43:34.159409: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 122 Chunks of size 2359296 totalling 274.50MiB\n2020-06-25 16:43:34.159435: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3070464 totalling 2.93MiB\n2020-06-25 16:43:34.159461: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3145728 totalling 3.00MiB\n2020-06-25 16:43:34.159488: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3266560 totalling 3.12MiB\n2020-06-25 16:43:34.159515: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3400960 totalling 3.24MiB\n2020-06-25 16:43:34.159541: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 4 Chunks of size 4194304 totalling 16.00MiB\n2020-06-25 16:43:34.159565: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 23 Chunks of size 8388608 totalling 184.00MiB\n2020-06-25 16:43:34.159591: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 33554432 totalling 608.00MiB\n2020-06-25 16:43:34.159617: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 45197824 totalling 43.10MiB\n2020-06-25 16:43:34.159644: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 56033280 totalling 53.44MiB\n2020-06-25 16:43:34.159671: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 9 Chunks of size 134217728 totalling 1.12GiB\n2020-06-25 16:43:34.159696: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 158075648 totalling 150.75MiB\n2020-06-25 16:43:34.159720: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 8 Chunks of size 1073741824 totalling 8.00GiB\n2020-06-25 16:43:34.159747: I tensorflow/core/common_runtime/bfc_allocator.cc:921] Sum Total of in-use chunks: 10.55GiB\n2020-06-25 16:43:34.159772: I tensorflow/core/common_runtime/bfc_allocator.cc:923] total_region_allocated_bytes_: 11330115840 memory_limit_: 11330115994 available bytes: 154 curr_region_allocation_bytes_: 17179869184\n2020-06-25 16:43:34.159800: I tensorflow/core/common_runtime/bfc_allocator.cc:929] Stats: \nLimit: 11330115994\nInUse: 11330104576\nMaxInUse: 11330112768\nNumAllocs: 1643\nMaxAllocSize: 1073741824\n\n2020-06-25 16:43:34.159940: W tensorflow/core/common_runtime/bfc_allocator.cc:424] ****************************************************************************************************\n2020-06-25 16:43:34.160032: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at cwise_ops_common.cc:82 : Resource exhausted: OOM when allocating tensor with shape[4,4,1024,2048] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc\n2020-06-25 16:43:44.161139: W tensorflow/core/common_runtime/bfc_allocator.cc:419] Allocator (GPU_0_bfc) ran out of memory trying to allocate 64.0KiB (rounded to 65536). Current allocation summary follows.\n2020-06-25 16:43:44.161239: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (256): \tTotal Chunks: 325, Chunks in use: 323. 81.2KiB allocated for chunks. 80.8KiB in use in bin. 23.6KiB client-requested in use in bin.\n2020-06-25 16:43:44.161272: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (512): \tTotal Chunks: 86, Chunks in use: 82. 43.5KiB allocated for chunks. 41.0KiB in use in bin. 41.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161301: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (1024): \tTotal Chunks: 470, Chunks in use: 465. 470.8KiB allocated for chunks. 465.2KiB in use in bin. 465.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161327: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (2048): \tTotal Chunks: 43, Chunks in use: 42. 86.2KiB allocated for chunks. 84.0KiB in use in bin. 84.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161353: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (4096): \tTotal Chunks: 20, Chunks in use: 20. 80.0KiB allocated for chunks. 80.0KiB in use in bin. 80.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161376: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (8192): \tTotal Chunks: 64, Chunks in use: 63. 608.0KiB allocated for chunks. 600.0KiB in use in bin. 600.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161410: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (16384): \tTotal Chunks: 7, Chunks in use: 7. 112.0KiB allocated for chunks. 112.0KiB in use in bin. 112.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161432: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (32768): \tTotal Chunks: 35, Chunks in use: 35. 1.17MiB allocated for chunks. 1.17MiB in use in bin. 1.17MiB client-requested in use in bin.\n2020-06-25 16:43:44.161460: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (65536): \tTotal Chunks: 3, Chunks in use: 3. 192.0KiB allocated for chunks. 192.0KiB in use in bin. 192.0KiB client-requested in use in bin.\n2020-06-25 16:43:44.161485: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (131072): \tTotal Chunks: 16, Chunks in use: 16. 2.00MiB allocated for chunks. 2.00MiB in use in bin. 2.00MiB client-requested in use in bin.\n2020-06-25 16:43:44.161508: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (262144): \tTotal Chunks: 40, Chunks in use: 40. 10.64MiB allocated for chunks. 10.64MiB in use in bin. 10.50MiB client-requested in use in bin.\n2020-06-25 16:43:44.161547: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (524288): \tTotal Chunks: 34, Chunks in use: 34. 17.52MiB allocated for chunks. 17.52MiB in use in bin. 17.52MiB client-requested in use in bin.\n2020-06-25 16:43:44.161573: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (1048576): \tTotal Chunks: 16, Chunks in use: 16. 18.00MiB allocated for chunks. 18.00MiB in use in bin. 18.00MiB client-requested in use in bin.\n2020-06-25 16:43:44.161596: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (2097152): \tTotal Chunks: 160, Chunks in use: 160. 354.97MiB allocated for chunks. 354.97MiB in use in bin. 351.50MiB client-requested in use in bin.\n2020-06-25 16:43:44.161631: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (4194304): \tTotal Chunks: 4, Chunks in use: 4. 16.00MiB allocated for chunks. 16.00MiB in use in bin. 12.50MiB client-requested in use in bin.\n2020-06-25 16:43:44.161654: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (8388608): \tTotal Chunks: 23, Chunks in use: 23. 184.00MiB allocated for chunks. 184.00MiB in use in bin. 184.00MiB client-requested in use in bin.\n2020-06-25 16:43:44.161677: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (16777216): \tTotal Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.\n2020-06-25 16:43:44.161700: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (33554432): \tTotal Chunks: 21, Chunks in use: 21. 704.54MiB allocated for chunks. 704.54MiB in use in bin. 672.00MiB client-requested in use in bin.\n2020-06-25 16:43:44.161721: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (67108864): \tTotal Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.\n2020-06-25 16:43:44.161750: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (134217728): \tTotal Chunks: 10, Chunks in use: 10. 1.27GiB allocated for chunks. 1.27GiB in use in bin. 1.25GiB client-requested in use in bin.\n2020-06-25 16:43:44.161786: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (268435456): \tTotal Chunks: 8, Chunks in use: 8. 8.00GiB allocated for chunks. 8.00GiB in use in bin. 8.00GiB client-requested in use in bin.\n2020-06-25 16:43:44.161860: I tensorflow/core/common_runtime/bfc_allocator.cc:885] Bin for 64.0KiB was 64.0KiB, Chunk State: \n2020-06-25 16:43:44.161896: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1048576\n2020-06-25 16:43:44.161917: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60000 next 1 of size 2048\n2020-06-25 16:43:44.161963: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60800 next 2 of size 256\n2020-06-25 16:43:44.161992: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60900 next 3 of size 1024\n2020-06-25 16:43:44.162009: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60d00 next 4 of size 1024\n2020-06-25 16:43:44.162024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61100 next 5 of size 256\n2020-06-25 16:43:44.162040: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61200 next 6 of size 256\n2020-06-25 16:43:44.162057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61300 next 7 of size 2048\n2020-06-25 16:43:44.162073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61b00 next 8 of size 256\n2020-06-25 16:43:44.162089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61c00 next 9 of size 256\n2020-06-25 16:43:44.162104: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61d00 next 10 of size 256\n2020-06-25 16:43:44.162120: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61e00 next 11 of size 1024\n2020-06-25 16:43:44.162136: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62200 next 12 of size 256\n2020-06-25 16:43:44.162166: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62300 next 13 of size 1024\n2020-06-25 16:43:44.162183: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62700 next 14 of size 256\n2020-06-25 16:43:44.162199: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62800 next 15 of size 512\n2020-06-25 16:43:44.162215: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62a00 next 16 of size 256\n2020-06-25 16:43:44.162231: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62b00 next 17 of size 512\n2020-06-25 16:43:44.162247: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62d00 next 18 of size 512\n2020-06-25 16:43:44.162263: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62f00 next 19 of size 256\n2020-06-25 16:43:44.162279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63000 next 20 of size 1024\n2020-06-25 16:43:44.162295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63400 next 21 of size 256\n2020-06-25 16:43:44.162311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63500 next 22 of size 512\n2020-06-25 16:43:44.162326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63700 next 23 of size 1024\n2020-06-25 16:43:44.162342: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63b00 next 24 of size 1024\n2020-06-25 16:43:44.162358: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63f00 next 25 of size 512\n2020-06-25 16:43:44.162374: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64100 next 26 of size 256\n2020-06-25 16:43:44.162390: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64200 next 27 of size 512\n2020-06-25 16:43:44.162406: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64400 next 28 of size 256\n2020-06-25 16:43:44.162423: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64500 next 29 of size 256\n2020-06-25 16:43:44.162439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64600 next 30 of size 1024\n2020-06-25 16:43:44.162454: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64a00 next 31 of size 512\n2020-06-25 16:43:44.162484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64c00 next 32 of size 1024\n2020-06-25 16:43:44.162513: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65000 next 33 of size 1024\n2020-06-25 16:43:44.162544: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65400 next 34 of size 256\n2020-06-25 16:43:44.162560: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65500 next 35 of size 256\n2020-06-25 16:43:44.162576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65600 next 36 of size 1024\n2020-06-25 16:43:44.162593: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65a00 next 37 of size 1024\n2020-06-25 16:43:44.162609: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65e00 next 38 of size 1024\n2020-06-25 16:43:44.162625: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66200 next 39 of size 256\n2020-06-25 16:43:44.162641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66300 next 40 of size 256\n2020-06-25 16:43:44.162659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66400 next 41 of size 256\n2020-06-25 16:43:44.162676: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66500 next 42 of size 1024\n2020-06-25 16:43:44.162692: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66900 next 43 of size 256\n2020-06-25 16:43:44.162708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66a00 next 44 of size 512\n2020-06-25 16:43:44.162724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66c00 next 45 of size 1024\n2020-06-25 16:43:44.162740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67000 next 46 of size 1024\n2020-06-25 16:43:44.162757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67400 next 47 of size 256\n2020-06-25 16:43:44.162773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67500 next 48 of size 256\n2020-06-25 16:43:44.162790: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67600 next 49 of size 256\n2020-06-25 16:43:44.162806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67700 next 50 of size 1024\n2020-06-25 16:43:44.162842: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67b00 next 51 of size 1024\n2020-06-25 16:43:44.162861: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67f00 next 52 of size 1024\n2020-06-25 16:43:44.162877: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68300 next 53 of size 2048\n2020-06-25 16:43:44.162894: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68b00 next 54 of size 256\n2020-06-25 16:43:44.162910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68c00 next 55 of size 256\n2020-06-25 16:43:44.162928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68d00 next 56 of size 1024\n2020-06-25 16:43:44.162945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69100 next 57 of size 1024\n2020-06-25 16:43:44.162961: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69500 next 58 of size 1024\n2020-06-25 16:43:44.162977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69900 next 59 of size 1024\n2020-06-25 16:43:44.162993: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69d00 next 60 of size 256\n2020-06-25 16:43:44.163009: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69e00 next 61 of size 256\n2020-06-25 16:43:44.163025: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69f00 next 62 of size 256\n2020-06-25 16:43:44.163041: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a000 next 63 of size 1024\n2020-06-25 16:43:44.163057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a400 next 64 of size 1024\n2020-06-25 16:43:44.163073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a800 next 65 of size 1024\n2020-06-25 16:43:44.163090: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ac00 next 66 of size 256\n2020-06-25 16:43:44.163107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ad00 next 67 of size 256\n2020-06-25 16:43:44.163123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ae00 next 68 of size 256\n2020-06-25 16:43:44.163139: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6af00 next 69 of size 1024\n2020-06-25 16:43:44.163164: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6b300 next 70 of size 1024\n2020-06-25 16:43:44.163181: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6b700 next 71 of size 1024\n2020-06-25 16:43:44.163197: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6bb00 next 72 of size 2048\n2020-06-25 16:43:44.163225: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c300 next 73 of size 512\n2020-06-25 16:43:44.163242: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c500 next 74 of size 256\n2020-06-25 16:43:44.163271: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c600 next 75 of size 256\n2020-06-25 16:43:44.163287: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c700 next 76 of size 1024\n2020-06-25 16:43:44.163303: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6cb00 next 77 of size 1024\n2020-06-25 16:43:44.163320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6cf00 next 78 of size 1024\n2020-06-25 16:43:44.163336: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d300 next 79 of size 512\n2020-06-25 16:43:44.163352: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d500 next 80 of size 512\n2020-06-25 16:43:44.163368: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d700 next 81 of size 256\n2020-06-25 16:43:44.163384: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d800 next 82 of size 256\n2020-06-25 16:43:44.163400: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d900 next 83 of size 256\n2020-06-25 16:43:44.163416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6da00 next 84 of size 1024\n2020-06-25 16:43:44.163433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6de00 next 85 of size 4096\n2020-06-25 16:43:44.163449: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ee00 next 86 of size 1024\n2020-06-25 16:43:44.163465: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f200 next 87 of size 256\n2020-06-25 16:43:44.163482: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f300 next 88 of size 256\n2020-06-25 16:43:44.163498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f400 next 89 of size 1024\n2020-06-25 16:43:44.163525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f800 next 90 of size 256\n2020-06-25 16:43:44.163541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f900 next 91 of size 1024\n2020-06-25 16:43:44.163557: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6fd00 next 92 of size 1024\n2020-06-25 16:43:44.163572: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70100 next 93 of size 256\n2020-06-25 16:43:44.163588: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70200 next 94 of size 1024\n2020-06-25 16:43:44.163604: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70600 next 95 of size 256\n2020-06-25 16:43:44.163620: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70700 next 96 of size 1024\n2020-06-25 16:43:44.163636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70b00 next 97 of size 1024\n2020-06-25 16:43:44.163653: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70f00 next 98 of size 256\n2020-06-25 16:43:44.163670: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71000 next 99 of size 1024\n2020-06-25 16:43:44.163686: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71400 next 100 of size 1024\n2020-06-25 16:43:44.163703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71800 next 101 of size 8192\n2020-06-25 16:43:44.163719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73800 next 102 of size 256\n2020-06-25 16:43:44.163735: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73900 next 103 of size 1024\n2020-06-25 16:43:44.163751: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73d00 next 104 of size 256\n2020-06-25 16:43:44.163767: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73e00 next 105 of size 1024\n2020-06-25 16:43:44.163784: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74200 next 106 of size 1024\n2020-06-25 16:43:44.163799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74600 next 107 of size 1024\n2020-06-25 16:43:44.163829: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74a00 next 108 of size 256\n2020-06-25 16:43:44.163848: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74b00 next 109 of size 1024\n2020-06-25 16:43:44.163863: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74f00 next 110 of size 1024\n2020-06-25 16:43:44.163880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75300 next 111 of size 256\n2020-06-25 16:43:44.163896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75400 next 112 of size 256\n2020-06-25 16:43:44.163912: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75500 next 113 of size 1024\n2020-06-25 16:43:44.163927: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75900 next 114 of size 1024\n2020-06-25 16:43:44.163943: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75d00 next 115 of size 1024\n2020-06-25 16:43:44.163959: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76100 next 116 of size 1024\n2020-06-25 16:43:44.188412: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76500 next 117 of size 256\n2020-06-25 16:43:44.188440: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76600 next 118 of size 1024\n2020-06-25 16:43:44.188453: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76a00 next 119 of size 1024\n2020-06-25 16:43:44.188463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76e00 next 120 of size 256\n2020-06-25 16:43:44.188474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76f00 next 121 of size 1024\n2020-06-25 16:43:44.188483: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77300 next 122 of size 1024\n2020-06-25 16:43:44.188492: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77700 next 123 of size 1024\n2020-06-25 16:43:44.188500: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77b00 next 124 of size 256\n2020-06-25 16:43:44.188509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77c00 next 125 of size 1024\n2020-06-25 16:43:44.188518: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78000 next 126 of size 256\n2020-06-25 16:43:44.188527: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78100 next 127 of size 1024\n2020-06-25 16:43:44.188536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78500 next 128 of size 1024\n2020-06-25 16:43:44.188545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78900 next 129 of size 512\n2020-06-25 16:43:44.188555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78b00 next 130 of size 1024\n2020-06-25 16:43:44.188563: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78f00 next 131 of size 256\n2020-06-25 16:43:44.188573: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79000 next 132 of size 1024\n2020-06-25 16:43:44.188584: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79400 next 133 of size 1024\n2020-06-25 16:43:44.188594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79800 next 134 of size 256\n2020-06-25 16:43:44.188603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79900 next 135 of size 1024\n2020-06-25 16:43:44.188614: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79d00 next 136 of size 256\n2020-06-25 16:43:44.188626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79e00 next 137 of size 1024\n2020-06-25 16:43:44.188636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a200 next 138 of size 256\n2020-06-25 16:43:44.188647: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a300 next 139 of size 1024\n2020-06-25 16:43:44.188658: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a700 next 140 of size 1024\n2020-06-25 16:43:44.188669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ab00 next 141 of size 1024\n2020-06-25 16:43:44.188679: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7af00 next 142 of size 1024\n2020-06-25 16:43:44.188690: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b300 next 143 of size 256\n2020-06-25 16:43:44.188709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b400 next 144 of size 256\n2020-06-25 16:43:44.188741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b500 next 145 of size 1024\n2020-06-25 16:43:44.188757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b900 next 146 of size 256\n2020-06-25 16:43:44.188775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ba00 next 147 of size 1024\n2020-06-25 16:43:44.188793: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7be00 next 148 of size 1024\n2020-06-25 16:43:44.188839: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7c200 next 149 of size 1024\n2020-06-25 16:43:44.188861: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7c600 next 150 of size 1024\n2020-06-25 16:43:44.188878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ca00 next 151 of size 1024\n2020-06-25 16:43:44.188894: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ce00 next 152 of size 512\n2020-06-25 16:43:44.188911: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d000 next 153 of size 256\n2020-06-25 16:43:44.188927: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d100 next 154 of size 256\n2020-06-25 16:43:44.188942: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d200 next 155 of size 1024\n2020-06-25 16:43:44.188959: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d600 next 156 of size 1024\n2020-06-25 16:43:44.188974: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7da00 next 157 of size 1024\n2020-06-25 16:43:44.188990: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7de00 next 158 of size 1024\n2020-06-25 16:43:44.189006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e200 next 159 of size 1024\n2020-06-25 16:43:44.189023: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e600 next 160 of size 256\n2020-06-25 16:43:44.189039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e700 next 161 of size 1024\n2020-06-25 16:43:44.189055: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7eb00 next 162 of size 256\n2020-06-25 16:43:44.189071: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ec00 next 163 of size 256\n2020-06-25 16:43:44.189087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ed00 next 164 of size 256\n2020-06-25 16:43:44.189103: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ee00 next 165 of size 512\n2020-06-25 16:43:44.189119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f000 next 166 of size 256\n2020-06-25 16:43:44.189135: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f100 next 167 of size 1024\n2020-06-25 16:43:44.189160: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f500 next 168 of size 256\n2020-06-25 16:43:44.189176: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f600 next 169 of size 1024\n2020-06-25 16:43:44.189193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fa00 next 170 of size 256\n2020-06-25 16:43:44.189209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fb00 next 171 of size 256\n2020-06-25 16:43:44.189225: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fc00 next 172 of size 256\n2020-06-25 16:43:44.189241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fd00 next 173 of size 1024\n2020-06-25 16:43:44.189256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80100 next 174 of size 256\n2020-06-25 16:43:44.189272: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80200 next 175 of size 256\n2020-06-25 16:43:44.189289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80300 next 176 of size 1024\n2020-06-25 16:43:44.189305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80700 next 177 of size 256\n2020-06-25 16:43:44.189321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80800 next 178 of size 256\n2020-06-25 16:43:44.189338: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80900 next 179 of size 512\n2020-06-25 16:43:44.189354: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80b00 next 180 of size 1024\n2020-06-25 16:43:44.189951: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80f00 next 181 of size 256\n2020-06-25 16:43:44.189983: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81000 next 182 of size 1024\n2020-06-25 16:43:44.189999: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81400 next 183 of size 1024\n2020-06-25 16:43:44.190012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81800 next 184 of size 1024\n2020-06-25 16:43:44.190024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81c00 next 185 of size 256\n2020-06-25 16:43:44.190036: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81d00 next 186 of size 256\n2020-06-25 16:43:44.190049: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81e00 next 187 of size 1024\n2020-06-25 16:43:44.190062: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82200 next 188 of size 1024\n2020-06-25 16:43:44.190080: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82600 next 189 of size 256\n2020-06-25 16:43:44.190098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82700 next 190 of size 256\n2020-06-25 16:43:44.190114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82800 next 191 of size 1024\n2020-06-25 16:43:44.190131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82c00 next 192 of size 1024\n2020-06-25 16:43:44.190187: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83000 next 193 of size 256\n2020-06-25 16:43:44.190215: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83100 next 194 of size 1024\n2020-06-25 16:43:44.190231: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83500 next 195 of size 1024\n2020-06-25 16:43:44.190247: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83900 next 196 of size 1024\n2020-06-25 16:43:44.190274: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83d00 next 197 of size 512\n2020-06-25 16:43:44.190289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83f00 next 198 of size 256\n2020-06-25 16:43:44.190304: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84000 next 199 of size 256\n2020-06-25 16:43:44.190320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84100 next 200 of size 1024\n2020-06-25 16:43:44.190335: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84500 next 201 of size 256\n2020-06-25 16:43:44.190350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84600 next 202 of size 1024\n2020-06-25 16:43:44.190366: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84a00 next 203 of size 1024\n2020-06-25 16:43:44.190381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84e00 next 204 of size 1024\n2020-06-25 16:43:44.190396: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85200 next 205 of size 2048\n2020-06-25 16:43:44.190411: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85a00 next 206 of size 256\n2020-06-25 16:43:44.190426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85b00 next 207 of size 256\n2020-06-25 16:43:44.190442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85c00 next 208 of size 1024\n2020-06-25 16:43:44.190457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86000 next 209 of size 1024\n2020-06-25 16:43:44.190485: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86400 next 210 of size 256\n2020-06-25 16:43:44.190511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86500 next 211 of size 1024\n2020-06-25 16:43:44.190527: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86900 next 212 of size 1024\n2020-06-25 16:43:44.190751: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86d00 next 213 of size 1024\n2020-06-25 16:43:44.190778: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87100 next 214 of size 256\n2020-06-25 16:43:44.190792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87200 next 215 of size 1024\n2020-06-25 16:43:44.190803: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87600 next 216 of size 1024\n2020-06-25 16:43:44.190844: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87a00 next 217 of size 256\n2020-06-25 16:43:44.190859: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87b00 next 218 of size 256\n2020-06-25 16:43:44.190870: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87c00 next 219 of size 1024\n2020-06-25 16:43:44.190888: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88000 next 220 of size 1024\n2020-06-25 16:43:44.190907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88400 next 221 of size 1024\n2020-06-25 16:43:44.190923: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88800 next 222 of size 256\n2020-06-25 16:43:44.190939: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88900 next 223 of size 256\n2020-06-25 16:43:44.190956: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88a00 next 224 of size 256\n2020-06-25 16:43:44.190972: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88b00 next 225 of size 1024\n2020-06-25 16:43:44.190988: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88f00 next 226 of size 256\n2020-06-25 16:43:44.191003: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89000 next 227 of size 256\n2020-06-25 16:43:44.191019: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89100 next 228 of size 1024\n2020-06-25 16:43:44.191035: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89500 next 229 of size 256\n2020-06-25 16:43:44.191051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89600 next 230 of size 256\n2020-06-25 16:43:44.191067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89700 next 231 of size 512\n2020-06-25 16:43:44.191083: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89900 next 232 of size 512\n2020-06-25 16:43:44.191099: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89b00 next 233 of size 256\n2020-06-25 16:43:44.191114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89c00 next 234 of size 1024\n2020-06-25 16:43:44.191130: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a000 next 235 of size 512\n2020-06-25 16:43:44.191153: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a200 next 236 of size 512\n2020-06-25 16:43:44.191185: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a400 next 237 of size 256\n2020-06-25 16:43:44.191201: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a500 next 238 of size 2048\n2020-06-25 16:43:44.191217: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ad00 next 239 of size 256\n2020-06-25 16:43:44.191246: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ae00 next 240 of size 4096\n2020-06-25 16:43:44.191262: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8be00 next 241 of size 1024\n2020-06-25 16:43:44.191278: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c200 next 242 of size 256\n2020-06-25 16:43:44.191293: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c300 next 243 of size 256\n2020-06-25 16:43:44.191309: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c400 next 244 of size 256\n2020-06-25 16:43:44.191325: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c500 next 245 of size 256\n2020-06-25 16:43:44.191340: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c600 next 246 of size 2048\n2020-06-25 16:43:44.191356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ce00 next 247 of size 256\n2020-06-25 16:43:44.191372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8cf00 next 248 of size 1024\n2020-06-25 16:43:44.191596: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8d300 next 249 of size 8192\n2020-06-25 16:43:44.191625: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f300 next 250 of size 256\n2020-06-25 16:43:44.191639: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f400 next 251 of size 256\n2020-06-25 16:43:44.191652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f500 next 252 of size 256\n2020-06-25 16:43:44.191663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f600 next 253 of size 256\n2020-06-25 16:43:44.191674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f700 next 254 of size 1024\n2020-06-25 16:43:44.191686: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8fb00 next 255 of size 2048\n2020-06-25 16:43:44.191697: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90300 next 256 of size 256\n2020-06-25 16:43:44.191711: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90400 next 257 of size 1024\n2020-06-25 16:43:44.191729: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90800 next 258 of size 256\n2020-06-25 16:43:44.191747: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90900 next 259 of size 256\n2020-06-25 16:43:44.191764: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90a00 next 260 of size 1024\n2020-06-25 16:43:44.191780: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90e00 next 261 of size 256\n2020-06-25 16:43:44.191796: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90f00 next 262 of size 256\n2020-06-25 16:43:44.191830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91000 next 263 of size 1024\n2020-06-25 16:43:44.191851: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91400 next 264 of size 256\n2020-06-25 16:43:44.191868: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91500 next 265 of size 256\n2020-06-25 16:43:44.191884: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91600 next 266 of size 1024\n2020-06-25 16:43:44.191900: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91a00 next 267 of size 256\n2020-06-25 16:43:44.191915: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91b00 next 268 of size 256\n2020-06-25 16:43:44.191931: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91c00 next 269 of size 256\n2020-06-25 16:43:44.191947: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91d00 next 270 of size 512\n2020-06-25 16:43:44.191963: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91f00 next 271 of size 256\n2020-06-25 16:43:44.191978: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92000 next 272 of size 512\n2020-06-25 16:43:44.191994: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92200 next 273 of size 256\n2020-06-25 16:43:44.192010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92300 next 274 of size 1024\n2020-06-25 16:43:44.192026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92700 next 275 of size 256\n2020-06-25 16:43:44.192042: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92800 next 276 of size 1024\n2020-06-25 16:43:44.192058: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92c00 next 277 of size 1024\n2020-06-25 16:43:44.192073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93000 next 278 of size 1024\n2020-06-25 16:43:44.192089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93400 next 279 of size 1024\n2020-06-25 16:43:44.192105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93800 next 280 of size 1024\n2020-06-25 16:43:44.192328: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93c00 next 281 of size 1024\n2020-06-25 16:43:44.192355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94000 next 282 of size 1024\n2020-06-25 16:43:44.192370: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94400 next 283 of size 1024\n2020-06-25 16:43:44.192382: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94800 next 284 of size 1024\n2020-06-25 16:43:44.192394: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94c00 next 285 of size 256\n2020-06-25 16:43:44.192405: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94d00 next 286 of size 256\n2020-06-25 16:43:44.192416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94e00 next 287 of size 256\n2020-06-25 16:43:44.192430: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94f00 next 288 of size 1024\n2020-06-25 16:43:44.192448: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95300 next 289 of size 256\n2020-06-25 16:43:44.192465: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95400 next 290 of size 1024\n2020-06-25 16:43:44.192482: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95800 next 291 of size 256\n2020-06-25 16:43:44.192498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95900 next 292 of size 1024\n2020-06-25 16:43:44.192514: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95d00 next 293 of size 1024\n2020-06-25 16:43:44.192529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96100 next 294 of size 1024\n2020-06-25 16:43:44.192545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96500 next 295 of size 1024\n2020-06-25 16:43:44.192562: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96900 next 296 of size 256\n2020-06-25 16:43:44.192579: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96a00 next 298 of size 32768\n2020-06-25 16:43:44.192596: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b9ea00 next 299 of size 37632\n2020-06-25 16:43:44.192611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703ba7d00 next 301 of size 294912\n2020-06-25 16:43:44.192627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703befd00 next 302 of size 12288\n2020-06-25 16:43:44.192644: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703bf2d00 next 18446744073709551615 of size 447232\n2020-06-25 16:43:44.192659: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4194304\n2020-06-25 16:43:44.192676: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703c60000 next 18446744073709551615 of size 4194304\n2020-06-25 16:43:44.192692: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4194304\n2020-06-25 16:43:44.192708: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704060000 next 18446744073709551615 of size 4194304\n2020-06-25 16:43:44.192724: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 8388608\n2020-06-25 16:43:44.192740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704460000 next 304 of size 1179648\n2020-06-25 16:43:44.192757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704580000 next 305 of size 1179648\n2020-06-25 16:43:44.192773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7046a0000 next 306 of size 2359296\n2020-06-25 16:43:44.192789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7048e0000 next 307 of size 524288\n2020-06-25 16:43:44.192806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704960000 next 18446744073709551615 of size 3145728\n2020-06-25 16:43:44.193044: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 16777216\n2020-06-25 16:43:44.193073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704c60000 next 309 of size 2097152\n2020-06-25 16:43:44.193088: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704e60000 next 310 of size 2359296\n2020-06-25 16:43:44.193100: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7050a0000 next 312 of size 2097152\n2020-06-25 16:43:44.193111: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7052a0000 next 313 of size 2359296\n2020-06-25 16:43:44.193124: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7054e0000 next 314 of size 37632\n2020-06-25 16:43:44.193135: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7054e9300 next 315 of size 2359296\n2020-06-25 16:43:44.193165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705729300 next 316 of size 37632\n2020-06-25 16:43:44.193184: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705732600 next 319 of size 2359296\n2020-06-25 16:43:44.193202: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705972600 next 18446744073709551615 of size 3070464\n2020-06-25 16:43:44.193219: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 33554432\n2020-06-25 16:43:44.193235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705c60000 next 18446744073709551615 of size 33554432\n2020-06-25 16:43:44.193264: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 67108864\n2020-06-25 16:43:44.193282: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x707c60000 next 318 of size 8388608\n2020-06-25 16:43:44.193299: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x708460000 next 320 of size 32768\n2020-06-25 16:43:44.193316: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x708468000 next 321 of size 294912\n2020-06-25 16:43:44.193343: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7084b0000 next 322 of size 2359296\n2020-06-25 16:43:44.193359: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7086f0000 next 18446744073709551615 of size 56033280\n2020-06-25 16:43:44.193375: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 134217728\n2020-06-25 16:43:44.193392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70bc60000 next 324 of size 1179648\n2020-06-25 16:43:44.193408: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70bd80000 next 325 of size 524288\n2020-06-25 16:43:44.193424: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70be00000 next 329 of size 262144\n2020-06-25 16:43:44.193441: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70be40000 next 330 of size 2359296\n2020-06-25 16:43:44.193457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c080000 next 331 of size 262144\n2020-06-25 16:43:44.193473: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c0c0000 next 332 of size 262144\n2020-06-25 16:43:44.193713: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c100000 next 333 of size 12288\n2020-06-25 16:43:44.193739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c103000 next 334 of size 2359296\n2020-06-25 16:43:44.193754: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c343000 next 335 of size 8192\n2020-06-25 16:43:44.193765: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c345000 next 336 of size 2359296\n2020-06-25 16:43:44.193777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c585000 next 337 of size 2359296\n2020-06-25 16:43:44.193788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c7c5000 next 338 of size 2359296\n2020-06-25 16:43:44.193800: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ca05000 next 339 of size 2359296\n2020-06-25 16:43:44.193834: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70cc45000 next 340 of size 524288\n2020-06-25 16:43:44.193854: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ccc5000 next 341 of size 2359296\n2020-06-25 16:43:44.193872: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70cf05000 next 342 of size 33554432\n2020-06-25 16:43:44.193888: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef05000 next 343 of size 8192\n2020-06-25 16:43:44.193904: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef07000 next 344 of size 8192\n2020-06-25 16:43:44.193919: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef09000 next 345 of size 2359296\n2020-06-25 16:43:44.193936: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f149000 next 346 of size 131072\n2020-06-25 16:43:44.193952: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f169000 next 347 of size 2359296\n2020-06-25 16:43:44.193967: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f3a9000 next 348 of size 2359296\n2020-06-25 16:43:44.193983: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f5e9000 next 349 of size 12288\n2020-06-25 16:43:44.193998: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f5ec000 next 350 of size 2359296\n2020-06-25 16:43:44.194013: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f82c000 next 351 of size 2359296\n2020-06-25 16:43:44.194029: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fa6c000 next 352 of size 2097152\n2020-06-25 16:43:44.194044: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fc6c000 next 353 of size 524288\n2020-06-25 16:43:44.194060: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fcec000 next 354 of size 2359296\n2020-06-25 16:43:44.194075: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ff2c000 next 355 of size 2359296\n2020-06-25 16:43:44.194091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71016c000 next 356 of size 2097152\n2020-06-25 16:43:44.194106: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71036c000 next 357 of size 8388608\n2020-06-25 16:43:44.194122: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x710b6c000 next 358 of size 8388608\n2020-06-25 16:43:44.194137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71136c000 next 359 of size 524288\n2020-06-25 16:43:44.194161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7113ec000 next 361 of size 12288\n2020-06-25 16:43:44.194177: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7113ef000 next 362 of size 262144\n2020-06-25 16:43:44.194193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71142f000 next 363 of size 262144\n2020-06-25 16:43:44.194209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71146f000 next 364 of size 262144\n2020-06-25 16:43:44.194225: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7114af000 next 365 of size 2359296\n2020-06-25 16:43:44.194241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7116ef000 next 366 of size 524288\n2020-06-25 16:43:44.194268: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71176f000 next 367 of size 2359296\n2020-06-25 16:43:44.194296: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7119af000 next 368 of size 2359296\n2020-06-25 16:43:44.194311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x711bef000 next 369 of size 2359296\n2020-06-25 16:43:44.194339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x711e2f000 next 370 of size 2359296\n2020-06-25 16:43:44.194367: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71206f000 next 371 of size 2097152\n2020-06-25 16:43:44.194383: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71226f000 next 372 of size 2359296\n2020-06-25 16:43:44.194410: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7124af000 next 373 of size 2359296\n2020-06-25 16:43:44.194426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7126ef000 next 374 of size 2359296\n2020-06-25 16:43:44.194442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71292f000 next 375 of size 8388608\n2020-06-25 16:43:44.194458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71312f000 next 376 of size 1179648\n2020-06-25 16:43:44.194474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71324f000 next 378 of size 294912\n2020-06-25 16:43:44.194490: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713297000 next 381 of size 37632\n2020-06-25 16:43:44.194506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7132a0300 next 382 of size 8192\n2020-06-25 16:43:44.194522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7132a2300 next 383 of size 2097152\n2020-06-25 16:43:44.194538: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134a2300 next 384 of size 131072\n2020-06-25 16:43:44.194554: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134c2300 next 385 of size 1280\n2020-06-25 16:43:44.194570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134c2800 next 386 of size 2359296\n2020-06-25 16:43:44.194586: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713702800 next 387 of size 2359296\n2020-06-25 16:43:44.194617: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713942800 next 18446744073709551615 of size 3266560\n2020-06-25 16:43:44.194634: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 268435456\n2020-06-25 16:43:44.195182: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713c60000 next 327 of size 134217728\n2020-06-25 16:43:44.195212: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71bc60000 next 377 of size 33554432\n2020-06-25 16:43:44.195228: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dc60000 next 388 of size 2359296\n2020-06-25 16:43:44.195241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0000 next 389 of size 1024\n2020-06-25 16:43:44.195265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0400 next 390 of size 1024\n2020-06-25 16:43:44.195278: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0800 next 391 of size 1024\n2020-06-25 16:43:44.195289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0c00 next 392 of size 256\n2020-06-25 16:43:44.195303: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0d00 next 393 of size 524288\n2020-06-25 16:43:44.195323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71df20d00 next 394 of size 33554432\n2020-06-25 16:43:44.195341: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff20d00 next 395 of size 1024\n2020-06-25 16:43:44.195382: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21100 next 396 of size 512\n2020-06-25 16:43:44.195398: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21300 next 397 of size 1024\n2020-06-25 16:43:44.195414: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21700 next 398 of size 131072\n2020-06-25 16:43:44.195430: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41700 next 399 of size 1024\n2020-06-25 16:43:44.195445: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41b00 next 400 of size 1024\n2020-06-25 16:43:44.195461: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41f00 next 401 of size 1024\n2020-06-25 16:43:44.195477: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42300 next 402 of size 1024\n2020-06-25 16:43:44.195493: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42700 next 403 of size 1024\n2020-06-25 16:43:44.195510: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42b00 next 404 of size 2359296\n2020-06-25 16:43:44.195526: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720182b00 next 405 of size 1024\n2020-06-25 16:43:44.195541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720182f00 next 406 of size 1024\n2020-06-25 16:43:44.195557: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720183300 next 407 of size 512\n2020-06-25 16:43:44.195573: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720183500 next 408 of size 2359296\n2020-06-25 16:43:44.195589: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3500 next 409 of size 1024\n2020-06-25 16:43:44.195606: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3900 next 410 of size 1024\n2020-06-25 16:43:44.195622: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3d00 next 411 of size 1024\n2020-06-25 16:43:44.195637: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4100 next 412 of size 1024\n2020-06-25 16:43:44.195654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4500 next 413 of size 256\n2020-06-25 16:43:44.195672: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4600 next 414 of size 1024\n2020-06-25 16:43:44.195688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4a00 next 415 of size 1024\n2020-06-25 16:43:44.195704: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4e00 next 416 of size 256\n2020-06-25 16:43:44.195719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4f00 next 417 of size 1024\n2020-06-25 16:43:44.195735: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5300 next 418 of size 512\n2020-06-25 16:43:44.195750: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5500 next 419 of size 1024\n2020-06-25 16:43:44.195766: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5900 next 420 of size 1024\n2020-06-25 16:43:44.196059: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5d00 next 421 of size 2359296\n2020-06-25 16:43:44.196087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720605d00 next 422 of size 1024\n2020-06-25 16:43:44.196101: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720606100 next 423 of size 2359296\n2020-06-25 16:43:44.196112: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720846100 next 424 of size 1024\n2020-06-25 16:43:44.196124: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720846500 next 425 of size 2359296\n2020-06-25 16:43:44.196137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a86500 next 426 of size 1024\n2020-06-25 16:43:44.196186: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a86900 next 427 of size 12288\n2020-06-25 16:43:44.196207: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89900 next 428 of size 1024\n2020-06-25 16:43:44.196224: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89d00 next 429 of size 256\n2020-06-25 16:43:44.196240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89e00 next 430 of size 1024\n2020-06-25 16:43:44.196256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8a200 next 431 of size 1024\n2020-06-25 16:43:44.196272: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8a600 next 432 of size 1024\n2020-06-25 16:43:44.196288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8aa00 next 433 of size 1024\n2020-06-25 16:43:44.196304: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8ae00 next 434 of size 512\n2020-06-25 16:43:44.196321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b000 next 435 of size 1024\n2020-06-25 16:43:44.196337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b400 next 436 of size 1024\n2020-06-25 16:43:44.196353: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b800 next 437 of size 2097152\n2020-06-25 16:43:44.196369: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8b800 next 438 of size 1024\n2020-06-25 16:43:44.196385: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8bc00 next 439 of size 1024\n2020-06-25 16:43:44.196401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8c000 next 440 of size 2097152\n2020-06-25 16:43:44.196416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720e8c000 next 441 of size 1024\n2020-06-25 16:43:44.196432: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720e8c400 next 442 of size 524288\n2020-06-25 16:43:44.196449: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0c400 next 443 of size 1024\n2020-06-25 16:43:44.196464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0c800 next 444 of size 1024\n2020-06-25 16:43:44.196480: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0cc00 next 445 of size 1024\n2020-06-25 16:43:44.196496: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d000 next 446 of size 1024\n2020-06-25 16:43:44.196511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d400 next 447 of size 1024\n2020-06-25 16:43:44.196527: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d800 next 448 of size 1024\n2020-06-25 16:43:44.196542: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0dc00 next 449 of size 1024\n2020-06-25 16:43:44.196558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e000 next 450 of size 1024\n2020-06-25 16:43:44.196575: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e400 next 451 of size 1024\n2020-06-25 16:43:44.196591: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e800 next 452 of size 256\n2020-06-25 16:43:44.196606: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e900 next 453 of size 256\n2020-06-25 16:43:44.196623: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0ea00 next 454 of size 256\n2020-06-25 16:43:44.196639: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0eb00 next 455 of size 2048\n2020-06-25 16:43:44.196653: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f300 next 456 of size 512\n2020-06-25 16:43:44.196669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f500 next 457 of size 1024\n2020-06-25 16:43:44.196686: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f900 next 458 of size 1024\n2020-06-25 16:43:44.196702: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0fd00 next 459 of size 1024\n2020-06-25 16:43:44.196717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10100 next 460 of size 1024\n2020-06-25 16:43:44.196983: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10500 next 461 of size 1024\n2020-06-25 16:43:44.197011: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10900 next 462 of size 1024\n2020-06-25 16:43:44.197025: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10d00 next 463 of size 256\n2020-06-25 16:43:44.197038: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10e00 next 464 of size 8388608\n2020-06-25 16:43:44.197050: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721710e00 next 465 of size 1024\n2020-06-25 16:43:44.197062: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721711200 next 466 of size 8388608\n2020-06-25 16:43:44.197073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f11200 next 468 of size 2048\n2020-06-25 16:43:44.197093: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f11a00 next 469 of size 524288\n2020-06-25 16:43:44.197123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f91a00 next 470 of size 262144\n2020-06-25 16:43:44.197160: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721fd1a00 next 471 of size 256\n2020-06-25 16:43:44.197190: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721fd1b00 next 472 of size 262144\n2020-06-25 16:43:44.197206: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722011b00 next 473 of size 1024\n2020-06-25 16:43:44.197223: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722011f00 next 474 of size 1024\n2020-06-25 16:43:44.197240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722012300 next 475 of size 12288\n2020-06-25 16:43:44.197257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722015300 next 476 of size 256\n2020-06-25 16:43:44.197287: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722015400 next 477 of size 262144\n2020-06-25 16:43:44.197302: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055400 next 478 of size 1024\n2020-06-25 16:43:44.197317: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055800 next 479 of size 1024\n2020-06-25 16:43:44.197333: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055c00 next 480 of size 1024\n2020-06-25 16:43:44.197348: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056000 next 481 of size 1024\n2020-06-25 16:43:44.197376: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056400 next 482 of size 1024\n2020-06-25 16:43:44.197392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056800 next 483 of size 1024\n2020-06-25 16:43:44.197408: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056c00 next 484 of size 524288\n2020-06-25 16:43:44.197435: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d6c00 next 485 of size 1024\n2020-06-25 16:43:44.197452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7000 next 486 of size 1024\n2020-06-25 16:43:44.197468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7400 next 487 of size 256\n2020-06-25 16:43:44.197483: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7500 next 488 of size 1024\n2020-06-25 16:43:44.197499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7900 next 489 of size 256\n2020-06-25 16:43:44.197526: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7a00 next 490 of size 256\n2020-06-25 16:43:44.197554: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7b00 next 491 of size 2359296\n2020-06-25 16:43:44.197570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722317b00 next 492 of size 1024\n2020-06-25 16:43:44.197586: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722317f00 next 493 of size 1024\n2020-06-25 16:43:44.197615: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318300 next 494 of size 512\n2020-06-25 16:43:44.197630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318500 next 495 of size 1024\n2020-06-25 16:43:44.197659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318900 next 496 of size 2048\n2020-06-25 16:43:44.197955: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722319100 next 497 of size 2359296\n2020-06-25 16:43:44.197990: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559100 next 498 of size 256\n2020-06-25 16:43:44.198008: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559200 next 499 of size 512\n2020-06-25 16:43:44.198019: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559400 next 500 of size 512\n2020-06-25 16:43:44.198031: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559600 next 501 of size 524288\n2020-06-25 16:43:44.198043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9600 next 502 of size 1024\n2020-06-25 16:43:44.198065: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9a00 next 503 of size 1024\n2020-06-25 16:43:44.198079: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9e00 next 504 of size 512\n2020-06-25 16:43:44.198098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da000 next 505 of size 256\n2020-06-25 16:43:44.198116: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da100 next 506 of size 1024\n2020-06-25 16:43:44.198134: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da500 next 507 of size 256\n2020-06-25 16:43:44.198170: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da600 next 508 of size 512\n2020-06-25 16:43:44.198200: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da800 next 509 of size 2359296\n2020-06-25 16:43:44.198241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281a800 next 510 of size 2048\n2020-06-25 16:43:44.198258: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b000 next 511 of size 1024\n2020-06-25 16:43:44.198289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b400 next 512 of size 1024\n2020-06-25 16:43:44.198307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b800 next 513 of size 12288\n2020-06-25 16:43:44.198324: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281e800 next 514 of size 1179648\n2020-06-25 16:43:44.198341: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293e800 next 515 of size 512\n2020-06-25 16:43:44.198358: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ea00 next 516 of size 512\n2020-06-25 16:43:44.198388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ec00 next 517 of size 512\n2020-06-25 16:43:44.198404: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ee00 next 518 of size 1024\n2020-06-25 16:43:44.198420: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f200 next 519 of size 512\n2020-06-25 16:43:44.198436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f400 next 520 of size 1024\n2020-06-25 16:43:44.198452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f800 next 521 of size 1024\n2020-06-25 16:43:44.198468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293fc00 next 522 of size 294912\n2020-06-25 16:43:44.198484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722987c00 next 523 of size 512\n2020-06-25 16:43:44.198501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722987e00 next 524 of size 512\n2020-06-25 16:43:44.198517: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988000 next 525 of size 1024\n2020-06-25 16:43:44.198532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988400 next 526 of size 2048\n2020-06-25 16:43:44.198548: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988c00 next 527 of size 2048\n2020-06-25 16:43:44.198564: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989400 next 528 of size 256\n2020-06-25 16:43:44.198580: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989500 next 529 of size 512\n2020-06-25 16:43:44.198596: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989700 next 530 of size 512\n2020-06-25 16:43:44.198612: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989900 next 531 of size 256\n2020-06-25 16:43:44.198628: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989a00 next 532 of size 512\n2020-06-25 16:43:44.198645: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989c00 next 533 of size 256\n2020-06-25 16:43:44.198905: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989d00 next 534 of size 37632\n2020-06-25 16:43:44.198933: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722993000 next 535 of size 1024\n2020-06-25 16:43:44.198962: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722993400 next 536 of size 2359296\n2020-06-25 16:43:44.198977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3400 next 537 of size 1024\n2020-06-25 16:43:44.198989: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3800 next 538 of size 512\n2020-06-25 16:43:44.199001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3a00 next 539 of size 512\n2020-06-25 16:43:44.199234: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3c00 next 540 of size 256\n2020-06-25 16:43:44.199257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3d00 next 541 of size 256\n2020-06-25 16:43:44.199287: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3e00 next 542 of size 2097152\n2020-06-25 16:43:44.199300: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd3e00 next 543 of size 1024\n2020-06-25 16:43:44.199312: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4200 next 544 of size 256\n2020-06-25 16:43:44.199324: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4300 next 545 of size 256\n2020-06-25 16:43:44.199550: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4400 next 546 of size 2359296\n2020-06-25 16:43:44.199570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014400 next 547 of size 256\n2020-06-25 16:43:44.199583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014500 next 548 of size 256\n2020-06-25 16:43:44.199594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014600 next 549 of size 8192\n2020-06-25 16:43:44.199607: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016600 next 550 of size 1024\n2020-06-25 16:43:44.199618: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016a00 next 551 of size 256\n2020-06-25 16:43:44.199644: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016b00 next 552 of size 1024\n2020-06-25 16:43:44.199656: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016f00 next 553 of size 1024\n2020-06-25 16:43:44.199674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017300 next 554 of size 1024\n2020-06-25 16:43:44.199691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017700 next 555 of size 2048\n2020-06-25 16:43:44.199707: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017f00 next 556 of size 1024\n2020-06-25 16:43:44.199724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723018300 next 557 of size 1024\n2020-06-25 16:43:44.199741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723018700 next 558 of size 2359296\n2020-06-25 16:43:44.199757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723258700 next 559 of size 2359296\n2020-06-25 16:43:44.199773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498700 next 560 of size 1024\n2020-06-25 16:43:44.199789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498b00 next 561 of size 256\n2020-06-25 16:43:44.199805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498c00 next 562 of size 2359296\n2020-06-25 16:43:44.199845: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d8c00 next 563 of size 1024\n2020-06-25 16:43:44.199863: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9000 next 564 of size 1024\n2020-06-25 16:43:44.199880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9400 next 565 of size 1024\n2020-06-25 16:43:44.199896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9800 next 566 of size 1024\n2020-06-25 16:43:44.199912: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9c00 next 567 of size 1024\n2020-06-25 16:43:44.199928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da000 next 568 of size 1024\n2020-06-25 16:43:44.199944: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da400 next 569 of size 1024\n2020-06-25 16:43:44.199959: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da800 next 570 of size 1024\n2020-06-25 16:43:44.199975: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236dac00 next 571 of size 2359296\n2020-06-25 16:43:44.199991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ac00 next 572 of size 512\n2020-06-25 16:43:44.200007: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ae00 next 573 of size 256\n2020-06-25 16:43:44.200023: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391af00 next 574 of size 1024\n2020-06-25 16:43:44.200039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391b300 next 575 of size 1024\n2020-06-25 16:43:44.200054: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391b700 next 576 of size 1024\n2020-06-25 16:43:44.200082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391bb00 next 577 of size 1024\n2020-06-25 16:43:44.200098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391bf00 next 578 of size 2048\n2020-06-25 16:43:44.200115: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391c700 next 579 of size 1024\n2020-06-25 16:43:44.200130: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391cb00 next 580 of size 1024\n2020-06-25 16:43:44.200180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391cf00 next 581 of size 1024\n2020-06-25 16:43:44.200199: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391d300 next 582 of size 1024\n2020-06-25 16:43:44.200216: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391d700 next 583 of size 1024\n2020-06-25 16:43:44.200233: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391db00 next 584 of size 2048\n2020-06-25 16:43:44.200250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391e300 next 585 of size 2048\n2020-06-25 16:43:44.200268: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391eb00 next 586 of size 1024\n2020-06-25 16:43:44.200298: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ef00 next 587 of size 1024\n2020-06-25 16:43:44.200326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391f300 next 588 of size 2048\n2020-06-25 16:43:44.200345: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391fb00 next 589 of size 512\n2020-06-25 16:43:44.200363: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391fd00 next 590 of size 1024\n2020-06-25 16:43:44.200393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920100 next 591 of size 1024\n2020-06-25 16:43:44.200410: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920500 next 592 of size 1024\n2020-06-25 16:43:44.200426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920900 next 593 of size 1024\n2020-06-25 16:43:44.200459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920d00 next 594 of size 1024\n2020-06-25 16:43:44.200474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921100 next 595 of size 1024\n2020-06-25 16:43:44.200490: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921500 next 596 of size 512\n2020-06-25 16:43:44.200518: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921700 next 597 of size 1024\n2020-06-25 16:43:44.200536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921b00 next 18446744073709551615 of size 3400960\n2020-06-25 16:43:44.200553: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1073741824\n2020-06-25 16:43:44.200570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723c60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:44.200587: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1073741824\n2020-06-25 16:43:44.200603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x763c60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:44.200619: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2147483648\n2020-06-25 16:43:44.200636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7a3c60000 next 380 of size 134217728\n2020-06-25 16:43:44.200653: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7abc60000 next 467 of size 1073741824\n2020-06-25 16:43:44.200671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60000 next 598 of size 1024\n2020-06-25 16:43:44.200688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60400 next 599 of size 1024\n2020-06-25 16:43:44.200704: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60800 next 600 of size 1024\n2020-06-25 16:43:44.200720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60c00 next 601 of size 1024\n2020-06-25 16:43:44.200736: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc61000 next 602 of size 2359296\n2020-06-25 16:43:44.200753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebea1000 next 603 of size 2359296\n2020-06-25 16:43:44.200769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec0e1000 next 604 of size 8388608\n2020-06-25 16:43:44.200785: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec8e1000 next 605 of size 1024\n2020-06-25 16:43:44.200802: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec8e1400 next 606 of size 33554432\n2020-06-25 16:43:44.200838: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e1400 next 607 of size 4096\n2020-06-25 16:43:44.200858: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2400 next 608 of size 512\n2020-06-25 16:43:44.200875: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2600 next 609 of size 1024\n2020-06-25 16:43:44.200891: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2a00 next 610 of size 1024\n2020-06-25 16:43:44.200908: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2e00 next 611 of size 1024\n2020-06-25 16:43:44.200924: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3200 next 612 of size 1024\n2020-06-25 16:43:44.200941: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3600 next 613 of size 512\n2020-06-25 16:43:44.200957: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3800 next 614 of size 512\n2020-06-25 16:43:44.200973: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3a00 next 615 of size 294912\n2020-06-25 16:43:44.200989: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92ba00 next 616 of size 1024\n2020-06-25 16:43:44.201005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92be00 next 617 of size 1024\n2020-06-25 16:43:44.201021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92c200 next 618 of size 32768\n2020-06-25 16:43:44.201037: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee934200 next 619 of size 1024\n2020-06-25 16:43:44.201053: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee934600 next 620 of size 4096\n2020-06-25 16:43:44.201069: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935600 next 621 of size 1024\n2020-06-25 16:43:44.201085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935a00 next 622 of size 1024\n2020-06-25 16:43:44.201101: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935e00 next 623 of size 1024\n2020-06-25 16:43:44.201326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936200 next 624 of size 1024\n2020-06-25 16:43:44.201354: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936600 next 625 of size 1024\n2020-06-25 16:43:44.201384: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936a00 next 626 of size 33554432\n2020-06-25 16:43:44.201399: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0936a00 next 627 of size 1024\n2020-06-25 16:43:44.201411: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0936e00 next 628 of size 512\n2020-06-25 16:43:44.201422: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937000 next 629 of size 512\n2020-06-25 16:43:44.201724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937200 next 630 of size 512\n2020-06-25 16:43:44.201745: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937400 next 631 of size 1024\n2020-06-25 16:43:44.201774: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937800 next 632 of size 2097152\n2020-06-25 16:43:44.201788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b37800 next 633 of size 1024\n2020-06-25 16:43:44.201799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b37c00 next 634 of size 1024\n2020-06-25 16:43:44.201834: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38000 next 635 of size 2048\n2020-06-25 16:43:44.202045: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38800 next 636 of size 1024\n2020-06-25 16:43:44.202081: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38c00 next 637 of size 2359296\n2020-06-25 16:43:44.202097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d78c00 next 638 of size 1024\n2020-06-25 16:43:44.202110: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79000 next 639 of size 1024\n2020-06-25 16:43:44.202122: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79400 next 640 of size 1024\n2020-06-25 16:43:44.202354: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79800 next 641 of size 1024\n2020-06-25 16:43:44.202385: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79c00 next 642 of size 512\n2020-06-25 16:43:44.202402: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79e00 next 643 of size 512\n2020-06-25 16:43:44.202415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d7a000 next 644 of size 2048\n2020-06-25 16:43:44.202427: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d7a800 next 645 of size 131072\n2020-06-25 16:43:44.202641: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d9a800 next 646 of size 2359296\n2020-06-25 16:43:44.202673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0fda800 next 647 of size 512\n2020-06-25 16:43:44.202702: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0fdaa00 next 648 of size 2359296\n2020-06-25 16:43:44.202719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f121aa00 next 649 of size 1024\n2020-06-25 16:43:44.202732: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f121ae00 next 650 of size 2359296\n2020-06-25 16:43:44.202744: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f145ae00 next 651 of size 1024\n2020-06-25 16:43:44.202975: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f145b200 next 652 of size 33554432\n2020-06-25 16:43:44.203007: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f345b200 next 653 of size 1179648\n2020-06-25 16:43:44.203037: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357b200 next 654 of size 1024\n2020-06-25 16:43:44.203051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357b600 next 655 of size 1024\n2020-06-25 16:43:44.203064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357ba00 next 656 of size 1024\n2020-06-25 16:43:44.203075: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357be00 next 657 of size 1024\n2020-06-25 16:43:44.203193: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357c200 next 658 of size 32768\n2020-06-25 16:43:44.203216: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584200 next 659 of size 256\n2020-06-25 16:43:44.203235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584300 next 660 of size 512\n2020-06-25 16:43:44.203253: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584500 next 661 of size 512\n2020-06-25 16:43:44.203270: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584700 next 662 of size 512\n2020-06-25 16:43:44.203288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584900 next 663 of size 524288\n2020-06-25 16:43:44.203305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3604900 next 664 of size 8192\n2020-06-25 16:43:44.203321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3606900 next 665 of size 1024\n2020-06-25 16:43:44.203338: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3606d00 next 666 of size 2097152\n2020-06-25 16:43:44.203355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3806d00 next 667 of size 256\n2020-06-25 16:43:44.203371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3806e00 next 668 of size 1024\n2020-06-25 16:43:44.203387: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3807200 next 669 of size 256\n2020-06-25 16:43:44.203404: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3807300 next 670 of size 37632\n2020-06-25 16:43:44.203420: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810600 next 671 of size 1024\n2020-06-25 16:43:44.203437: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810a00 next 672 of size 1024\n2020-06-25 16:43:44.203453: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810e00 next 673 of size 1024\n2020-06-25 16:43:44.203470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811200 next 674 of size 256\n2020-06-25 16:43:44.203486: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811300 next 675 of size 512\n2020-06-25 16:43:44.203503: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811500 next 676 of size 256\n2020-06-25 16:43:44.203519: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811600 next 679 of size 262144\n2020-06-25 16:43:44.203536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3851600 next 680 of size 2359296\n2020-06-25 16:43:44.203564: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91600 next 681 of size 256\n2020-06-25 16:43:44.203579: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91700 next 682 of size 256\n2020-06-25 16:43:44.203595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91800 next 683 of size 256\n2020-06-25 16:43:44.203611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91900 next 684 of size 1024\n2020-06-25 16:43:44.203627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91d00 next 685 of size 256\n2020-06-25 16:43:44.203643: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91e00 next 686 of size 2359296\n2020-06-25 16:43:44.203657: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3cd1e00 next 687 of size 1024\n2020-06-25 16:43:44.203674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3cd2200 next 688 of size 2359296\n2020-06-25 16:43:44.203690: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12200 next 689 of size 1024\n2020-06-25 16:43:44.203706: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12600 next 690 of size 256\n2020-06-25 16:43:44.203722: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12700 next 691 of size 1024\n2020-06-25 16:43:44.203739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12b00 next 692 of size 256\n2020-06-25 16:43:44.203755: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12c00 next 693 of size 256\n2020-06-25 16:43:44.203782: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12d00 next 694 of size 1179648\n2020-06-25 16:43:44.203798: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4032d00 next 695 of size 1024\n2020-06-25 16:43:44.203832: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4033100 next 696 of size 1179648\n2020-06-25 16:43:44.203852: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4153100 next 697 of size 4096\n2020-06-25 16:43:44.203880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4154100 next 698 of size 12288\n2020-06-25 16:43:44.203896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157100 next 699 of size 1024\n2020-06-25 16:43:44.203912: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157500 next 700 of size 256\n2020-06-25 16:43:44.203928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157600 next 701 of size 1024\n2020-06-25 16:43:44.203944: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157a00 next 702 of size 1024\n2020-06-25 16:43:44.203960: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157e00 next 703 of size 1024\n2020-06-25 16:43:44.203976: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158200 next 704 of size 256\n2020-06-25 16:43:44.203992: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158300 next 705 of size 256\n2020-06-25 16:43:44.204008: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158400 next 706 of size 256\n2020-06-25 16:43:44.204036: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158500 next 707 of size 512\n2020-06-25 16:43:44.204063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158700 next 708 of size 256\n2020-06-25 16:43:44.204091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158800 next 709 of size 262144\n2020-06-25 16:43:44.204107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4198800 next 710 of size 1024\n2020-06-25 16:43:44.204123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4198c00 next 711 of size 1024\n2020-06-25 16:43:44.204139: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4199000 next 712 of size 294912\n2020-06-25 16:43:44.204165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f41e1000 next 713 of size 2359296\n2020-06-25 16:43:44.204182: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421000 next 714 of size 1024\n2020-06-25 16:43:44.204210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421400 next 715 of size 256\n2020-06-25 16:43:44.204227: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421500 next 716 of size 8388608\n2020-06-25 16:43:44.204244: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4c21500 next 717 of size 1024\n2020-06-25 16:43:44.204261: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4c21900 next 718 of size 2359296\n2020-06-25 16:43:44.204277: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61900 next 719 of size 256\n2020-06-25 16:43:44.204294: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61a00 next 720 of size 512\n2020-06-25 16:43:44.204311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61c00 next 721 of size 1024\n2020-06-25 16:43:44.204328: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e62000 next 722 of size 1024\n2020-06-25 16:43:44.204344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e62400 next 723 of size 262144\n2020-06-25 16:43:44.204385: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4ea2400 next 724 of size 1024\n2020-06-25 16:43:44.204400: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4ea2800 next 725 of size 2359296\n2020-06-25 16:43:44.204416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2800 next 726 of size 1024\n2020-06-25 16:43:44.204432: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2c00 next 727 of size 256\n2020-06-25 16:43:44.204448: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2d00 next 728 of size 1024\n2020-06-25 16:43:44.204463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e3100 next 729 of size 4096\n2020-06-25 16:43:44.204479: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e4100 next 730 of size 37632\n2020-06-25 16:43:44.204495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ed400 next 731 of size 2048\n2020-06-25 16:43:44.204511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50edc00 next 732 of size 1024\n2020-06-25 16:43:44.204526: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ee000 next 733 of size 1024\n2020-06-25 16:43:44.204542: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ee400 next 734 of size 294912\n2020-06-25 16:43:44.204570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5136400 next 735 of size 2048\n2020-06-25 16:43:44.204587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5136c00 next 736 of size 1024\n2020-06-25 16:43:44.204603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137000 next 737 of size 1024\n2020-06-25 16:43:44.204619: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137400 next 738 of size 1024\n2020-06-25 16:43:44.204635: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137800 next 739 of size 2359296\n2020-06-25 16:43:44.204652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5377800 next 740 of size 1024\n2020-06-25 16:43:44.204670: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5377c00 next 741 of size 1024\n2020-06-25 16:43:44.204687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378000 next 742 of size 1024\n2020-06-25 16:43:44.204703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378400 next 743 of size 256\n2020-06-25 16:43:44.204720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378500 next 744 of size 256\n2020-06-25 16:43:44.204736: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378600 next 745 of size 256\n2020-06-25 16:43:44.204752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378700 next 746 of size 1024\n2020-06-25 16:43:44.204769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378b00 next 747 of size 1024\n2020-06-25 16:43:44.204787: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378f00 next 748 of size 512\n2020-06-25 16:43:44.204803: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379100 next 749 of size 256\n2020-06-25 16:43:44.204922: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379200 next 750 of size 2048\n2020-06-25 16:43:44.204964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379a00 next 751 of size 256\n2020-06-25 16:43:44.204984: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379b00 next 752 of size 1024\n2020-06-25 16:43:44.205002: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379f00 next 753 of size 1024\n2020-06-25 16:43:44.205020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f537a300 next 754 of size 1024\n2020-06-25 16:43:44.205037: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f537a700 next 755 of size 134217728\n2020-06-25 16:43:44.205054: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37a700 next 756 of size 1024\n2020-06-25 16:43:44.205070: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37ab00 next 757 of size 1024\n2020-06-25 16:43:44.205087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37af00 next 758 of size 1024\n2020-06-25 16:43:44.205103: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37b300 next 759 of size 1024\n2020-06-25 16:43:44.205119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37b700 next 760 of size 1024\n2020-06-25 16:43:44.205136: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37bb00 next 761 of size 1024\n2020-06-25 16:43:44.205152: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37bf00 next 762 of size 512\n2020-06-25 16:43:44.205169: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37c100 next 763 of size 37632\n2020-06-25 16:43:44.205194: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385400 next 764 of size 256\n2020-06-25 16:43:44.205213: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385500 next 765 of size 256\n2020-06-25 16:43:44.205230: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385600 next 766 of size 256\n2020-06-25 16:43:44.205247: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385700 next 767 of size 1024\n2020-06-25 16:43:44.205275: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385b00 next 768 of size 1024\n2020-06-25 16:43:44.205305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385f00 next 769 of size 512\n2020-06-25 16:43:44.205322: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386100 next 770 of size 512\n2020-06-25 16:43:44.205352: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386300 next 771 of size 256\n2020-06-25 16:43:44.205368: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386400 next 772 of size 256\n2020-06-25 16:43:44.205399: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386500 next 773 of size 256\n2020-06-25 16:43:44.205415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386600 next 774 of size 1024\n2020-06-25 16:43:44.205431: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386a00 next 775 of size 1024\n2020-06-25 16:43:44.205447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386e00 next 776 of size 1024\n2020-06-25 16:43:44.205463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd387200 next 777 of size 8192\n2020-06-25 16:43:44.205479: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389200 next 778 of size 1024\n2020-06-25 16:43:44.205507: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389600 next 779 of size 1024\n2020-06-25 16:43:44.205525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389a00 next 780 of size 1024\n2020-06-25 16:43:44.205541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389e00 next 781 of size 1024\n2020-06-25 16:43:44.205558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a200 next 782 of size 256\n2020-06-25 16:43:44.205574: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a300 next 783 of size 256\n2020-06-25 16:43:44.205604: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a400 next 784 of size 256\n2020-06-25 16:43:44.205620: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a500 next 785 of size 256\n2020-06-25 16:43:44.205636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a600 next 786 of size 256\n2020-06-25 16:43:44.205652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a700 next 787 of size 256\n2020-06-25 16:43:44.205680: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a800 next 788 of size 256\n2020-06-25 16:43:44.205694: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a900 next 789 of size 1024\n2020-06-25 16:43:44.205711: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38ad00 next 790 of size 1024\n2020-06-25 16:43:44.205728: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b100 next 791 of size 256\n2020-06-25 16:43:44.205745: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b200 next 792 of size 1024\n2020-06-25 16:43:44.205761: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b600 next 793 of size 512\n2020-06-25 16:43:44.205778: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b800 next 794 of size 1024\n2020-06-25 16:43:44.205807: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38bc00 next 795 of size 1024\n2020-06-25 16:43:44.205846: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c000 next 796 of size 1024\n2020-06-25 16:43:44.205865: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c400 next 797 of size 1024\n2020-06-25 16:43:44.205881: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c800 next 798 of size 1024\n2020-06-25 16:43:44.205898: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38cc00 next 799 of size 1024\n2020-06-25 16:43:44.205914: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d000 next 800 of size 1024\n2020-06-25 16:43:44.205930: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d400 next 801 of size 1024\n2020-06-25 16:43:44.205946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d800 next 802 of size 4096\n2020-06-25 16:43:44.205963: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38e800 next 803 of size 134217728\n2020-06-25 16:43:44.205979: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80538e800 next 804 of size 8192\n2020-06-25 16:43:44.205995: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390800 next 805 of size 256\n2020-06-25 16:43:44.206011: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390900 next 806 of size 256\n2020-06-25 16:43:44.206027: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390a00 next 807 of size 256\n2020-06-25 16:43:44.206043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390b00 next 808 of size 2097152\n2020-06-25 16:43:44.303418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590b00 next 809 of size 256\n2020-06-25 16:43:44.303451: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590c00 next 810 of size 256\n2020-06-25 16:43:44.303465: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590d00 next 811 of size 1024\n2020-06-25 16:43:44.303477: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591100 next 812 of size 1024\n2020-06-25 16:43:44.303488: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591500 next 813 of size 1024\n2020-06-25 16:43:44.303499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591900 next 814 of size 256\n2020-06-25 16:43:44.303511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591a00 next 815 of size 1024\n2020-06-25 16:43:44.303521: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591e00 next 816 of size 256\n2020-06-25 16:43:44.303533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591f00 next 817 of size 256\n2020-06-25 16:43:44.303544: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592000 next 818 of size 1024\n2020-06-25 16:43:44.303555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592400 next 819 of size 256\n2020-06-25 16:43:44.303565: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592500 next 820 of size 2048\n2020-06-25 16:43:44.303576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592d00 next 821 of size 256\n2020-06-25 16:43:44.303586: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592e00 next 822 of size 256\n2020-06-25 16:43:44.303597: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592f00 next 823 of size 512\n2020-06-25 16:43:44.303608: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593100 next 824 of size 1024\n2020-06-25 16:43:44.303618: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593500 next 825 of size 256\n2020-06-25 16:43:44.303629: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593600 next 826 of size 1024\n2020-06-25 16:43:44.303640: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593a00 next 827 of size 1024\n2020-06-25 16:43:44.303652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593e00 next 828 of size 1024\n2020-06-25 16:43:44.303663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594200 next 829 of size 1024\n2020-06-25 16:43:44.303674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594600 next 830 of size 1024\n2020-06-25 16:43:44.303699: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594a00 next 831 of size 1024\n2020-06-25 16:43:44.303714: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594e00 next 832 of size 1024\n2020-06-25 16:43:44.303726: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805595200 next 833 of size 2048\n2020-06-25 16:43:44.303738: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805595a00 next 834 of size 8192\n2020-06-25 16:43:44.303749: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805597a00 next 835 of size 1024\n2020-06-25 16:43:44.303760: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805597e00 next 836 of size 4096\n2020-06-25 16:43:44.303772: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805598e00 next 837 of size 512\n2020-06-25 16:43:44.303784: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599000 next 838 of size 1024\n2020-06-25 16:43:44.303796: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599400 next 839 of size 1024\n2020-06-25 16:43:44.303807: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599800 next 840 of size 1024\n2020-06-25 16:43:44.304021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599c00 next 841 of size 1024\n2020-06-25 16:43:44.304049: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a000 next 842 of size 1024\n2020-06-25 16:43:44.304063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a400 next 843 of size 1024\n2020-06-25 16:43:44.304075: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a800 next 844 of size 1024\n2020-06-25 16:43:44.304086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ac00 next 845 of size 256\n2020-06-25 16:43:44.304097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ad00 next 846 of size 8192\n2020-06-25 16:43:44.304109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559cd00 next 847 of size 256\n2020-06-25 16:43:44.304120: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ce00 next 848 of size 256\n2020-06-25 16:43:44.304132: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559cf00 next 849 of size 8192\n2020-06-25 16:43:44.304143: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ef00 next 850 of size 256\n2020-06-25 16:43:44.304153: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f000 next 851 of size 512\n2020-06-25 16:43:44.304164: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f200 next 852 of size 512\n2020-06-25 16:43:44.304175: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f400 next 853 of size 1024\n2020-06-25 16:43:44.304199: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f800 next 854 of size 1024\n2020-06-25 16:43:44.304215: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559fc00 next 855 of size 8192\n2020-06-25 16:43:44.304227: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a1c00 next 856 of size 1024\n2020-06-25 16:43:44.304239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2000 next 857 of size 1024\n2020-06-25 16:43:44.304250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2400 next 858 of size 1024\n2020-06-25 16:43:44.304261: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2800 next 859 of size 1024\n2020-06-25 16:43:44.304272: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2c00 next 860 of size 1024\n2020-06-25 16:43:44.304282: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3000 next 861 of size 1024\n2020-06-25 16:43:44.304293: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3400 next 862 of size 256\n2020-06-25 16:43:44.304302: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3500 next 863 of size 256\n2020-06-25 16:43:44.304312: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3600 next 864 of size 1024\n2020-06-25 16:43:44.304317: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3a00 next 865 of size 256\n2020-06-25 16:43:44.304323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3b00 next 866 of size 8192\n2020-06-25 16:43:44.304328: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a5b00 next 867 of size 1024\n2020-06-25 16:43:44.304334: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a5f00 next 868 of size 1024\n2020-06-25 16:43:44.304339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6300 next 869 of size 1024\n2020-06-25 16:43:44.304344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6700 next 870 of size 1024\n2020-06-25 16:43:44.304350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6b00 next 871 of size 256\n2020-06-25 16:43:44.304355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6c00 next 872 of size 1024\n2020-06-25 16:43:44.304361: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7000 next 873 of size 256\n2020-06-25 16:43:44.304366: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7100 next 874 of size 256\n2020-06-25 16:43:44.304371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7200 next 875 of size 1024\n2020-06-25 16:43:44.304377: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7600 next 876 of size 1024\n2020-06-25 16:43:44.304382: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7a00 next 877 of size 1024\n2020-06-25 16:43:44.304387: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7e00 next 878 of size 1024\n2020-06-25 16:43:44.304393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8200 next 879 of size 1024\n2020-06-25 16:43:44.304398: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8600 next 880 of size 1024\n2020-06-25 16:43:44.304404: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8a00 next 881 of size 1024\n2020-06-25 16:43:44.304409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8e00 next 882 of size 1024\n2020-06-25 16:43:44.304415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9200 next 883 of size 2048\n2020-06-25 16:43:44.304420: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9a00 next 884 of size 256\n2020-06-25 16:43:44.304426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9b00 next 885 of size 256\n2020-06-25 16:43:44.304431: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9c00 next 886 of size 2048\n2020-06-25 16:43:44.304436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa400 next 887 of size 256\n2020-06-25 16:43:44.304442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa500 next 888 of size 512\n2020-06-25 16:43:44.304447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa700 next 889 of size 1024\n2020-06-25 16:43:44.304453: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aab00 next 890 of size 1024\n2020-06-25 16:43:44.304458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aaf00 next 891 of size 2048\n2020-06-25 16:43:44.304464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ab700 next 892 of size 1024\n2020-06-25 16:43:44.304469: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055abb00 next 893 of size 1024\n2020-06-25 16:43:44.304474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055abf00 next 894 of size 256\n2020-06-25 16:43:44.304480: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac000 next 895 of size 256\n2020-06-25 16:43:44.304485: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac100 next 896 of size 512\n2020-06-25 16:43:44.304491: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac300 next 897 of size 512\n2020-06-25 16:43:44.304496: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac500 next 898 of size 512\n2020-06-25 16:43:44.304501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac700 next 899 of size 256\n2020-06-25 16:43:44.304507: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac800 next 900 of size 1024\n2020-06-25 16:43:44.304512: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055acc00 next 901 of size 1024\n2020-06-25 16:43:44.304529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad000 next 902 of size 1024\n2020-06-25 16:43:44.304535: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad400 next 903 of size 1024\n2020-06-25 16:43:44.304540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad800 next 904 of size 1024\n2020-06-25 16:43:44.304545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055adc00 next 905 of size 1024\n2020-06-25 16:43:44.304551: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae000 next 906 of size 1024\n2020-06-25 16:43:44.304556: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae400 next 907 of size 256\n2020-06-25 16:43:44.304561: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae500 next 908 of size 1024\n2020-06-25 16:43:44.304866: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae900 next 909 of size 1024\n2020-06-25 16:43:44.304901: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aed00 next 910 of size 256\n2020-06-25 16:43:44.304941: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aee00 next 911 of size 1024\n2020-06-25 16:43:44.305105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af200 next 912 of size 256\n2020-06-25 16:43:44.305134: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af300 next 913 of size 1024\n2020-06-25 16:43:44.305155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af700 next 914 of size 512\n2020-06-25 16:43:44.305180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af900 next 915 of size 256\n2020-06-25 16:43:44.305222: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055afa00 next 916 of size 32768\n2020-06-25 16:43:44.305259: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055b7a00 next 917 of size 32768\n2020-06-25 16:43:44.305295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055bfa00 next 918 of size 4096\n2020-06-25 16:43:44.305320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055c0a00 next 919 of size 2359296\n2020-06-25 16:43:44.305499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805800a00 next 920 of size 2359296\n2020-06-25 16:43:44.305538: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40a00 next 921 of size 256\n2020-06-25 16:43:44.305575: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40b00 next 922 of size 512\n2020-06-25 16:43:44.305605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40d00 next 923 of size 1024\n2020-06-25 16:43:44.305628: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41100 next 924 of size 1024\n2020-06-25 16:43:44.305790: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41500 next 925 of size 256\n2020-06-25 16:43:44.305906: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41600 next 926 of size 1024\n2020-06-25 16:43:44.305952: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41a00 next 927 of size 1024\n2020-06-25 16:43:44.306099: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41e00 next 928 of size 1024\n2020-06-25 16:43:44.306135: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42200 next 929 of size 1024\n2020-06-25 16:43:44.306157: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42600 next 930 of size 1024\n2020-06-25 16:43:44.306178: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42a00 next 931 of size 1024\n2020-06-25 16:43:44.306218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42e00 next 932 of size 256\n2020-06-25 16:43:44.306256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42f00 next 933 of size 1024\n2020-06-25 16:43:44.306293: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43300 next 934 of size 1024\n2020-06-25 16:43:44.306319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43700 next 935 of size 1024\n2020-06-25 16:43:44.306471: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43b00 next 936 of size 1024\n2020-06-25 16:43:44.306507: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43f00 next 937 of size 512\n2020-06-25 16:43:44.306529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44100 next 938 of size 1024\n2020-06-25 16:43:44.306575: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44500 next 939 of size 1179648\n2020-06-25 16:43:44.306611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805b64500 next 940 of size 1179648\n2020-06-25 16:43:44.306636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805c84500 next 941 of size 33554432\n2020-06-25 16:43:44.306785: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x807c84500 next 942 of size 33554432\n2020-06-25 16:43:44.306849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809c84500 next 943 of size 294912\n2020-06-25 16:43:44.306892: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809ccc500 next 944 of size 294912\n2020-06-25 16:43:44.306919: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14500 next 945 of size 256\n2020-06-25 16:43:44.307068: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14600 next 946 of size 256\n2020-06-25 16:43:44.307098: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14700 next 947 of size 2097152\n2020-06-25 16:43:44.307120: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809f14700 next 948 of size 2097152\n2020-06-25 16:43:44.307139: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114700 next 949 of size 1024\n2020-06-25 16:43:44.307158: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114b00 next 950 of size 2048\n2020-06-25 16:43:44.307217: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115300 next 951 of size 1024\n2020-06-25 16:43:44.307443: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115700 next 952 of size 8192\n2020-06-25 16:43:44.307489: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117700 next 953 of size 1024\n2020-06-25 16:43:44.307512: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117b00 next 954 of size 2359296\n2020-06-25 16:43:44.307532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a357b00 next 955 of size 2359296\n2020-06-25 16:43:44.307552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a597b00 next 956 of size 1179648\n2020-06-25 16:43:44.307586: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a6b7b00 next 957 of size 1179648\n2020-06-25 16:43:44.307611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a7d7b00 next 958 of size 2097152\n2020-06-25 16:43:44.307767: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a9d7b00 next 959 of size 2097152\n2020-06-25 16:43:44.307794: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80abd7b00 next 960 of size 2359296\n2020-06-25 16:43:44.307839: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ae17b00 next 961 of size 2359296\n2020-06-25 16:43:44.307867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b057b00 next 963 of size 8192\n2020-06-25 16:43:44.307890: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b059b00 next 964 of size 8192\n2020-06-25 16:43:44.307926: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05bb00 next 965 of size 8192\n2020-06-25 16:43:44.307958: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05db00 next 966 of size 524288\n2020-06-25 16:43:44.307982: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b0ddb00 next 967 of size 524288\n2020-06-25 16:43:44.308129: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15db00 next 968 of size 1024\n2020-06-25 16:43:44.308163: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15df00 next 969 of size 1024\n2020-06-25 16:43:44.308210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15e300 next 970 of size 2359296\n2020-06-25 16:43:44.308239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e300 next 971 of size 1024\n2020-06-25 16:43:44.308416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e700 next 972 of size 1024\n2020-06-25 16:43:44.308447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39eb00 next 974 of size 262144\n2020-06-25 16:43:44.308470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b3deb00 next 975 of size 2359296\n2020-06-25 16:43:44.308490: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b61eb00 next 976 of size 2359296\n2020-06-25 16:43:44.308512: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b85eb00 next 977 of size 2359296\n2020-06-25 16:43:44.308555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ba9eb00 next 978 of size 2359296\n2020-06-25 16:43:44.308592: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdeb00 next 979 of size 2048\n2020-06-25 16:43:44.308631: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdf300 next 980 of size 2359296\n2020-06-25 16:43:44.308793: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bf1f300 next 981 of size 2359296\n2020-06-25 16:43:44.308856: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c15f300 next 982 of size 4096\n2020-06-25 16:43:44.308884: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160300 next 983 of size 256\n2020-06-25 16:43:44.308920: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160400 next 984 of size 1024\n2020-06-25 16:43:44.309063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160800 next 985 of size 32768\n2020-06-25 16:43:44.309103: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c168800 next 986 of size 32768\n2020-06-25 16:43:44.309128: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c170800 next 987 of size 2359296\n2020-06-25 16:43:44.309150: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c3b0800 next 988 of size 2359296\n2020-06-25 16:43:44.309171: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c5f0800 next 989 of size 2359296\n2020-06-25 16:43:44.309219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c830800 next 990 of size 2359296\n2020-06-25 16:43:44.309256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ca70800 next 991 of size 33554432\n2020-06-25 16:43:44.309282: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ea70800 next 992 of size 33554432\n2020-06-25 16:43:44.309431: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810a70800 next 993 of size 2359296\n2020-06-25 16:43:44.309466: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810cb0800 next 994 of size 2359296\n2020-06-25 16:43:44.309501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810ef0800 next 995 of size 131072\n2020-06-25 16:43:44.309529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f10800 next 996 of size 131072\n2020-06-25 16:43:44.309559: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f30800 next 997 of size 2359296\n2020-06-25 16:43:44.309583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811170800 next 998 of size 2359296\n2020-06-25 16:43:44.309611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8113b0800 next 1001 of size 2359296\n2020-06-25 16:43:44.309767: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8115f0800 next 1002 of size 2359296\n2020-06-25 16:43:44.309792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811830800 next 1003 of size 8388608\n2020-06-25 16:43:44.309849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812030800 next 1004 of size 8388608\n2020-06-25 16:43:44.309992: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830800 next 1005 of size 1024\n2020-06-25 16:43:44.310027: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830c00 next 1006 of size 2359296\n2020-06-25 16:43:44.310050: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812a70c00 next 1007 of size 2359296\n2020-06-25 16:43:44.310082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb0c00 next 1008 of size 1024\n2020-06-25 16:43:44.310114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1000 next 1009 of size 1024\n2020-06-25 16:43:44.310146: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1400 next 1010 of size 1024\n2020-06-25 16:43:44.310358: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1800 next 1011 of size 1024\n2020-06-25 16:43:44.310425: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1c00 next 1012 of size 262144\n2020-06-25 16:43:44.310460: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cf1c00 next 1013 of size 1179648\n2020-06-25 16:43:44.310477: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812e11c00 next 1014 of size 1179648\n2020-06-25 16:43:44.310492: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f31c00 next 1015 of size 262144\n2020-06-25 16:43:44.310508: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f71c00 next 1016 of size 262144\n2020-06-25 16:43:44.310522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812fb1c00 next 1017 of size 524288\n2020-06-25 16:43:44.310538: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813031c00 next 1018 of size 524288\n2020-06-25 16:43:44.310553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8130b1c00 next 1019 of size 2359296\n2020-06-25 16:43:44.310570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8132f1c00 next 1020 of size 2359296\n2020-06-25 16:43:44.310587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813531c00 next 1021 of size 12288\n2020-06-25 16:43:44.310601: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813534c00 next 1022 of size 12288\n2020-06-25 16:43:44.310629: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813537c00 next 1023 of size 2048\n2020-06-25 16:43:44.310647: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813538400 next 1024 of size 1179648\n2020-06-25 16:43:44.310665: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813658400 next 1025 of size 1179648\n2020-06-25 16:43:44.310687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778400 next 1026 of size 256\n2020-06-25 16:43:44.310720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778500 next 1027 of size 1024\n2020-06-25 16:43:44.310740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778900 next 1028 of size 1024\n2020-06-25 16:43:44.310759: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778d00 next 1029 of size 2359296\n2020-06-25 16:43:44.310792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b8d00 next 1030 of size 1024\n2020-06-25 16:43:44.311047: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9100 next 1031 of size 1024\n2020-06-25 16:43:44.311317: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9500 next 1032 of size 37632\n2020-06-25 16:43:44.311350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139c2800 next 1033 of size 37632\n2020-06-25 16:43:44.311375: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139cbb00 next 1034 of size 524288\n2020-06-25 16:43:44.311397: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813a4bb00 next 1035 of size 524288\n2020-06-25 16:43:44.311417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813acbb00 next 1036 of size 37632\n2020-06-25 16:43:44.311438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ad4e00 next 1037 of size 37632\n2020-06-25 16:43:44.311498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ade100 next 1038 of size 524288\n2020-06-25 16:43:44.311533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813b5e100 next 1039 of size 524288\n2020-06-25 16:43:44.311558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813bde100 next 1040 of size 262144\n2020-06-25 16:43:44.311715: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c1e100 next 1041 of size 262144\n2020-06-25 16:43:44.311751: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c5e100 next 1042 of size 2359296\n2020-06-25 16:43:44.311775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813e9e100 next 1043 of size 2359296\n2020-06-25 16:43:44.311836: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8140de100 next 1044 of size 8388608\n2020-06-25 16:43:44.312006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8148de100 next 1045 of size 8388608\n2020-06-25 16:43:44.312042: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8150de100 next 1046 of size 262144\n2020-06-25 16:43:44.312064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81511e100 next 1047 of size 262144\n2020-06-25 16:43:44.312086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81515e100 next 1048 of size 2359296\n2020-06-25 16:43:44.312106: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81539e100 next 1049 of size 2359296\n2020-06-25 16:43:44.312137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8155de100 next 1050 of size 33554432\n2020-06-25 16:43:44.312163: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8175de100 next 1051 of size 33554432\n2020-06-25 16:43:44.312328: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195de100 next 1052 of size 131072\n2020-06-25 16:43:44.312357: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe100 next 1053 of size 1024\n2020-06-25 16:43:44.312391: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe500 next 1054 of size 1024\n2020-06-25 16:43:44.312414: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe900 next 1055 of size 2097152\n2020-06-25 16:43:44.312437: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fe900 next 1056 of size 1024\n2020-06-25 16:43:44.312479: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fed00 next 1057 of size 131072\n2020-06-25 16:43:44.312516: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981ed00 next 1058 of size 1024\n2020-06-25 16:43:44.312543: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f100 next 1059 of size 1024\n2020-06-25 16:43:44.312739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f500 next 1060 of size 2359296\n2020-06-25 16:43:44.312777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819a5f500 next 1061 of size 2359296\n2020-06-25 16:43:44.312802: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819c9f500 next 1062 of size 2359296\n2020-06-25 16:43:44.312859: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819edf500 next 1063 of size 2359296\n2020-06-25 16:43:44.312911: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a11f500 next 1064 of size 2359296\n2020-06-25 16:43:44.312978: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a35f500 next 1065 of size 2359296\n2020-06-25 16:43:44.313154: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a59f500 next 18446744073709551615 of size 158075648\n2020-06-25 16:43:44.313217: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4294967296\n2020-06-25 16:43:44.313257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x823e60000 next 678 of size 1073741824\n2020-06-25 16:43:44.313433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x863e60000 next 962 of size 1073741824\n2020-06-25 16:43:44.313470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8a3e60000 next 973 of size 1073741824\n2020-06-25 16:43:44.313505: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8e3e60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:44.313527: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2202261760\n2020-06-25 16:43:44.313548: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x923e60000 next 1000 of size 1073741824\n2020-06-25 16:43:44.313589: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x963e60000 next 1066 of size 134217728\n2020-06-25 16:43:44.313738: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be60000 next 1067 of size 12288\n2020-06-25 16:43:44.313800: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be63000 next 1068 of size 12288\n2020-06-25 16:43:44.313849: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be66000 next 1069 of size 33554432\n2020-06-25 16:43:44.313875: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96de66000 next 1070 of size 33554432\n2020-06-25 16:43:44.313896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe66000 next 1071 of size 12288\n2020-06-25 16:43:44.313938: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe69000 next 1072 of size 12288\n2020-06-25 16:43:44.313989: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c000 next 1073 of size 2048\n2020-06-25 16:43:44.314023: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c800 next 1074 of size 262144\n2020-06-25 16:43:44.314046: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feac800 next 1075 of size 262144\n2020-06-25 16:43:44.314212: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feec800 next 1076 of size 2359296\n2020-06-25 16:43:44.314244: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97012c800 next 1077 of size 2359296\n2020-06-25 16:43:44.314286: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97036c800 next 1078 of size 294912\n2020-06-25 16:43:44.314323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703b4800 next 1079 of size 294912\n2020-06-25 16:43:44.314350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703fc800 next 1080 of size 2097152\n2020-06-25 16:43:44.314501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fc800 next 1081 of size 1024\n2020-06-25 16:43:44.314537: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fcc00 next 1082 of size 1024\n2020-06-25 16:43:44.314562: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fd000 next 1083 of size 2359296\n2020-06-25 16:43:44.314601: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d000 next 1084 of size 1024\n2020-06-25 16:43:44.314630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d400 next 1085 of size 2048\n2020-06-25 16:43:44.314655: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083dc00 next 1086 of size 294912\n2020-06-25 16:43:44.314830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970885c00 next 1087 of size 294912\n2020-06-25 16:43:44.314870: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9708cdc00 next 1088 of size 294912\n2020-06-25 16:43:44.314894: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970915c00 next 1089 of size 294912\n2020-06-25 16:43:44.314929: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97095dc00 next 1090 of size 37632\n2020-06-25 16:43:44.315087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970966f00 next 1091 of size 37632\n2020-06-25 16:43:44.315129: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970970200 next 1092 of size 2359296\n2020-06-25 16:43:44.315169: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970bb0200 next 1093 of size 2359296\n2020-06-25 16:43:44.315220: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df0200 next 1094 of size 8192\n2020-06-25 16:43:44.315247: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df2200 next 1095 of size 8192\n2020-06-25 16:43:44.315285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df4200 next 1096 of size 8192\n2020-06-25 16:43:44.315318: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df6200 next 1097 of size 2359296\n2020-06-25 16:43:44.315344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971036200 next 1098 of size 2359296\n2020-06-25 16:43:44.315520: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971276200 next 1099 of size 262144\n2020-06-25 16:43:44.315555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712b6200 next 1100 of size 262144\n2020-06-25 16:43:44.315592: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712f6200 next 1101 of size 2097152\n2020-06-25 16:43:44.315630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9714f6200 next 1102 of size 2097152\n2020-06-25 16:43:44.315663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9716f6200 next 1103 of size 134217728\n2020-06-25 16:43:44.315689: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9796f6200 next 1104 of size 134217728\n2020-06-25 16:43:44.315711: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6200 next 1105 of size 512\n2020-06-25 16:43:44.315902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6400 next 1106 of size 512\n2020-06-25 16:43:44.315936: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6600 next 1107 of size 1024\n2020-06-25 16:43:44.315976: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6a00 next 1108 of size 2359296\n2020-06-25 16:43:44.316131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981936a00 next 1109 of size 2359296\n2020-06-25 16:43:44.316199: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981b76a00 next 1110 of size 8388608\n2020-06-25 16:43:44.316229: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376a00 next 1111 of size 1024\n2020-06-25 16:43:44.316252: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376e00 next 1112 of size 1024\n2020-06-25 16:43:44.316285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982377200 next 1113 of size 12288\n2020-06-25 16:43:44.316311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237a200 next 1114 of size 12288\n2020-06-25 16:43:44.316474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237d200 next 1115 of size 2097152\n2020-06-25 16:43:44.316501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98257d200 next 1116 of size 2097152\n2020-06-25 16:43:44.316525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98277d200 next 1117 of size 8388608\n2020-06-25 16:43:44.316558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982f7d200 next 1118 of size 8388608\n2020-06-25 16:43:44.316579: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377d200 next 1119 of size 8192\n2020-06-25 16:43:44.316622: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377f200 next 1120 of size 8192\n2020-06-25 16:43:44.316656: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983781200 next 1121 of size 524288\n2020-06-25 16:43:44.316682: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983801200 next 1122 of size 524288\n2020-06-25 16:43:44.316705: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983881200 next 1123 of size 2359296\n2020-06-25 16:43:44.316883: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983ac1200 next 1124 of size 2359296\n2020-06-25 16:43:44.316910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983d01200 next 1125 of size 2359296\n2020-06-25 16:43:44.316943: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983f41200 next 1126 of size 2359296\n2020-06-25 16:43:44.316969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984181200 next 1127 of size 37632\n2020-06-25 16:43:44.317125: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98418a500 next 1128 of size 37632\n2020-06-25 16:43:44.317151: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193800 next 1129 of size 1024\n2020-06-25 16:43:44.317173: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193c00 next 1130 of size 2048\n2020-06-25 16:43:44.317210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984194400 next 1131 of size 2359296\n2020-06-25 16:43:44.317250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4400 next 1132 of size 1024\n2020-06-25 16:43:44.317295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4800 next 1133 of size 2359296\n2020-06-25 16:43:44.317321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984614800 next 1134 of size 2359296\n2020-06-25 16:43:44.317509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984854800 next 1135 of size 2359296\n2020-06-25 16:43:44.317549: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984a94800 next 1136 of size 2359296\n2020-06-25 16:43:44.317587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984cd4800 next 1137 of size 2359296\n2020-06-25 16:43:44.317627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984f14800 next 1138 of size 2359296\n2020-06-25 16:43:44.317664: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154800 next 1139 of size 1024\n2020-06-25 16:43:44.317688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154c00 next 1140 of size 512\n2020-06-25 16:43:44.317710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154e00 next 1141 of size 8192\n2020-06-25 16:43:44.317883: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985156e00 next 1142 of size 8192\n2020-06-25 16:43:44.317921: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985158e00 next 1143 of size 1024\n2020-06-25 16:43:44.317946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159200 next 1144 of size 2048\n2020-06-25 16:43:44.317983: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159a00 next 1145 of size 1024\n2020-06-25 16:43:44.318019: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159e00 next 1146 of size 1024\n2020-06-25 16:43:44.318046: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98515a200 next 1147 of size 8388608\n2020-06-25 16:43:44.318211: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98595a200 next 1148 of size 524288\n2020-06-25 16:43:44.318250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9859da200 next 1149 of size 524288\n2020-06-25 16:43:44.318287: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985a5a200 next 1150 of size 2359296\n2020-06-25 16:43:44.318313: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985c9a200 next 1151 of size 2359296\n2020-06-25 16:43:44.318472: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985eda200 next 1152 of size 2097152\n2020-06-25 16:43:44.318499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9860da200 next 1153 of size 2097152\n2020-06-25 16:43:44.318522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9862da200 next 1154 of size 2359296\n2020-06-25 16:43:44.318542: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98651a200 next 1155 of size 2359296\n2020-06-25 16:43:44.318564: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a200 next 1156 of size 1024\n2020-06-25 16:43:44.318604: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a600 next 1157 of size 2359296\n2020-06-25 16:43:44.318642: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98699a600 next 1158 of size 2359296\n2020-06-25 16:43:44.318669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bda600 next 1159 of size 1024\n2020-06-25 16:43:44.318855: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaa00 next 1160 of size 256\n2020-06-25 16:43:44.318893: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdab00 next 1161 of size 256\n2020-06-25 16:43:44.318917: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdac00 next 1162 of size 256\n2020-06-25 16:43:44.318953: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdad00 next 1163 of size 256\n2020-06-25 16:43:44.318985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdae00 next 1164 of size 256\n2020-06-25 16:43:44.319010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaf00 next 1165 of size 256\n2020-06-25 16:43:44.319039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb000 next 1166 of size 256\n2020-06-25 16:43:44.319215: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb100 next 1167 of size 256\n2020-06-25 16:43:44.319265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb200 next 1168 of size 256\n2020-06-25 16:43:44.319418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb300 next 1169 of size 256\n2020-06-25 16:43:44.319454: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb400 next 1170 of size 256\n2020-06-25 16:43:44.319478: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb500 next 1171 of size 256\n2020-06-25 16:43:44.319499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb600 next 1172 of size 256\n2020-06-25 16:43:44.319520: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb700 next 1173 of size 256\n2020-06-25 16:43:44.319551: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb800 next 1174 of size 256\n2020-06-25 16:43:44.319577: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb900 next 1175 of size 256\n2020-06-25 16:43:44.319737: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdba00 next 1176 of size 256\n2020-06-25 16:43:44.319768: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbb00 next 1177 of size 256\n2020-06-25 16:43:44.319791: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbc00 next 1178 of size 256\n2020-06-25 16:43:44.319833: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbd00 next 1179 of size 256\n2020-06-25 16:43:44.319864: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbe00 next 1180 of size 256\n2020-06-25 16:43:44.319905: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbf00 next 1181 of size 256\n2020-06-25 16:43:44.319943: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc000 next 1182 of size 256\n2020-06-25 16:43:44.319968: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc100 next 1183 of size 256\n2020-06-25 16:43:44.320125: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc200 next 1184 of size 256\n2020-06-25 16:43:44.320162: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc300 next 1185 of size 256\n2020-06-25 16:43:44.320210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc400 next 1186 of size 256\n2020-06-25 16:43:44.320241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc500 next 1187 of size 256\n2020-06-25 16:43:44.320399: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc600 next 1188 of size 256\n2020-06-25 16:43:44.320429: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc700 next 1189 of size 256\n2020-06-25 16:43:44.320452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc800 next 1190 of size 256\n2020-06-25 16:43:44.320474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc900 next 1191 of size 256\n2020-06-25 16:43:44.320496: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdca00 next 1192 of size 256\n2020-06-25 16:43:44.320550: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcb00 next 1193 of size 256\n2020-06-25 16:43:44.320734: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcc00 next 1194 of size 256\n2020-06-25 16:43:44.320775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcd00 next 1195 of size 256\n2020-06-25 16:43:44.320797: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdce00 next 1196 of size 256\n2020-06-25 16:43:44.320839: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcf00 next 1197 of size 256\n2020-06-25 16:43:44.320867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd000 next 1198 of size 256\n2020-06-25 16:43:44.320901: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd100 next 1199 of size 256\n2020-06-25 16:43:44.320926: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd200 next 1200 of size 256\n2020-06-25 16:43:44.321083: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd300 next 1201 of size 256\n2020-06-25 16:43:44.321109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd400 next 1202 of size 256\n2020-06-25 16:43:44.321131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd500 next 1203 of size 256\n2020-06-25 16:43:44.321151: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd600 next 1204 of size 256\n2020-06-25 16:43:44.321172: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd700 next 1205 of size 256\n2020-06-25 16:43:44.321225: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd800 next 1206 of size 256\n2020-06-25 16:43:44.321409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd900 next 1207 of size 256\n2020-06-25 16:43:44.321435: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdda00 next 1208 of size 256\n2020-06-25 16:43:44.321464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddb00 next 1209 of size 256\n2020-06-25 16:43:44.321490: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddc00 next 1210 of size 256\n2020-06-25 16:43:44.321512: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddd00 next 1211 of size 256\n2020-06-25 16:43:44.321549: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdde00 next 1212 of size 256\n2020-06-25 16:43:44.321583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddf00 next 1213 of size 256\n2020-06-25 16:43:44.321609: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde000 next 1214 of size 256\n2020-06-25 16:43:44.321776: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde100 next 1215 of size 256\n2020-06-25 16:43:44.321830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde200 next 1216 of size 256\n2020-06-25 16:43:44.321863: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde300 next 1217 of size 256\n2020-06-25 16:43:44.321902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde400 next 1218 of size 256\n2020-06-25 16:43:44.321940: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde500 next 1219 of size 256\n2020-06-25 16:43:44.321966: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde600 next 1220 of size 256\n2020-06-25 16:43:44.322119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde700 next 1221 of size 256\n2020-06-25 16:43:44.322155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde800 next 1222 of size 256\n2020-06-25 16:43:44.322180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde900 next 1223 of size 256\n2020-06-25 16:43:44.322359: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdea00 next 1224 of size 256\n2020-06-25 16:43:44.322398: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdeb00 next 1225 of size 256\n2020-06-25 16:43:44.322423: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdec00 next 1226 of size 256\n2020-06-25 16:43:44.322444: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bded00 next 1227 of size 256\n2020-06-25 16:43:44.322465: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdee00 next 1228 of size 256\n2020-06-25 16:43:44.322498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdef00 next 1229 of size 256\n2020-06-25 16:43:44.322524: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf000 next 1230 of size 256\n2020-06-25 16:43:44.322688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf100 next 1231 of size 256\n2020-06-25 16:43:44.322719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf200 next 1232 of size 4096\n2020-06-25 16:43:44.322742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0200 next 1233 of size 256\n2020-06-25 16:43:44.322764: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0300 next 1234 of size 4096\n2020-06-25 16:43:44.322785: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1300 next 1235 of size 256\n2020-06-25 16:43:44.322838: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1400 next 1236 of size 1024\n2020-06-25 16:43:44.322868: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986be1800 next 1237 of size 256\n2020-06-25 16:43:44.323027: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1900 next 1238 of size 1024\n2020-06-25 16:43:44.323056: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1d00 next 1239 of size 512\n2020-06-25 16:43:44.323077: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1f00 next 1240 of size 256\n2020-06-25 16:43:44.323097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2000 next 1241 of size 1024\n2020-06-25 16:43:44.323117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2400 next 1242 of size 1024\n2020-06-25 16:43:44.323150: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2800 next 1243 of size 1024\n2020-06-25 16:43:44.323176: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2c00 next 1358 of size 256\n2020-06-25 16:43:44.323228: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2d00 next 1375 of size 256\n2020-06-25 16:43:44.323378: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2e00 next 1380 of size 256\n2020-06-25 16:43:44.323413: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2f00 next 1244 of size 256\n2020-06-25 16:43:44.323437: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3000 next 1245 of size 1024\n2020-06-25 16:43:44.323473: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3400 next 1246 of size 1024\n2020-06-25 16:43:44.323504: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3800 next 1247 of size 1024\n2020-06-25 16:43:44.323529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986be3c00 next 1251 of size 1024\n2020-06-25 16:43:44.323674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be4000 next 1252 of size 8192\n2020-06-25 16:43:44.323710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986be6000 next 1256 of size 1024\n2020-06-25 16:43:44.323734: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6400 next 1257 of size 2048\n2020-06-25 16:43:44.323769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986be6c00 next 1261 of size 1024\n2020-06-25 16:43:44.323933: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be7000 next 1262 of size 8192\n2020-06-25 16:43:44.323977: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986be9000 next 1265 of size 768\n2020-06-25 16:43:44.324002: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9300 next 1266 of size 2048\n2020-06-25 16:43:44.324024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986be9b00 next 1268 of size 512\n2020-06-25 16:43:44.324044: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9d00 next 1269 of size 2048\n2020-06-25 16:43:44.324077: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bea500 next 1270 of size 256\n2020-06-25 16:43:44.324102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea600 next 1271 of size 2048\n2020-06-25 16:43:44.324270: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986beae00 next 1276 of size 1280\n2020-06-25 16:43:44.324297: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb300 next 1277 of size 256\n2020-06-25 16:43:44.324320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb400 next 1278 of size 256\n2020-06-25 16:43:44.324340: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb500 next 1279 of size 1024\n2020-06-25 16:43:44.324361: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb900 next 1280 of size 1024\n2020-06-25 16:43:44.324397: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bebd00 next 1281 of size 1024\n2020-06-25 16:43:44.324436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec100 next 1282 of size 1024\n2020-06-25 16:43:44.324461: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec500 next 1283 of size 512\n2020-06-25 16:43:44.324611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec700 next 1405 of size 256\n2020-06-25 16:43:44.324659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec800 next 1406 of size 256\n2020-06-25 16:43:44.324682: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bec900 next 1284 of size 512\n2020-06-25 16:43:44.324715: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becb00 next 1285 of size 1024\n2020-06-25 16:43:44.324739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becf00 next 1286 of size 1024\n2020-06-25 16:43:44.324938: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed300 next 1287 of size 1024\n2020-06-25 16:43:44.324965: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed700 next 1288 of size 1024\n2020-06-25 16:43:44.325017: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedb00 next 1289 of size 256\n2020-06-25 16:43:44.325036: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bedc00 next 1294 of size 1280\n2020-06-25 16:43:44.325057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bee100 next 1295 of size 8192\n2020-06-25 16:43:44.325099: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf0100 next 1296 of size 8192\n2020-06-25 16:43:44.325134: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bf2100 next 1299 of size 768\n2020-06-25 16:43:44.325160: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2400 next 1300 of size 33554432\n2020-06-25 16:43:44.325210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bf2400 next 1301 of size 32768\n2020-06-25 16:43:44.325241: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bfa400 next 1302 of size 524288\n2020-06-25 16:43:44.325478: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7a400 next 1303 of size 4096\n2020-06-25 16:43:44.325509: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7b400 next 1304 of size 12288\n2020-06-25 16:43:44.325532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e400 next 1305 of size 256\n2020-06-25 16:43:44.325554: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e500 next 1306 of size 524288\n2020-06-25 16:43:44.325575: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cfe500 next 1307 of size 4096\n2020-06-25 16:43:44.325594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cff500 next 1308 of size 32768\n2020-06-25 16:43:44.325626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d07500 next 1309 of size 32768\n2020-06-25 16:43:44.325651: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d0f500 next 1310 of size 8388608\n2020-06-25 16:43:44.325830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98950f500 next 1311 of size 16384\n2020-06-25 16:43:44.325865: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989513500 next 1312 of size 131072\n2020-06-25 16:43:44.325889: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989533500 next 1313 of size 131072\n2020-06-25 16:43:44.325910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989553500 next 1314 of size 524288\n2020-06-25 16:43:44.325931: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d3500 next 1315 of size 4096\n2020-06-25 16:43:44.325969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d4500 next 1316 of size 8388608\n2020-06-25 16:43:44.326005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd4500 next 1317 of size 16384\n2020-06-25 16:43:44.326031: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd8500 next 1318 of size 134217728\n2020-06-25 16:43:44.326194: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dd8500 next 1319 of size 65536\n2020-06-25 16:43:44.326234: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991de8500 next 1320 of size 8192\n2020-06-25 16:43:44.326279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dea500 next 1321 of size 12288\n2020-06-25 16:43:44.326313: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded500 next 1322 of size 256\n2020-06-25 16:43:44.326339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded600 next 1323 of size 2097152\n2020-06-25 16:43:44.326485: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fed600 next 1324 of size 8192\n2020-06-25 16:43:44.326522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fef600 next 1325 of size 2097152\n2020-06-25 16:43:44.326546: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921ef600 next 1326 of size 8192\n2020-06-25 16:43:44.326585: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921f1600 next 1327 of size 2097152\n2020-06-25 16:43:44.326633: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f1600 next 1328 of size 8192\n2020-06-25 16:43:44.326658: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3600 next 1389 of size 256\n2020-06-25 16:43:44.326692: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3700 next 1392 of size 256\n2020-06-25 16:43:44.326876: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3800 next 1394 of size 256\n2020-06-25 16:43:44.326908: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3900 next 1398 of size 1024\n2020-06-25 16:43:44.326946: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9923f3d00 next 1330 of size 2304\n2020-06-25 16:43:44.326983: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f4600 next 1331 of size 32768\n2020-06-25 16:43:44.327009: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923fc600 next 1332 of size 32768\n2020-06-25 16:43:44.327155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992404600 next 1333 of size 12288\n2020-06-25 16:43:44.327204: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407600 next 1334 of size 256\n2020-06-25 16:43:44.327245: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407700 next 1335 of size 12288\n2020-06-25 16:43:44.327284: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a700 next 1336 of size 256\n2020-06-25 16:43:44.327310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a800 next 1337 of size 8388608\n2020-06-25 16:43:44.327457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0a800 next 1338 of size 16384\n2020-06-25 16:43:44.327492: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0e800 next 1339 of size 2097152\n2020-06-25 16:43:44.327515: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e0e800 next 1340 of size 8192\n2020-06-25 16:43:44.327550: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e10800 next 1341 of size 524288\n2020-06-25 16:43:44.327581: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e90800 next 1342 of size 4096\n2020-06-25 16:43:44.327604: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e91800 next 1343 of size 131072\n2020-06-25 16:43:44.327757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992eb1800 next 1344 of size 131072\n2020-06-25 16:43:44.327804: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992ed1800 next 1345 of size 33554432\n2020-06-25 16:43:44.327854: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994ed1800 next 1346 of size 32768\n2020-06-25 16:43:44.327892: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x994ed9800 next 1347 of size 8192\n2020-06-25 16:43:44.327929: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994edb800 next 1348 of size 8388608\n2020-06-25 16:43:44.327953: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956db800 next 1349 of size 16384\n2020-06-25 16:43:44.328096: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956df800 next 1350 of size 134217728\n2020-06-25 16:43:44.328132: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6df800 next 1351 of size 65536\n2020-06-25 16:43:44.328166: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6ef800 next 1352 of size 33554432\n2020-06-25 16:43:44.328219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6ef800 next 1353 of size 32768\n2020-06-25 16:43:44.328250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7800 next 1354 of size 1024\n2020-06-25 16:43:44.328407: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7c00 next 1355 of size 524288\n2020-06-25 16:43:44.328439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f777c00 next 1356 of size 4096\n2020-06-25 16:43:44.328476: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f778c00 next 1357 of size 12288\n2020-06-25 16:43:44.328631: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f77bc00 next 1359 of size 524288\n2020-06-25 16:43:44.328665: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fbc00 next 1360 of size 4096\n2020-06-25 16:43:44.328688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fcc00 next 1361 of size 8192\n2020-06-25 16:43:44.328709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fec00 next 1362 of size 2097152\n2020-06-25 16:43:44.328752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f9fec00 next 1363 of size 32768\n2020-06-25 16:43:44.328773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa06c00 next 1364 of size 32768\n2020-06-25 16:43:44.328842: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa0ec00 next 1365 of size 8388608\n2020-06-25 16:43:44.329073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a020ec00 next 1366 of size 16384\n2020-06-25 16:43:44.329119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0212c00 next 1367 of size 2048\n2020-06-25 16:43:44.329141: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0213400 next 1368 of size 131072\n2020-06-25 16:43:44.329162: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0233400 next 1369 of size 131072\n2020-06-25 16:43:44.329182: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0253400 next 1370 of size 524288\n2020-06-25 16:43:44.329264: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3400 next 1371 of size 4096\n2020-06-25 16:43:44.329296: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d4400 next 1372 of size 8388608\n2020-06-25 16:43:44.329320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ad4400 next 1373 of size 16384\n2020-06-25 16:43:44.329465: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ad8400 next 1381 of size 65536\n2020-06-25 16:43:44.329498: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ae8400 next 1382 of size 12288\n2020-06-25 16:43:44.329538: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0aeb400 next 1376 of size 2294016\n2020-06-25 16:43:44.329577: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0d1b500 next 1377 of size 798976\n2020-06-25 16:43:44.329613: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0dde600 next 1378 of size 798976\n2020-06-25 16:43:44.329638: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ea1700 next 1379 of size 4194304\n2020-06-25 16:43:44.329783: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a12a1700 next 1374 of size 4194304\n2020-06-25 16:43:44.329838: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1700 next 1383 of size 2048\n2020-06-25 16:43:44.329870: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1f00 next 1384 of size 2097152\n2020-06-25 16:43:44.329907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a1f00 next 1385 of size 8192\n2020-06-25 16:43:44.330051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a3f00 next 1386 of size 2097152\n2020-06-25 16:43:44.330087: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa3f00 next 1387 of size 8192\n2020-06-25 16:43:44.330109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa5f00 next 1388 of size 33554432\n2020-06-25 16:43:44.330131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aa5f00 next 1329 of size 32768\n2020-06-25 16:43:44.330150: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aadf00 next 1390 of size 32768\n2020-06-25 16:43:44.330182: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab5f00 next 1391 of size 12288\n2020-06-25 16:43:44.330233: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab8f00 next 1393 of size 12288\n2020-06-25 16:43:44.330258: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3abbf00 next 1395 of size 2097152\n2020-06-25 16:43:44.330405: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3cbbf00 next 1396 of size 8388608\n2020-06-25 16:43:44.330440: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bbf00 next 1397 of size 16384\n2020-06-25 16:43:44.330464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bff00 next 1399 of size 2097152\n2020-06-25 16:43:44.330501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46bff00 next 1400 of size 8192\n2020-06-25 16:43:44.330531: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46c1f00 next 1401 of size 524288\n2020-06-25 16:43:44.330556: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4741f00 next 1402 of size 4096\n2020-06-25 16:43:44.330704: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4742f00 next 1403 of size 131072\n2020-06-25 16:43:44.330741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4762f00 next 1404 of size 131072\n2020-06-25 16:43:44.330766: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4782f00 next 18446744073709551615 of size 45197824\n2020-06-25 16:43:44.330801: I tensorflow/core/common_runtime/bfc_allocator.cc:914] Summary of in-use Chunks by size: \n2020-06-25 16:43:44.330968: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 323 Chunks of size 256 totalling 80.8KiB\n2020-06-25 16:43:44.331008: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 82 Chunks of size 512 totalling 41.0KiB\n2020-06-25 16:43:44.331036: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 464 Chunks of size 1024 totalling 464.0KiB\n2020-06-25 16:43:44.331060: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 1280 totalling 1.2KiB\n2020-06-25 16:43:44.331084: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 42 Chunks of size 2048 totalling 84.0KiB\n2020-06-25 16:43:44.331123: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 20 Chunks of size 4096 totalling 80.0KiB\n2020-06-25 16:43:44.331157: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 39 Chunks of size 8192 totalling 312.0KiB\n2020-06-25 16:43:44.331350: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 12288 totalling 288.0KiB\n2020-06-25 16:43:44.331390: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 7 Chunks of size 16384 totalling 112.0KiB\n2020-06-25 16:43:44.331417: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 32768 totalling 608.0KiB\n2020-06-25 16:43:44.331466: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 37632 totalling 588.0KiB\n2020-06-25 16:43:44.331640: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 3 Chunks of size 65536 totalling 192.0KiB\n2020-06-25 16:43:44.331671: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 131072 totalling 2.00MiB\n2020-06-25 16:43:44.331696: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 262144 totalling 6.00MiB\n2020-06-25 16:43:44.331718: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 15 Chunks of size 294912 totalling 4.22MiB\n2020-06-25 16:43:44.331742: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 447232 totalling 436.8KiB\n2020-06-25 16:43:44.331782: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 32 Chunks of size 524288 totalling 16.00MiB\n2020-06-25 16:43:44.331831: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 2 Chunks of size 798976 totalling 1.52MiB\n2020-06-25 16:43:44.331865: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 1179648 totalling 18.00MiB\n2020-06-25 16:43:44.332017: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 33 Chunks of size 2097152 totalling 66.00MiB\n2020-06-25 16:43:44.332053: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 2294016 totalling 2.19MiB\n2020-06-25 16:43:44.332098: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 122 Chunks of size 2359296 totalling 274.50MiB\n2020-06-25 16:43:44.332140: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3070464 totalling 2.93MiB\n2020-06-25 16:43:44.332168: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3145728 totalling 3.00MiB\n2020-06-25 16:43:44.332337: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3266560 totalling 3.12MiB\n2020-06-25 16:43:44.332381: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3400960 totalling 3.24MiB\n2020-06-25 16:43:44.332409: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 4 Chunks of size 4194304 totalling 16.00MiB\n2020-06-25 16:43:44.332558: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 23 Chunks of size 8388608 totalling 184.00MiB\n2020-06-25 16:43:44.332589: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 33554432 totalling 608.00MiB\n2020-06-25 16:43:44.332614: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 45197824 totalling 43.10MiB\n2020-06-25 16:43:44.332637: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 56033280 totalling 53.44MiB\n2020-06-25 16:43:44.332679: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 9 Chunks of size 134217728 totalling 1.12GiB\n2020-06-25 16:43:44.332707: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 158075648 totalling 150.75MiB\n2020-06-25 16:43:44.332909: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 8 Chunks of size 1073741824 totalling 8.00GiB\n2020-06-25 16:43:44.332938: I tensorflow/core/common_runtime/bfc_allocator.cc:921] Sum Total of in-use chunks: 10.55GiB\n2020-06-25 16:43:44.332961: I tensorflow/core/common_runtime/bfc_allocator.cc:923] total_region_allocated_bytes_: 11330115840 memory_limit_: 11330115994 available bytes: 154 curr_region_allocation_bytes_: 17179869184\n2020-06-25 16:43:44.332986: I tensorflow/core/common_runtime/bfc_allocator.cc:929] Stats: \nLimit: 11330115994\nInUse: 11330096640\nMaxInUse: 11330112768\nNumAllocs: 1645\nMaxAllocSize: 1073741824\n\n2020-06-25 16:43:44.333256: W tensorflow/core/common_runtime/bfc_allocator.cc:424] ****************************************************************************************************\n2020-06-25 16:43:44.333354: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at cwise_ops_common.h:259 : Resource exhausted: OOM when allocating tensor with shape[1,16384] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc\n2020-06-25 16:43:54.334735: W tensorflow/core/common_runtime/bfc_allocator.cc:419] Allocator (GPU_0_bfc) ran out of memory trying to allocate 8.00MiB (rounded to 8388608). Current allocation summary follows.\n2020-06-25 16:43:54.334857: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (256): \tTotal Chunks: 341, Chunks in use: 340. 85.2KiB allocated for chunks. 85.0KiB in use in bin. 22.8KiB client-requested in use in bin.\n2020-06-25 16:43:54.334890: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (512): \tTotal Chunks: 82, Chunks in use: 82. 41.0KiB allocated for chunks. 41.0KiB in use in bin. 41.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.334918: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (1024): \tTotal Chunks: 480, Chunks in use: 479. 481.5KiB allocated for chunks. 480.5KiB in use in bin. 479.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.334944: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (2048): \tTotal Chunks: 43, Chunks in use: 42. 86.0KiB allocated for chunks. 84.0KiB in use in bin. 84.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.334973: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (4096): \tTotal Chunks: 18, Chunks in use: 16. 75.0KiB allocated for chunks. 64.0KiB in use in bin. 64.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.334997: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (8192): \tTotal Chunks: 63, Chunks in use: 59. 600.0KiB allocated for chunks. 568.0KiB in use in bin. 568.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.335019: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (16384): \tTotal Chunks: 6, Chunks in use: 4. 96.0KiB allocated for chunks. 64.0KiB in use in bin. 64.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.335039: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (32768): \tTotal Chunks: 35, Chunks in use: 32. 1.17MiB allocated for chunks. 1.07MiB in use in bin. 1.07MiB client-requested in use in bin.\n2020-06-25 16:43:54.335060: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (65536): \tTotal Chunks: 3, Chunks in use: 2. 208.0KiB allocated for chunks. 128.0KiB in use in bin. 128.0KiB client-requested in use in bin.\n2020-06-25 16:43:54.335080: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (131072): \tTotal Chunks: 16, Chunks in use: 14. 2.00MiB allocated for chunks. 1.75MiB in use in bin. 1.75MiB client-requested in use in bin.\n2020-06-25 16:43:54.335100: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (262144): \tTotal Chunks: 40, Chunks in use: 40. 10.64MiB allocated for chunks. 10.64MiB in use in bin. 10.50MiB client-requested in use in bin.\n2020-06-25 16:43:54.335122: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (524288): \tTotal Chunks: 34, Chunks in use: 34. 17.52MiB allocated for chunks. 17.52MiB in use in bin. 17.52MiB client-requested in use in bin.\n2020-06-25 16:43:54.335143: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (1048576): \tTotal Chunks: 16, Chunks in use: 16. 18.00MiB allocated for chunks. 18.00MiB in use in bin. 18.00MiB client-requested in use in bin.\n2020-06-25 16:43:54.335163: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (2097152): \tTotal Chunks: 160, Chunks in use: 160. 354.97MiB allocated for chunks. 354.97MiB in use in bin. 351.50MiB client-requested in use in bin.\n2020-06-25 16:43:54.335194: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (4194304): \tTotal Chunks: 4, Chunks in use: 4. 16.00MiB allocated for chunks. 16.00MiB in use in bin. 12.50MiB client-requested in use in bin.\n2020-06-25 16:43:54.335218: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (8388608): \tTotal Chunks: 23, Chunks in use: 23. 184.00MiB allocated for chunks. 184.00MiB in use in bin. 184.00MiB client-requested in use in bin.\n2020-06-25 16:43:54.335237: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (16777216): \tTotal Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.\n2020-06-25 16:43:54.335258: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (33554432): \tTotal Chunks: 21, Chunks in use: 21. 704.54MiB allocated for chunks. 704.54MiB in use in bin. 672.00MiB client-requested in use in bin.\n2020-06-25 16:43:54.335278: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (67108864): \tTotal Chunks: 0, Chunks in use: 0. 0B allocated for chunks. 0B in use in bin. 0B client-requested in use in bin.\n2020-06-25 16:43:54.335298: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (134217728): \tTotal Chunks: 10, Chunks in use: 10. 1.27GiB allocated for chunks. 1.27GiB in use in bin. 1.25GiB client-requested in use in bin.\n2020-06-25 16:43:54.335318: I tensorflow/core/common_runtime/bfc_allocator.cc:869] Bin (268435456): \tTotal Chunks: 8, Chunks in use: 8. 8.00GiB allocated for chunks. 8.00GiB in use in bin. 8.00GiB client-requested in use in bin.\n2020-06-25 16:43:54.335337: I tensorflow/core/common_runtime/bfc_allocator.cc:885] Bin for 8.00MiB was 8.00MiB, Chunk State: \n2020-06-25 16:43:54.335354: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1048576\n2020-06-25 16:43:54.335374: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60000 next 1 of size 2048\n2020-06-25 16:43:54.335391: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60800 next 2 of size 256\n2020-06-25 16:43:54.335408: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60900 next 3 of size 1024\n2020-06-25 16:43:54.335425: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b60d00 next 4 of size 1024\n2020-06-25 16:43:54.335441: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61100 next 5 of size 256\n2020-06-25 16:43:54.335457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61200 next 6 of size 256\n2020-06-25 16:43:54.335473: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61300 next 7 of size 2048\n2020-06-25 16:43:54.335489: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61b00 next 8 of size 256\n2020-06-25 16:43:54.335505: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61c00 next 9 of size 256\n2020-06-25 16:43:54.335521: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61d00 next 10 of size 256\n2020-06-25 16:43:54.335537: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b61e00 next 11 of size 1024\n2020-06-25 16:43:54.335553: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62200 next 12 of size 256\n2020-06-25 16:43:54.335569: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62300 next 13 of size 1024\n2020-06-25 16:43:54.335584: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62700 next 14 of size 256\n2020-06-25 16:43:54.335601: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62800 next 15 of size 512\n2020-06-25 16:43:54.335617: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62a00 next 16 of size 256\n2020-06-25 16:43:54.335633: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62b00 next 17 of size 512\n2020-06-25 16:43:54.335649: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62d00 next 18 of size 512\n2020-06-25 16:43:54.335665: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b62f00 next 19 of size 256\n2020-06-25 16:43:54.335682: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63000 next 20 of size 1024\n2020-06-25 16:43:54.335700: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63400 next 21 of size 256\n2020-06-25 16:43:54.335717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63500 next 22 of size 512\n2020-06-25 16:43:54.335733: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63700 next 23 of size 1024\n2020-06-25 16:43:54.335749: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63b00 next 24 of size 1024\n2020-06-25 16:43:54.335765: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b63f00 next 25 of size 512\n2020-06-25 16:43:54.335781: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64100 next 26 of size 256\n2020-06-25 16:43:54.335796: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64200 next 27 of size 512\n2020-06-25 16:43:54.335826: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64400 next 28 of size 256\n2020-06-25 16:43:54.335845: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64500 next 29 of size 256\n2020-06-25 16:43:54.335861: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64600 next 30 of size 1024\n2020-06-25 16:43:54.335877: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64a00 next 31 of size 512\n2020-06-25 16:43:54.335893: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b64c00 next 32 of size 1024\n2020-06-25 16:43:54.335909: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65000 next 33 of size 1024\n2020-06-25 16:43:54.335925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65400 next 34 of size 256\n2020-06-25 16:43:54.335941: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65500 next 35 of size 256\n2020-06-25 16:43:54.335957: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65600 next 36 of size 1024\n2020-06-25 16:43:54.335973: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65a00 next 37 of size 1024\n2020-06-25 16:43:54.335989: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b65e00 next 38 of size 1024\n2020-06-25 16:43:54.336005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66200 next 39 of size 256\n2020-06-25 16:43:54.336021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66300 next 40 of size 256\n2020-06-25 16:43:54.336037: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66400 next 41 of size 256\n2020-06-25 16:43:54.336052: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66500 next 42 of size 1024\n2020-06-25 16:43:54.336068: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66900 next 43 of size 256\n2020-06-25 16:43:54.336084: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66a00 next 44 of size 512\n2020-06-25 16:43:54.336099: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b66c00 next 45 of size 1024\n2020-06-25 16:43:54.336115: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67000 next 46 of size 1024\n2020-06-25 16:43:54.336131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67400 next 47 of size 256\n2020-06-25 16:43:54.336158: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67500 next 48 of size 256\n2020-06-25 16:43:54.336218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67600 next 49 of size 256\n2020-06-25 16:43:54.336235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67700 next 50 of size 1024\n2020-06-25 16:43:54.336253: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67b00 next 51 of size 1024\n2020-06-25 16:43:54.336271: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b67f00 next 52 of size 1024\n2020-06-25 16:43:54.336288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68300 next 53 of size 2048\n2020-06-25 16:43:54.336305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68b00 next 54 of size 256\n2020-06-25 16:43:54.336322: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68c00 next 55 of size 256\n2020-06-25 16:43:54.336339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b68d00 next 56 of size 1024\n2020-06-25 16:43:54.336357: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69100 next 57 of size 1024\n2020-06-25 16:43:54.336375: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69500 next 58 of size 1024\n2020-06-25 16:43:54.336392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69900 next 59 of size 1024\n2020-06-25 16:43:54.336409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69d00 next 60 of size 256\n2020-06-25 16:43:54.336426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69e00 next 61 of size 256\n2020-06-25 16:43:54.336456: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b69f00 next 62 of size 256\n2020-06-25 16:43:54.336485: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a000 next 63 of size 1024\n2020-06-25 16:43:54.336500: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a400 next 64 of size 1024\n2020-06-25 16:43:54.336516: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6a800 next 65 of size 1024\n2020-06-25 16:43:54.336532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ac00 next 66 of size 256\n2020-06-25 16:43:54.336548: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ad00 next 67 of size 256\n2020-06-25 16:43:54.336563: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ae00 next 68 of size 256\n2020-06-25 16:43:54.336579: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6af00 next 69 of size 1024\n2020-06-25 16:43:54.336595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6b300 next 70 of size 1024\n2020-06-25 16:43:54.336611: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6b700 next 71 of size 1024\n2020-06-25 16:43:54.336627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6bb00 next 72 of size 2048\n2020-06-25 16:43:54.336642: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c300 next 73 of size 512\n2020-06-25 16:43:54.336658: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c500 next 74 of size 256\n2020-06-25 16:43:54.336674: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c600 next 75 of size 256\n2020-06-25 16:43:54.336687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6c700 next 76 of size 1024\n2020-06-25 16:43:54.336703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6cb00 next 77 of size 1024\n2020-06-25 16:43:54.336719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6cf00 next 78 of size 1024\n2020-06-25 16:43:54.336736: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d300 next 79 of size 512\n2020-06-25 16:43:54.336752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d500 next 80 of size 512\n2020-06-25 16:43:54.336769: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d700 next 81 of size 256\n2020-06-25 16:43:54.336784: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d800 next 82 of size 256\n2020-06-25 16:43:54.336800: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6d900 next 83 of size 256\n2020-06-25 16:43:54.336831: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6da00 next 84 of size 1024\n2020-06-25 16:43:54.336867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6de00 next 85 of size 4096\n2020-06-25 16:43:54.336885: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6ee00 next 86 of size 1024\n2020-06-25 16:43:54.336902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f200 next 87 of size 256\n2020-06-25 16:43:54.336918: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f300 next 88 of size 256\n2020-06-25 16:43:54.336933: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f400 next 89 of size 1024\n2020-06-25 16:43:54.336949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f800 next 90 of size 256\n2020-06-25 16:43:54.336965: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6f900 next 91 of size 1024\n2020-06-25 16:43:54.336981: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b6fd00 next 92 of size 1024\n2020-06-25 16:43:54.336996: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70100 next 93 of size 256\n2020-06-25 16:43:54.337012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70200 next 94 of size 1024\n2020-06-25 16:43:54.337028: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70600 next 95 of size 256\n2020-06-25 16:43:54.337044: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70700 next 96 of size 1024\n2020-06-25 16:43:54.337060: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70b00 next 97 of size 1024\n2020-06-25 16:43:54.337075: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b70f00 next 98 of size 256\n2020-06-25 16:43:54.337091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71000 next 99 of size 1024\n2020-06-25 16:43:54.337107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71400 next 100 of size 1024\n2020-06-25 16:43:54.337123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b71800 next 101 of size 8192\n2020-06-25 16:43:54.337139: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73800 next 102 of size 256\n2020-06-25 16:43:54.337155: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73900 next 103 of size 1024\n2020-06-25 16:43:54.337171: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73d00 next 104 of size 256\n2020-06-25 16:43:54.337195: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b73e00 next 105 of size 1024\n2020-06-25 16:43:54.337212: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74200 next 106 of size 1024\n2020-06-25 16:43:54.337228: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74600 next 107 of size 1024\n2020-06-25 16:43:54.337244: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74a00 next 108 of size 256\n2020-06-25 16:43:54.337260: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74b00 next 109 of size 1024\n2020-06-25 16:43:54.337276: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b74f00 next 110 of size 1024\n2020-06-25 16:43:54.337292: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75300 next 111 of size 256\n2020-06-25 16:43:54.337307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75400 next 112 of size 256\n2020-06-25 16:43:54.337323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75500 next 113 of size 1024\n2020-06-25 16:43:54.337339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75900 next 114 of size 1024\n2020-06-25 16:43:54.337355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b75d00 next 115 of size 1024\n2020-06-25 16:43:54.337372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76100 next 116 of size 1024\n2020-06-25 16:43:54.361724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76500 next 117 of size 256\n2020-06-25 16:43:54.361751: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76600 next 118 of size 1024\n2020-06-25 16:43:54.361763: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76a00 next 119 of size 1024\n2020-06-25 16:43:54.361772: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76e00 next 120 of size 256\n2020-06-25 16:43:54.361781: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b76f00 next 121 of size 1024\n2020-06-25 16:43:54.361790: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77300 next 122 of size 1024\n2020-06-25 16:43:54.361798: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77700 next 123 of size 1024\n2020-06-25 16:43:54.361807: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77b00 next 124 of size 256\n2020-06-25 16:43:54.361886: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b77c00 next 125 of size 1024\n2020-06-25 16:43:54.362332: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78000 next 126 of size 256\n2020-06-25 16:43:54.362355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78100 next 127 of size 1024\n2020-06-25 16:43:54.362373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78500 next 128 of size 1024\n2020-06-25 16:43:54.362390: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78900 next 129 of size 512\n2020-06-25 16:43:54.362407: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78b00 next 130 of size 1024\n2020-06-25 16:43:54.362426: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b78f00 next 131 of size 256\n2020-06-25 16:43:54.362448: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79000 next 132 of size 1024\n2020-06-25 16:43:54.362467: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79400 next 133 of size 1024\n2020-06-25 16:43:54.362485: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79800 next 134 of size 256\n2020-06-25 16:43:54.362536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79900 next 135 of size 1024\n2020-06-25 16:43:54.362720: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79d00 next 136 of size 256\n2020-06-25 16:43:54.362752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b79e00 next 137 of size 1024\n2020-06-25 16:43:54.362773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a200 next 138 of size 256\n2020-06-25 16:43:54.362838: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a300 next 139 of size 1024\n2020-06-25 16:43:54.362869: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7a700 next 140 of size 1024\n2020-06-25 16:43:54.362905: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ab00 next 141 of size 1024\n2020-06-25 16:43:54.362954: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7af00 next 142 of size 1024\n2020-06-25 16:43:54.363123: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b300 next 143 of size 256\n2020-06-25 16:43:54.363148: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b400 next 144 of size 256\n2020-06-25 16:43:54.363169: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b500 next 145 of size 1024\n2020-06-25 16:43:54.363236: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7b900 next 146 of size 256\n2020-06-25 16:43:54.363285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ba00 next 147 of size 1024\n2020-06-25 16:43:54.363310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7be00 next 148 of size 1024\n2020-06-25 16:43:54.363517: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7c200 next 149 of size 1024\n2020-06-25 16:43:54.363542: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7c600 next 150 of size 1024\n2020-06-25 16:43:54.363565: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ca00 next 151 of size 1024\n2020-06-25 16:43:54.363599: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ce00 next 152 of size 512\n2020-06-25 16:43:54.363619: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d000 next 153 of size 256\n2020-06-25 16:43:54.363657: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d100 next 154 of size 256\n2020-06-25 16:43:54.363701: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d200 next 155 of size 1024\n2020-06-25 16:43:54.363726: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7d600 next 156 of size 1024\n2020-06-25 16:43:54.363897: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7da00 next 157 of size 1024\n2020-06-25 16:43:54.363938: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7de00 next 158 of size 1024\n2020-06-25 16:43:54.363961: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e200 next 159 of size 1024\n2020-06-25 16:43:54.364002: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e600 next 160 of size 256\n2020-06-25 16:43:54.364039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7e700 next 161 of size 1024\n2020-06-25 16:43:54.364064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7eb00 next 162 of size 256\n2020-06-25 16:43:54.364226: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ec00 next 163 of size 256\n2020-06-25 16:43:54.364262: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ed00 next 164 of size 256\n2020-06-25 16:43:54.364285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7ee00 next 165 of size 512\n2020-06-25 16:43:54.364321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f000 next 166 of size 256\n2020-06-25 16:43:54.364352: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f100 next 167 of size 1024\n2020-06-25 16:43:54.364375: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f500 next 168 of size 256\n2020-06-25 16:43:54.364396: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7f600 next 169 of size 1024\n2020-06-25 16:43:54.364566: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fa00 next 170 of size 256\n2020-06-25 16:43:54.364594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fb00 next 171 of size 256\n2020-06-25 16:43:54.364633: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fc00 next 172 of size 256\n2020-06-25 16:43:54.364658: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b7fd00 next 173 of size 1024\n2020-06-25 16:43:54.364865: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80100 next 174 of size 256\n2020-06-25 16:43:54.364895: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80200 next 175 of size 256\n2020-06-25 16:43:54.364930: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80300 next 176 of size 1024\n2020-06-25 16:43:54.364950: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80700 next 177 of size 256\n2020-06-25 16:43:54.364970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80800 next 178 of size 256\n2020-06-25 16:43:54.365005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80900 next 179 of size 512\n2020-06-25 16:43:54.365029: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80b00 next 180 of size 1024\n2020-06-25 16:43:54.365189: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b80f00 next 181 of size 256\n2020-06-25 16:43:54.365218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81000 next 182 of size 1024\n2020-06-25 16:43:54.365239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81400 next 183 of size 1024\n2020-06-25 16:43:54.365259: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81800 next 184 of size 1024\n2020-06-25 16:43:54.365298: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81c00 next 185 of size 256\n2020-06-25 16:43:54.365322: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81d00 next 186 of size 256\n2020-06-25 16:43:54.365355: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b81e00 next 187 of size 1024\n2020-06-25 16:43:54.365376: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82200 next 188 of size 1024\n2020-06-25 16:43:54.365529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82600 next 189 of size 256\n2020-06-25 16:43:54.365559: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82700 next 190 of size 256\n2020-06-25 16:43:54.365597: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82800 next 191 of size 1024\n2020-06-25 16:43:54.365742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b82c00 next 192 of size 1024\n2020-06-25 16:43:54.365777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83000 next 193 of size 256\n2020-06-25 16:43:54.365799: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83100 next 194 of size 1024\n2020-06-25 16:43:54.365842: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83500 next 195 of size 1024\n2020-06-25 16:43:54.365866: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83900 next 196 of size 1024\n2020-06-25 16:43:54.365898: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83d00 next 197 of size 512\n2020-06-25 16:43:54.365923: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b83f00 next 198 of size 256\n2020-06-25 16:43:54.366075: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84000 next 199 of size 256\n2020-06-25 16:43:54.366113: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84100 next 200 of size 1024\n2020-06-25 16:43:54.366133: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84500 next 201 of size 256\n2020-06-25 16:43:54.366153: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84600 next 202 of size 1024\n2020-06-25 16:43:54.366174: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84a00 next 203 of size 1024\n2020-06-25 16:43:54.366239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b84e00 next 204 of size 1024\n2020-06-25 16:43:54.366389: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85200 next 205 of size 2048\n2020-06-25 16:43:54.366418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85a00 next 206 of size 256\n2020-06-25 16:43:54.366438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85b00 next 207 of size 256\n2020-06-25 16:43:54.366458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b85c00 next 208 of size 1024\n2020-06-25 16:43:54.366477: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86000 next 209 of size 1024\n2020-06-25 16:43:54.366508: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86400 next 210 of size 256\n2020-06-25 16:43:54.366532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86500 next 211 of size 1024\n2020-06-25 16:43:54.366693: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86900 next 212 of size 1024\n2020-06-25 16:43:54.366719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b86d00 next 213 of size 1024\n2020-06-25 16:43:54.366739: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87100 next 214 of size 256\n2020-06-25 16:43:54.366758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87200 next 215 of size 1024\n2020-06-25 16:43:54.366777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87600 next 216 of size 1024\n2020-06-25 16:43:54.366827: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87a00 next 217 of size 256\n2020-06-25 16:43:54.366858: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87b00 next 218 of size 256\n2020-06-25 16:43:54.367003: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b87c00 next 219 of size 1024\n2020-06-25 16:43:54.367030: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88000 next 220 of size 1024\n2020-06-25 16:43:54.367051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88400 next 221 of size 1024\n2020-06-25 16:43:54.367071: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88800 next 222 of size 256\n2020-06-25 16:43:54.367102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88900 next 223 of size 256\n2020-06-25 16:43:54.367141: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88a00 next 224 of size 256\n2020-06-25 16:43:54.367210: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88b00 next 225 of size 1024\n2020-06-25 16:43:54.367239: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b88f00 next 226 of size 256\n2020-06-25 16:43:54.367459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89000 next 227 of size 256\n2020-06-25 16:43:54.367484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89100 next 228 of size 1024\n2020-06-25 16:43:54.367506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89500 next 229 of size 256\n2020-06-25 16:43:54.367554: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89600 next 230 of size 256\n2020-06-25 16:43:54.367589: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89700 next 231 of size 512\n2020-06-25 16:43:54.367614: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89900 next 232 of size 512\n2020-06-25 16:43:54.367771: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89b00 next 233 of size 256\n2020-06-25 16:43:54.367806: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b89c00 next 234 of size 1024\n2020-06-25 16:43:54.367853: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a000 next 235 of size 512\n2020-06-25 16:43:54.367891: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a200 next 236 of size 512\n2020-06-25 16:43:54.367925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a400 next 237 of size 256\n2020-06-25 16:43:54.367949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8a500 next 238 of size 2048\n2020-06-25 16:43:54.368090: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ad00 next 239 of size 256\n2020-06-25 16:43:54.368125: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ae00 next 240 of size 4096\n2020-06-25 16:43:54.368147: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8be00 next 241 of size 1024\n2020-06-25 16:43:54.368196: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c200 next 242 of size 256\n2020-06-25 16:43:54.368348: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c300 next 243 of size 256\n2020-06-25 16:43:54.368373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c400 next 244 of size 256\n2020-06-25 16:43:54.368393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c500 next 245 of size 256\n2020-06-25 16:43:54.368413: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8c600 next 246 of size 2048\n2020-06-25 16:43:54.368432: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8ce00 next 247 of size 256\n2020-06-25 16:43:54.368470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8cf00 next 248 of size 1024\n2020-06-25 16:43:54.368504: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8d300 next 249 of size 8192\n2020-06-25 16:43:54.368528: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f300 next 250 of size 256\n2020-06-25 16:43:54.368680: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f400 next 251 of size 256\n2020-06-25 16:43:54.368713: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f500 next 252 of size 256\n2020-06-25 16:43:54.368737: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f600 next 253 of size 256\n2020-06-25 16:43:54.368767: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8f700 next 254 of size 1024\n2020-06-25 16:43:54.368792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b8fb00 next 255 of size 2048\n2020-06-25 16:43:54.368960: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90300 next 256 of size 256\n2020-06-25 16:43:54.368985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90400 next 257 of size 1024\n2020-06-25 16:43:54.369005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90800 next 258 of size 256\n2020-06-25 16:43:54.369024: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90900 next 259 of size 256\n2020-06-25 16:43:54.369044: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90a00 next 260 of size 1024\n2020-06-25 16:43:54.369081: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90e00 next 261 of size 256\n2020-06-25 16:43:54.369115: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b90f00 next 262 of size 256\n2020-06-25 16:43:54.369138: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91000 next 263 of size 1024\n2020-06-25 16:43:54.369289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91400 next 264 of size 256\n2020-06-25 16:43:54.369323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91500 next 265 of size 256\n2020-06-25 16:43:54.369358: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91600 next 266 of size 1024\n2020-06-25 16:43:54.369395: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91a00 next 267 of size 256\n2020-06-25 16:43:54.369439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91b00 next 268 of size 256\n2020-06-25 16:43:54.369462: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91c00 next 269 of size 256\n2020-06-25 16:43:54.369482: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91d00 next 270 of size 512\n2020-06-25 16:43:54.369647: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b91f00 next 271 of size 256\n2020-06-25 16:43:54.369691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92000 next 272 of size 512\n2020-06-25 16:43:54.369713: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92200 next 273 of size 256\n2020-06-25 16:43:54.369760: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92300 next 274 of size 1024\n2020-06-25 16:43:54.369784: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92700 next 275 of size 256\n2020-06-25 16:43:54.369837: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92800 next 276 of size 1024\n2020-06-25 16:43:54.370003: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b92c00 next 277 of size 1024\n2020-06-25 16:43:54.370038: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93000 next 278 of size 1024\n2020-06-25 16:43:54.370086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93400 next 279 of size 1024\n2020-06-25 16:43:54.370119: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93800 next 280 of size 1024\n2020-06-25 16:43:54.370156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b93c00 next 281 of size 1024\n2020-06-25 16:43:54.370333: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94000 next 282 of size 1024\n2020-06-25 16:43:54.370360: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94400 next 283 of size 1024\n2020-06-25 16:43:54.370394: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94800 next 284 of size 1024\n2020-06-25 16:43:54.370415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94c00 next 285 of size 256\n2020-06-25 16:43:54.370435: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94d00 next 286 of size 256\n2020-06-25 16:43:54.370483: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94e00 next 287 of size 256\n2020-06-25 16:43:54.370518: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b94f00 next 288 of size 1024\n2020-06-25 16:43:54.370543: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95300 next 289 of size 256\n2020-06-25 16:43:54.370683: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95400 next 290 of size 1024\n2020-06-25 16:43:54.370718: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95800 next 291 of size 256\n2020-06-25 16:43:54.370740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95900 next 292 of size 1024\n2020-06-25 16:43:54.370779: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b95d00 next 293 of size 1024\n2020-06-25 16:43:54.370829: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96100 next 294 of size 1024\n2020-06-25 16:43:54.370860: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96500 next 295 of size 1024\n2020-06-25 16:43:54.371013: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96900 next 296 of size 256\n2020-06-25 16:43:54.371048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b96a00 next 298 of size 32768\n2020-06-25 16:43:54.371082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703b9ea00 next 299 of size 37632\n2020-06-25 16:43:54.371116: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703ba7d00 next 301 of size 294912\n2020-06-25 16:43:54.371152: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703befd00 next 302 of size 12288\n2020-06-25 16:43:54.371190: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703bf2d00 next 18446744073709551615 of size 447232\n2020-06-25 16:43:54.371354: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4194304\n2020-06-25 16:43:54.371381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x703c60000 next 18446744073709551615 of size 4194304\n2020-06-25 16:43:54.371431: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4194304\n2020-06-25 16:43:54.371476: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704060000 next 18446744073709551615 of size 4194304\n2020-06-25 16:43:54.371505: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 8388608\n2020-06-25 16:43:54.371659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704460000 next 304 of size 1179648\n2020-06-25 16:43:54.371693: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704580000 next 305 of size 1179648\n2020-06-25 16:43:54.371717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7046a0000 next 306 of size 2359296\n2020-06-25 16:43:54.371757: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7048e0000 next 307 of size 524288\n2020-06-25 16:43:54.371792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704960000 next 18446744073709551615 of size 3145728\n2020-06-25 16:43:54.371837: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 16777216\n2020-06-25 16:43:54.371982: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704c60000 next 309 of size 2097152\n2020-06-25 16:43:54.372017: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x704e60000 next 310 of size 2359296\n2020-06-25 16:43:54.372041: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7050a0000 next 312 of size 2097152\n2020-06-25 16:43:54.372077: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7052a0000 next 313 of size 2359296\n2020-06-25 16:43:54.372108: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7054e0000 next 314 of size 37632\n2020-06-25 16:43:54.372131: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7054e9300 next 315 of size 2359296\n2020-06-25 16:43:54.372158: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705729300 next 316 of size 37632\n2020-06-25 16:43:54.372319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705732600 next 319 of size 2359296\n2020-06-25 16:43:54.372344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705972600 next 18446744073709551615 of size 3070464\n2020-06-25 16:43:54.372381: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 33554432\n2020-06-25 16:43:54.372418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x705c60000 next 18446744073709551615 of size 33554432\n2020-06-25 16:43:54.372443: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 67108864\n2020-06-25 16:43:54.372587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x707c60000 next 318 of size 8388608\n2020-06-25 16:43:54.372621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x708460000 next 320 of size 32768\n2020-06-25 16:43:54.372646: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x708468000 next 321 of size 294912\n2020-06-25 16:43:54.372683: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7084b0000 next 322 of size 2359296\n2020-06-25 16:43:54.372837: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7086f0000 next 18446744073709551615 of size 56033280\n2020-06-25 16:43:54.372873: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 134217728\n2020-06-25 16:43:54.372896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70bc60000 next 324 of size 1179648\n2020-06-25 16:43:54.372917: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70bd80000 next 325 of size 524288\n2020-06-25 16:43:54.372939: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70be00000 next 329 of size 262144\n2020-06-25 16:43:54.372974: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70be40000 next 330 of size 2359296\n2020-06-25 16:43:54.373008: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c080000 next 331 of size 262144\n2020-06-25 16:43:54.373032: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c0c0000 next 332 of size 262144\n2020-06-25 16:43:54.373186: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c100000 next 333 of size 12288\n2020-06-25 16:43:54.373223: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c103000 next 334 of size 2359296\n2020-06-25 16:43:54.373261: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c343000 next 335 of size 8192\n2020-06-25 16:43:54.373400: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c345000 next 336 of size 2359296\n2020-06-25 16:43:54.373439: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c585000 next 337 of size 2359296\n2020-06-25 16:43:54.373464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70c7c5000 next 338 of size 2359296\n2020-06-25 16:43:54.373484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ca05000 next 339 of size 2359296\n2020-06-25 16:43:54.373504: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70cc45000 next 340 of size 524288\n2020-06-25 16:43:54.373524: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ccc5000 next 341 of size 2359296\n2020-06-25 16:43:54.373560: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70cf05000 next 342 of size 33554432\n2020-06-25 16:43:54.373594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef05000 next 343 of size 8192\n2020-06-25 16:43:54.373618: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef07000 next 344 of size 8192\n2020-06-25 16:43:54.373765: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ef09000 next 345 of size 2359296\n2020-06-25 16:43:54.373801: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f149000 next 346 of size 131072\n2020-06-25 16:43:54.373859: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f169000 next 347 of size 2359296\n2020-06-25 16:43:54.373888: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f3a9000 next 348 of size 2359296\n2020-06-25 16:43:54.374038: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f5e9000 next 349 of size 12288\n2020-06-25 16:43:54.374067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f5ec000 next 350 of size 2359296\n2020-06-25 16:43:54.374088: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70f82c000 next 351 of size 2359296\n2020-06-25 16:43:54.374107: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fa6c000 next 352 of size 2097152\n2020-06-25 16:43:54.374127: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fc6c000 next 353 of size 524288\n2020-06-25 16:43:54.374167: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70fcec000 next 354 of size 2359296\n2020-06-25 16:43:54.374218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x70ff2c000 next 355 of size 2359296\n2020-06-25 16:43:54.374392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71016c000 next 356 of size 2097152\n2020-06-25 16:43:54.374430: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71036c000 next 357 of size 8388608\n2020-06-25 16:43:54.374454: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x710b6c000 next 358 of size 8388608\n2020-06-25 16:43:54.374489: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71136c000 next 359 of size 524288\n2020-06-25 16:43:54.374525: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7113ec000 next 361 of size 12288\n2020-06-25 16:43:54.374549: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7113ef000 next 362 of size 262144\n2020-06-25 16:43:54.374703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71142f000 next 363 of size 262144\n2020-06-25 16:43:54.374736: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71146f000 next 364 of size 262144\n2020-06-25 16:43:54.374759: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7114af000 next 365 of size 2359296\n2020-06-25 16:43:54.374793: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7116ef000 next 366 of size 524288\n2020-06-25 16:43:54.374944: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71176f000 next 367 of size 2359296\n2020-06-25 16:43:54.374979: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7119af000 next 368 of size 2359296\n2020-06-25 16:43:54.375000: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x711bef000 next 369 of size 2359296\n2020-06-25 16:43:54.375020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x711e2f000 next 370 of size 2359296\n2020-06-25 16:43:54.375039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71206f000 next 371 of size 2097152\n2020-06-25 16:43:54.375067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71226f000 next 372 of size 2359296\n2020-06-25 16:43:54.375091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7124af000 next 373 of size 2359296\n2020-06-25 16:43:54.375278: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7126ef000 next 374 of size 2359296\n2020-06-25 16:43:54.375323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71292f000 next 375 of size 8388608\n2020-06-25 16:43:54.375345: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71312f000 next 376 of size 1179648\n2020-06-25 16:43:54.375364: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71324f000 next 378 of size 294912\n2020-06-25 16:43:54.375383: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713297000 next 381 of size 37632\n2020-06-25 16:43:54.375415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7132a0300 next 382 of size 8192\n2020-06-25 16:43:54.375450: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7132a2300 next 383 of size 2097152\n2020-06-25 16:43:54.375483: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134a2300 next 384 of size 131072\n2020-06-25 16:43:54.375508: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134c2300 next 385 of size 1280\n2020-06-25 16:43:54.375649: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7134c2800 next 386 of size 2359296\n2020-06-25 16:43:54.375684: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713702800 next 387 of size 2359296\n2020-06-25 16:43:54.375707: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713942800 next 18446744073709551615 of size 3266560\n2020-06-25 16:43:54.375749: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 268435456\n2020-06-25 16:43:54.375775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x713c60000 next 327 of size 134217728\n2020-06-25 16:43:54.375952: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71bc60000 next 377 of size 33554432\n2020-06-25 16:43:54.375979: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dc60000 next 388 of size 2359296\n2020-06-25 16:43:54.376001: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0000 next 389 of size 1024\n2020-06-25 16:43:54.376021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0400 next 390 of size 1024\n2020-06-25 16:43:54.376051: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0800 next 391 of size 1024\n2020-06-25 16:43:54.376077: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0c00 next 392 of size 256\n2020-06-25 16:43:54.376250: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71dea0d00 next 393 of size 524288\n2020-06-25 16:43:54.376279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71df20d00 next 394 of size 33554432\n2020-06-25 16:43:54.376300: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff20d00 next 395 of size 1024\n2020-06-25 16:43:54.376320: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21100 next 396 of size 512\n2020-06-25 16:43:54.376340: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21300 next 397 of size 1024\n2020-06-25 16:43:54.376371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff21700 next 398 of size 131072\n2020-06-25 16:43:54.376394: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41700 next 399 of size 1024\n2020-06-25 16:43:54.376544: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41b00 next 400 of size 1024\n2020-06-25 16:43:54.376569: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff41f00 next 401 of size 1024\n2020-06-25 16:43:54.376590: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42300 next 402 of size 1024\n2020-06-25 16:43:54.376609: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42700 next 403 of size 1024\n2020-06-25 16:43:54.376631: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x71ff42b00 next 404 of size 2359296\n2020-06-25 16:43:54.376669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720182b00 next 405 of size 1024\n2020-06-25 16:43:54.376691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720182f00 next 406 of size 1024\n2020-06-25 16:43:54.376864: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720183300 next 407 of size 512\n2020-06-25 16:43:54.376901: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720183500 next 408 of size 2359296\n2020-06-25 16:43:54.376934: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3500 next 409 of size 1024\n2020-06-25 16:43:54.376955: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3900 next 410 of size 1024\n2020-06-25 16:43:54.376986: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c3d00 next 411 of size 1024\n2020-06-25 16:43:54.377023: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4100 next 412 of size 1024\n2020-06-25 16:43:54.377048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4500 next 413 of size 256\n2020-06-25 16:43:54.377282: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4600 next 414 of size 1024\n2020-06-25 16:43:54.377306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4a00 next 415 of size 1024\n2020-06-25 16:43:54.377327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4e00 next 416 of size 256\n2020-06-25 16:43:54.377347: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c4f00 next 417 of size 1024\n2020-06-25 16:43:54.377376: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5300 next 418 of size 512\n2020-06-25 16:43:54.377401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5500 next 419 of size 1024\n2020-06-25 16:43:54.377592: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5900 next 420 of size 1024\n2020-06-25 16:43:54.377620: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7203c5d00 next 421 of size 2359296\n2020-06-25 16:43:54.377654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720605d00 next 422 of size 1024\n2020-06-25 16:43:54.377687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720606100 next 423 of size 2359296\n2020-06-25 16:43:54.377706: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720846100 next 424 of size 1024\n2020-06-25 16:43:54.377725: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720846500 next 425 of size 2359296\n2020-06-25 16:43:54.377761: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a86500 next 426 of size 1024\n2020-06-25 16:43:54.377786: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a86900 next 427 of size 12288\n2020-06-25 16:43:54.377837: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89900 next 428 of size 1024\n2020-06-25 16:43:54.377864: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89d00 next 429 of size 256\n2020-06-25 16:43:54.378015: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a89e00 next 430 of size 1024\n2020-06-25 16:43:54.378040: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8a200 next 431 of size 1024\n2020-06-25 16:43:54.378070: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8a600 next 432 of size 1024\n2020-06-25 16:43:54.378095: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8aa00 next 433 of size 1024\n2020-06-25 16:43:54.378285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8ae00 next 434 of size 512\n2020-06-25 16:43:54.378315: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b000 next 435 of size 1024\n2020-06-25 16:43:54.378337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b400 next 436 of size 1024\n2020-06-25 16:43:54.378371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720a8b800 next 437 of size 2097152\n2020-06-25 16:43:54.378391: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8b800 next 438 of size 1024\n2020-06-25 16:43:54.378411: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8bc00 next 439 of size 1024\n2020-06-25 16:43:54.378458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720c8c000 next 440 of size 2097152\n2020-06-25 16:43:54.378522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720e8c000 next 441 of size 1024\n2020-06-25 16:43:54.378547: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720e8c400 next 442 of size 524288\n2020-06-25 16:43:54.378717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0c400 next 443 of size 1024\n2020-06-25 16:43:54.378751: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0c800 next 444 of size 1024\n2020-06-25 16:43:54.378774: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0cc00 next 445 of size 1024\n2020-06-25 16:43:54.378826: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d000 next 446 of size 1024\n2020-06-25 16:43:54.378865: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d400 next 447 of size 1024\n2020-06-25 16:43:54.378891: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0d800 next 448 of size 1024\n2020-06-25 16:43:54.379032: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0dc00 next 449 of size 1024\n2020-06-25 16:43:54.379067: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e000 next 450 of size 1024\n2020-06-25 16:43:54.379091: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e400 next 451 of size 1024\n2020-06-25 16:43:54.379126: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e800 next 452 of size 256\n2020-06-25 16:43:54.379158: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0e900 next 453 of size 256\n2020-06-25 16:43:54.379209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0ea00 next 454 of size 256\n2020-06-25 16:43:54.379393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0eb00 next 455 of size 2048\n2020-06-25 16:43:54.379436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f300 next 456 of size 512\n2020-06-25 16:43:54.379476: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f500 next 457 of size 1024\n2020-06-25 16:43:54.379631: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0f900 next 458 of size 1024\n2020-06-25 16:43:54.379668: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f0fd00 next 459 of size 1024\n2020-06-25 16:43:54.379691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10100 next 460 of size 1024\n2020-06-25 16:43:54.379712: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10500 next 461 of size 1024\n2020-06-25 16:43:54.379732: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10900 next 462 of size 1024\n2020-06-25 16:43:54.379753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10d00 next 463 of size 256\n2020-06-25 16:43:54.379793: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x720f10e00 next 464 of size 8388608\n2020-06-25 16:43:54.379956: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721710e00 next 465 of size 1024\n2020-06-25 16:43:54.379993: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721711200 next 466 of size 8388608\n2020-06-25 16:43:54.380017: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f11200 next 468 of size 2048\n2020-06-25 16:43:54.380039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f11a00 next 469 of size 524288\n2020-06-25 16:43:54.380060: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721f91a00 next 470 of size 262144\n2020-06-25 16:43:54.380096: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721fd1a00 next 471 of size 256\n2020-06-25 16:43:54.380251: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x721fd1b00 next 472 of size 262144\n2020-06-25 16:43:54.380288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722011b00 next 473 of size 1024\n2020-06-25 16:43:54.380312: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722011f00 next 474 of size 1024\n2020-06-25 16:43:54.380332: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722012300 next 475 of size 12288\n2020-06-25 16:43:54.380352: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722015300 next 476 of size 256\n2020-06-25 16:43:54.380390: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722015400 next 477 of size 262144\n2020-06-25 16:43:54.380416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055400 next 478 of size 1024\n2020-06-25 16:43:54.380574: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055800 next 479 of size 1024\n2020-06-25 16:43:54.380599: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722055c00 next 480 of size 1024\n2020-06-25 16:43:54.380621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056000 next 481 of size 1024\n2020-06-25 16:43:54.380640: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056400 next 482 of size 1024\n2020-06-25 16:43:54.380671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056800 next 483 of size 1024\n2020-06-25 16:43:54.380696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722056c00 next 484 of size 524288\n2020-06-25 16:43:54.380724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d6c00 next 485 of size 1024\n2020-06-25 16:43:54.380747: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7000 next 486 of size 1024\n2020-06-25 16:43:54.380775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7400 next 487 of size 256\n2020-06-25 16:43:54.380957: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7500 next 488 of size 1024\n2020-06-25 16:43:54.380982: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7900 next 489 of size 256\n2020-06-25 16:43:54.381019: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7a00 next 490 of size 256\n2020-06-25 16:43:54.381057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7220d7b00 next 491 of size 2359296\n2020-06-25 16:43:54.381082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722317b00 next 492 of size 1024\n2020-06-25 16:43:54.381245: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722317f00 next 493 of size 1024\n2020-06-25 16:43:54.381279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318300 next 494 of size 512\n2020-06-25 16:43:54.381302: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318500 next 495 of size 1024\n2020-06-25 16:43:54.381337: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722318900 next 496 of size 2048\n2020-06-25 16:43:54.381373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722319100 next 497 of size 2359296\n2020-06-25 16:43:54.381399: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559100 next 498 of size 256\n2020-06-25 16:43:54.381566: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559200 next 499 of size 512\n2020-06-25 16:43:54.381601: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559400 next 500 of size 512\n2020-06-25 16:43:54.381626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722559600 next 501 of size 524288\n2020-06-25 16:43:54.381663: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9600 next 502 of size 1024\n2020-06-25 16:43:54.381702: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9a00 next 503 of size 1024\n2020-06-25 16:43:54.381727: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225d9e00 next 504 of size 512\n2020-06-25 16:43:54.381889: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da000 next 505 of size 256\n2020-06-25 16:43:54.381925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da100 next 506 of size 1024\n2020-06-25 16:43:54.381950: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da500 next 507 of size 256\n2020-06-25 16:43:54.381986: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da600 next 508 of size 512\n2020-06-25 16:43:54.382020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7225da800 next 509 of size 2359296\n2020-06-25 16:43:54.382044: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281a800 next 510 of size 2048\n2020-06-25 16:43:54.382200: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b000 next 511 of size 1024\n2020-06-25 16:43:54.382235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b400 next 512 of size 1024\n2020-06-25 16:43:54.382270: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281b800 next 513 of size 12288\n2020-06-25 16:43:54.382308: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72281e800 next 514 of size 1179648\n2020-06-25 16:43:54.382466: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293e800 next 515 of size 512\n2020-06-25 16:43:54.382504: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ea00 next 516 of size 512\n2020-06-25 16:43:54.382526: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ec00 next 517 of size 512\n2020-06-25 16:43:54.382545: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293ee00 next 518 of size 1024\n2020-06-25 16:43:54.382565: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f200 next 519 of size 512\n2020-06-25 16:43:54.382595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f400 next 520 of size 1024\n2020-06-25 16:43:54.382633: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293f800 next 521 of size 1024\n2020-06-25 16:43:54.382783: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72293fc00 next 522 of size 294912\n2020-06-25 16:43:54.382825: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722987c00 next 523 of size 512\n2020-06-25 16:43:54.382856: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722987e00 next 524 of size 512\n2020-06-25 16:43:54.382878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988000 next 525 of size 1024\n2020-06-25 16:43:54.382917: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988400 next 526 of size 2048\n2020-06-25 16:43:54.383059: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722988c00 next 527 of size 2048\n2020-06-25 16:43:54.383094: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989400 next 528 of size 256\n2020-06-25 16:43:54.383117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989500 next 529 of size 512\n2020-06-25 16:43:54.383137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989700 next 530 of size 512\n2020-06-25 16:43:54.383156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989900 next 531 of size 256\n2020-06-25 16:43:54.383203: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989a00 next 532 of size 512\n2020-06-25 16:43:54.383359: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989c00 next 533 of size 256\n2020-06-25 16:43:54.383388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722989d00 next 534 of size 37632\n2020-06-25 16:43:54.383409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722993000 next 535 of size 1024\n2020-06-25 16:43:54.383429: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722993400 next 536 of size 2359296\n2020-06-25 16:43:54.383449: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3400 next 537 of size 1024\n2020-06-25 16:43:54.383487: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3800 next 538 of size 512\n2020-06-25 16:43:54.383522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3a00 next 539 of size 512\n2020-06-25 16:43:54.383547: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3c00 next 540 of size 256\n2020-06-25 16:43:54.383691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3d00 next 541 of size 256\n2020-06-25 16:43:54.383725: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722bd3e00 next 542 of size 2097152\n2020-06-25 16:43:54.383748: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd3e00 next 543 of size 1024\n2020-06-25 16:43:54.383789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4200 next 544 of size 256\n2020-06-25 16:43:54.383838: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4300 next 545 of size 256\n2020-06-25 16:43:54.383867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x722dd4400 next 546 of size 2359296\n2020-06-25 16:43:54.384011: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014400 next 547 of size 256\n2020-06-25 16:43:54.384045: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014500 next 548 of size 256\n2020-06-25 16:43:54.384068: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723014600 next 549 of size 8192\n2020-06-25 16:43:54.384108: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016600 next 550 of size 1024\n2020-06-25 16:43:54.384141: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016a00 next 551 of size 256\n2020-06-25 16:43:54.384165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016b00 next 552 of size 1024\n2020-06-25 16:43:54.384327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723016f00 next 553 of size 1024\n2020-06-25 16:43:54.384364: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017300 next 554 of size 1024\n2020-06-25 16:43:54.384401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017700 next 555 of size 2048\n2020-06-25 16:43:54.384540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723017f00 next 556 of size 1024\n2020-06-25 16:43:54.384581: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723018300 next 557 of size 1024\n2020-06-25 16:43:54.384617: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723018700 next 558 of size 2359296\n2020-06-25 16:43:54.384637: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723258700 next 559 of size 2359296\n2020-06-25 16:43:54.384656: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498700 next 560 of size 1024\n2020-06-25 16:43:54.384686: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498b00 next 561 of size 256\n2020-06-25 16:43:54.384710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723498c00 next 562 of size 2359296\n2020-06-25 16:43:54.384742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d8c00 next 563 of size 1024\n2020-06-25 16:43:54.384766: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9000 next 564 of size 1024\n2020-06-25 16:43:54.384953: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9400 next 565 of size 1024\n2020-06-25 16:43:54.384987: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9800 next 566 of size 1024\n2020-06-25 16:43:54.385020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236d9c00 next 567 of size 1024\n2020-06-25 16:43:54.385045: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da000 next 568 of size 1024\n2020-06-25 16:43:54.385203: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da400 next 569 of size 1024\n2020-06-25 16:43:54.385231: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236da800 next 570 of size 1024\n2020-06-25 16:43:54.385252: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7236dac00 next 571 of size 2359296\n2020-06-25 16:43:54.385271: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ac00 next 572 of size 512\n2020-06-25 16:43:54.385303: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ae00 next 573 of size 256\n2020-06-25 16:43:54.385327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391af00 next 574 of size 1024\n2020-06-25 16:43:54.385474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391b300 next 575 of size 1024\n2020-06-25 16:43:54.385499: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391b700 next 576 of size 1024\n2020-06-25 16:43:54.385520: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391bb00 next 577 of size 1024\n2020-06-25 16:43:54.385539: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391bf00 next 578 of size 2048\n2020-06-25 16:43:54.385558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391c700 next 579 of size 1024\n2020-06-25 16:43:54.385596: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391cb00 next 580 of size 1024\n2020-06-25 16:43:54.385629: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391cf00 next 581 of size 1024\n2020-06-25 16:43:54.385654: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391d300 next 582 of size 1024\n2020-06-25 16:43:54.385687: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391d700 next 583 of size 1024\n2020-06-25 16:43:54.385850: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391db00 next 584 of size 2048\n2020-06-25 16:43:54.385878: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391e300 next 585 of size 2048\n2020-06-25 16:43:54.385954: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391eb00 next 586 of size 1024\n2020-06-25 16:43:54.386000: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391ef00 next 587 of size 1024\n2020-06-25 16:43:54.386026: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391f300 next 588 of size 2048\n2020-06-25 16:43:54.386207: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391fb00 next 589 of size 512\n2020-06-25 16:43:54.386267: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x72391fd00 next 590 of size 1024\n2020-06-25 16:43:54.386319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920100 next 591 of size 1024\n2020-06-25 16:43:54.386486: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920500 next 592 of size 1024\n2020-06-25 16:43:54.386533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920900 next 593 of size 1024\n2020-06-25 16:43:54.386555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723920d00 next 594 of size 1024\n2020-06-25 16:43:54.386575: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921100 next 595 of size 1024\n2020-06-25 16:43:54.386595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921500 next 596 of size 512\n2020-06-25 16:43:54.386631: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921700 next 597 of size 1024\n2020-06-25 16:43:54.386773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723921b00 next 18446744073709551615 of size 3400960\n2020-06-25 16:43:54.386807: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1073741824\n2020-06-25 16:43:54.386856: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x723c60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:54.386880: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 1073741824\n2020-06-25 16:43:54.386902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x763c60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:54.386937: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2147483648\n2020-06-25 16:43:54.386970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7a3c60000 next 380 of size 134217728\n2020-06-25 16:43:54.386994: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7abc60000 next 467 of size 1073741824\n2020-06-25 16:43:54.387132: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60000 next 598 of size 1024\n2020-06-25 16:43:54.387165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60400 next 599 of size 1024\n2020-06-25 16:43:54.387218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60800 next 600 of size 1024\n2020-06-25 16:43:54.387258: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc60c00 next 601 of size 1024\n2020-06-25 16:43:54.387283: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebc61000 next 602 of size 2359296\n2020-06-25 16:43:54.387480: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ebea1000 next 603 of size 2359296\n2020-06-25 16:43:54.387517: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec0e1000 next 604 of size 8388608\n2020-06-25 16:43:54.387541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec8e1000 next 605 of size 1024\n2020-06-25 16:43:54.387578: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ec8e1400 next 606 of size 33554432\n2020-06-25 16:43:54.387613: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e1400 next 607 of size 4096\n2020-06-25 16:43:54.387652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2400 next 608 of size 512\n2020-06-25 16:43:54.387693: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2600 next 609 of size 1024\n2020-06-25 16:43:54.387880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2a00 next 610 of size 1024\n2020-06-25 16:43:54.387910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e2e00 next 611 of size 1024\n2020-06-25 16:43:54.387949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3200 next 612 of size 1024\n2020-06-25 16:43:54.388005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3600 next 613 of size 512\n2020-06-25 16:43:54.388028: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3800 next 614 of size 512\n2020-06-25 16:43:54.388055: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee8e3a00 next 615 of size 294912\n2020-06-25 16:43:54.388217: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92ba00 next 616 of size 1024\n2020-06-25 16:43:54.388252: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92be00 next 617 of size 1024\n2020-06-25 16:43:54.388277: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee92c200 next 618 of size 32768\n2020-06-25 16:43:54.388427: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee934200 next 619 of size 1024\n2020-06-25 16:43:54.388454: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee934600 next 620 of size 4096\n2020-06-25 16:43:54.388475: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935600 next 621 of size 1024\n2020-06-25 16:43:54.388496: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935a00 next 622 of size 1024\n2020-06-25 16:43:54.388517: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee935e00 next 623 of size 1024\n2020-06-25 16:43:54.388552: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936200 next 624 of size 1024\n2020-06-25 16:43:54.388585: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936600 next 625 of size 1024\n2020-06-25 16:43:54.388610: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7ee936a00 next 626 of size 33554432\n2020-06-25 16:43:54.388851: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0936a00 next 627 of size 1024\n2020-06-25 16:43:54.388887: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0936e00 next 628 of size 512\n2020-06-25 16:43:54.388910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937000 next 629 of size 512\n2020-06-25 16:43:54.388948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937200 next 630 of size 512\n2020-06-25 16:43:54.388984: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937400 next 631 of size 1024\n2020-06-25 16:43:54.389008: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0937800 next 632 of size 2097152\n2020-06-25 16:43:54.389151: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b37800 next 633 of size 1024\n2020-06-25 16:43:54.389198: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b37c00 next 634 of size 1024\n2020-06-25 16:43:54.389242: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38000 next 635 of size 2048\n2020-06-25 16:43:54.389383: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38800 next 636 of size 1024\n2020-06-25 16:43:54.389418: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0b38c00 next 637 of size 2359296\n2020-06-25 16:43:54.389442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d78c00 next 638 of size 1024\n2020-06-25 16:43:54.389462: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79000 next 639 of size 1024\n2020-06-25 16:43:54.389481: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79400 next 640 of size 1024\n2020-06-25 16:43:54.389511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79800 next 641 of size 1024\n2020-06-25 16:43:54.389536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79c00 next 642 of size 512\n2020-06-25 16:43:54.389570: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d79e00 next 643 of size 512\n2020-06-25 16:43:54.389607: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d7a000 next 644 of size 2048\n2020-06-25 16:43:54.389752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d7a800 next 645 of size 131072\n2020-06-25 16:43:54.389788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0d9a800 next 646 of size 2359296\n2020-06-25 16:43:54.389956: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0fda800 next 647 of size 512\n2020-06-25 16:43:54.389994: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f0fdaa00 next 648 of size 2359296\n2020-06-25 16:43:54.390017: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f121aa00 next 649 of size 1024\n2020-06-25 16:43:54.390038: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f121ae00 next 650 of size 2359296\n2020-06-25 16:43:54.390059: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f145ae00 next 651 of size 1024\n2020-06-25 16:43:54.390078: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f145b200 next 652 of size 33554432\n2020-06-25 16:43:54.390097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f345b200 next 653 of size 1179648\n2020-06-25 16:43:54.390137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357b200 next 654 of size 1024\n2020-06-25 16:43:54.390291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357b600 next 655 of size 1024\n2020-06-25 16:43:54.390326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357ba00 next 656 of size 1024\n2020-06-25 16:43:54.390350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357be00 next 657 of size 1024\n2020-06-25 16:43:54.390370: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f357c200 next 658 of size 32768\n2020-06-25 16:43:54.390389: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584200 next 659 of size 256\n2020-06-25 16:43:54.390419: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584300 next 660 of size 512\n2020-06-25 16:43:54.390445: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584500 next 661 of size 512\n2020-06-25 16:43:54.390609: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584700 next 662 of size 512\n2020-06-25 16:43:54.390638: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3584900 next 663 of size 524288\n2020-06-25 16:43:54.390658: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3604900 next 664 of size 8192\n2020-06-25 16:43:54.390678: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3606900 next 665 of size 1024\n2020-06-25 16:43:54.390698: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3606d00 next 666 of size 2097152\n2020-06-25 16:43:54.390729: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3806d00 next 667 of size 256\n2020-06-25 16:43:54.390753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3806e00 next 668 of size 1024\n2020-06-25 16:43:54.390922: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3807200 next 669 of size 256\n2020-06-25 16:43:54.390949: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3807300 next 670 of size 37632\n2020-06-25 16:43:54.390969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810600 next 671 of size 1024\n2020-06-25 16:43:54.390989: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810a00 next 672 of size 1024\n2020-06-25 16:43:54.391010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3810e00 next 673 of size 1024\n2020-06-25 16:43:54.391046: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811200 next 674 of size 256\n2020-06-25 16:43:54.391080: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811300 next 675 of size 512\n2020-06-25 16:43:54.391105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811500 next 676 of size 256\n2020-06-25 16:43:54.391257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3811600 next 679 of size 262144\n2020-06-25 16:43:54.391291: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3851600 next 680 of size 2359296\n2020-06-25 16:43:54.391314: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91600 next 681 of size 256\n2020-06-25 16:43:54.391350: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91700 next 682 of size 256\n2020-06-25 16:43:54.391383: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91800 next 683 of size 256\n2020-06-25 16:43:54.391408: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91900 next 684 of size 1024\n2020-06-25 16:43:54.391596: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91d00 next 685 of size 256\n2020-06-25 16:43:54.391633: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3a91e00 next 686 of size 2359296\n2020-06-25 16:43:54.391671: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3cd1e00 next 687 of size 1024\n2020-06-25 16:43:54.391726: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3cd2200 next 688 of size 2359296\n2020-06-25 16:43:54.391762: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12200 next 689 of size 1024\n2020-06-25 16:43:54.391788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12600 next 690 of size 256\n2020-06-25 16:43:54.391966: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12700 next 691 of size 1024\n2020-06-25 16:43:54.392005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12b00 next 692 of size 256\n2020-06-25 16:43:54.392030: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12c00 next 693 of size 256\n2020-06-25 16:43:54.392065: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f3f12d00 next 694 of size 1179648\n2020-06-25 16:43:54.392222: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4032d00 next 695 of size 1024\n2020-06-25 16:43:54.392262: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4033100 next 696 of size 1179648\n2020-06-25 16:43:54.392286: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4153100 next 697 of size 4096\n2020-06-25 16:43:54.392307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4154100 next 698 of size 12288\n2020-06-25 16:43:54.392327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157100 next 699 of size 1024\n2020-06-25 16:43:54.392348: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157500 next 700 of size 256\n2020-06-25 16:43:54.392382: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157600 next 701 of size 1024\n2020-06-25 16:43:54.392417: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157a00 next 702 of size 1024\n2020-06-25 16:43:54.392443: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4157e00 next 703 of size 1024\n2020-06-25 16:43:54.392591: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158200 next 704 of size 256\n2020-06-25 16:43:54.392626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158300 next 705 of size 256\n2020-06-25 16:43:54.392650: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158400 next 706 of size 256\n2020-06-25 16:43:54.392686: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158500 next 707 of size 512\n2020-06-25 16:43:54.392709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158700 next 708 of size 256\n2020-06-25 16:43:54.392884: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4158800 next 709 of size 262144\n2020-06-25 16:43:54.392910: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4198800 next 710 of size 1024\n2020-06-25 16:43:54.392932: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4198c00 next 711 of size 1024\n2020-06-25 16:43:54.392952: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4199000 next 712 of size 294912\n2020-06-25 16:43:54.392973: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f41e1000 next 713 of size 2359296\n2020-06-25 16:43:54.393010: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421000 next 714 of size 1024\n2020-06-25 16:43:54.393048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421400 next 715 of size 256\n2020-06-25 16:43:54.393074: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4421500 next 716 of size 8388608\n2020-06-25 16:43:54.393230: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4c21500 next 717 of size 1024\n2020-06-25 16:43:54.393265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4c21900 next 718 of size 2359296\n2020-06-25 16:43:54.393288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61900 next 719 of size 256\n2020-06-25 16:43:54.393327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61a00 next 720 of size 512\n2020-06-25 16:43:54.393363: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e61c00 next 721 of size 1024\n2020-06-25 16:43:54.393387: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e62000 next 722 of size 1024\n2020-06-25 16:43:54.393532: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4e62400 next 723 of size 262144\n2020-06-25 16:43:54.393571: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4ea2400 next 724 of size 1024\n2020-06-25 16:43:54.393595: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f4ea2800 next 725 of size 2359296\n2020-06-25 16:43:54.393631: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2800 next 726 of size 1024\n2020-06-25 16:43:54.393669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2c00 next 727 of size 256\n2020-06-25 16:43:54.393694: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e2d00 next 728 of size 1024\n2020-06-25 16:43:54.393715: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e3100 next 729 of size 4096\n2020-06-25 16:43:54.393889: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50e4100 next 730 of size 37632\n2020-06-25 16:43:54.393920: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ed400 next 731 of size 2048\n2020-06-25 16:43:54.393954: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50edc00 next 732 of size 1024\n2020-06-25 16:43:54.393978: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ee000 next 733 of size 1024\n2020-06-25 16:43:54.394130: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f50ee400 next 734 of size 294912\n2020-06-25 16:43:54.394156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5136400 next 735 of size 2048\n2020-06-25 16:43:54.394189: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5136c00 next 736 of size 1024\n2020-06-25 16:43:54.394218: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137000 next 737 of size 1024\n2020-06-25 16:43:54.394261: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137400 next 738 of size 1024\n2020-06-25 16:43:54.394296: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5137800 next 739 of size 2359296\n2020-06-25 16:43:54.394323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5377800 next 740 of size 1024\n2020-06-25 16:43:54.394470: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5377c00 next 741 of size 1024\n2020-06-25 16:43:54.394506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378000 next 742 of size 1024\n2020-06-25 16:43:54.394530: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378400 next 743 of size 256\n2020-06-25 16:43:54.394567: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378500 next 744 of size 256\n2020-06-25 16:43:54.394599: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378600 next 745 of size 256\n2020-06-25 16:43:54.394636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378700 next 746 of size 1024\n2020-06-25 16:43:54.394777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378b00 next 747 of size 1024\n2020-06-25 16:43:54.394828: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5378f00 next 748 of size 512\n2020-06-25 16:43:54.394869: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379100 next 749 of size 256\n2020-06-25 16:43:54.395009: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379200 next 750 of size 2048\n2020-06-25 16:43:54.395043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379a00 next 751 of size 256\n2020-06-25 16:43:54.395066: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379b00 next 752 of size 1024\n2020-06-25 16:43:54.395086: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f5379f00 next 753 of size 1024\n2020-06-25 16:43:54.395105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f537a300 next 754 of size 1024\n2020-06-25 16:43:54.395136: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7f537a700 next 755 of size 134217728\n2020-06-25 16:43:54.395161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37a700 next 756 of size 1024\n2020-06-25 16:43:54.395318: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37ab00 next 757 of size 1024\n2020-06-25 16:43:54.395344: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37af00 next 758 of size 1024\n2020-06-25 16:43:54.395365: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37b300 next 759 of size 1024\n2020-06-25 16:43:54.395384: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37b700 next 760 of size 1024\n2020-06-25 16:43:54.395404: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37bb00 next 761 of size 1024\n2020-06-25 16:43:54.395455: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37bf00 next 762 of size 512\n2020-06-25 16:43:54.395502: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd37c100 next 763 of size 37632\n2020-06-25 16:43:54.395528: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385400 next 764 of size 256\n2020-06-25 16:43:54.395689: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385500 next 765 of size 256\n2020-06-25 16:43:54.395724: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385600 next 766 of size 256\n2020-06-25 16:43:54.395747: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385700 next 767 of size 1024\n2020-06-25 16:43:54.395790: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385b00 next 768 of size 1024\n2020-06-25 16:43:54.395846: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd385f00 next 769 of size 512\n2020-06-25 16:43:54.395877: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386100 next 770 of size 512\n2020-06-25 16:43:54.396034: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386300 next 771 of size 256\n2020-06-25 16:43:54.396065: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386400 next 772 of size 256\n2020-06-25 16:43:54.396102: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386500 next 773 of size 256\n2020-06-25 16:43:54.396128: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386600 next 774 of size 1024\n2020-06-25 16:43:54.396310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386a00 next 775 of size 1024\n2020-06-25 16:43:54.396336: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd386e00 next 776 of size 1024\n2020-06-25 16:43:54.396356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd387200 next 777 of size 8192\n2020-06-25 16:43:54.396377: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389200 next 778 of size 1024\n2020-06-25 16:43:54.396397: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389600 next 779 of size 1024\n2020-06-25 16:43:54.396438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389a00 next 780 of size 1024\n2020-06-25 16:43:54.396477: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd389e00 next 781 of size 1024\n2020-06-25 16:43:54.396502: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a200 next 782 of size 256\n2020-06-25 16:43:54.396523: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a300 next 783 of size 256\n2020-06-25 16:43:54.396695: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a400 next 784 of size 256\n2020-06-25 16:43:54.396725: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a500 next 785 of size 256\n2020-06-25 16:43:54.396746: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a600 next 786 of size 256\n2020-06-25 16:43:54.396786: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a700 next 787 of size 256\n2020-06-25 16:43:54.396945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a800 next 788 of size 256\n2020-06-25 16:43:54.396981: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38a900 next 789 of size 1024\n2020-06-25 16:43:54.397004: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38ad00 next 790 of size 1024\n2020-06-25 16:43:54.397023: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b100 next 791 of size 256\n2020-06-25 16:43:54.397043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b200 next 792 of size 1024\n2020-06-25 16:43:54.397081: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b600 next 793 of size 512\n2020-06-25 16:43:54.397106: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38b800 next 794 of size 1024\n2020-06-25 16:43:54.397310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38bc00 next 795 of size 1024\n2020-06-25 16:43:54.397348: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c000 next 796 of size 1024\n2020-06-25 16:43:54.397369: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c400 next 797 of size 1024\n2020-06-25 16:43:54.397388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38c800 next 798 of size 1024\n2020-06-25 16:43:54.397408: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38cc00 next 799 of size 1024\n2020-06-25 16:43:54.397444: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d000 next 800 of size 1024\n2020-06-25 16:43:54.397468: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d400 next 801 of size 1024\n2020-06-25 16:43:54.397635: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38d800 next 802 of size 4096\n2020-06-25 16:43:54.397732: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x7fd38e800 next 803 of size 134217728\n2020-06-25 16:43:54.397970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80538e800 next 804 of size 8192\n2020-06-25 16:43:54.398020: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390800 next 805 of size 256\n2020-06-25 16:43:54.398043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390900 next 806 of size 256\n2020-06-25 16:43:54.398064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390a00 next 807 of size 256\n2020-06-25 16:43:54.398100: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805390b00 next 808 of size 2097152\n2020-06-25 16:43:54.398121: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590b00 next 809 of size 256\n2020-06-25 16:43:54.398159: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590c00 next 810 of size 256\n2020-06-25 16:43:54.398208: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805590d00 next 811 of size 1024\n2020-06-25 16:43:54.398237: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591100 next 812 of size 1024\n2020-06-25 16:43:54.398257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591500 next 813 of size 1024\n2020-06-25 16:43:54.398402: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591900 next 814 of size 256\n2020-06-25 16:43:54.398436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591a00 next 815 of size 1024\n2020-06-25 16:43:54.398459: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591e00 next 816 of size 256\n2020-06-25 16:43:54.398494: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805591f00 next 817 of size 256\n2020-06-25 16:43:54.398531: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592000 next 818 of size 1024\n2020-06-25 16:43:54.398556: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592400 next 819 of size 256\n2020-06-25 16:43:54.398702: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592500 next 820 of size 2048\n2020-06-25 16:43:54.398737: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592d00 next 821 of size 256\n2020-06-25 16:43:54.398760: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592e00 next 822 of size 256\n2020-06-25 16:43:54.398794: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805592f00 next 823 of size 512\n2020-06-25 16:43:54.398960: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593100 next 824 of size 1024\n2020-06-25 16:43:54.398997: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593500 next 825 of size 256\n2020-06-25 16:43:54.399021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593600 next 826 of size 1024\n2020-06-25 16:43:54.399041: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593a00 next 827 of size 1024\n2020-06-25 16:43:54.399061: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805593e00 next 828 of size 1024\n2020-06-25 16:43:54.399092: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594200 next 829 of size 1024\n2020-06-25 16:43:54.399118: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594600 next 830 of size 1024\n2020-06-25 16:43:54.399281: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594a00 next 831 of size 1024\n2020-06-25 16:43:54.399308: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805594e00 next 832 of size 1024\n2020-06-25 16:43:54.399330: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805595200 next 833 of size 2048\n2020-06-25 16:43:54.399349: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805595a00 next 834 of size 8192\n2020-06-25 16:43:54.399371: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805597a00 next 835 of size 1024\n2020-06-25 16:43:54.399407: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805597e00 next 836 of size 4096\n2020-06-25 16:43:54.399442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805598e00 next 837 of size 512\n2020-06-25 16:43:54.399467: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599000 next 838 of size 1024\n2020-06-25 16:43:54.399616: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599400 next 839 of size 1024\n2020-06-25 16:43:54.399651: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599800 next 840 of size 1024\n2020-06-25 16:43:54.399676: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805599c00 next 841 of size 1024\n2020-06-25 16:43:54.399715: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a000 next 842 of size 1024\n2020-06-25 16:43:54.399752: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a400 next 843 of size 1024\n2020-06-25 16:43:54.399777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559a800 next 844 of size 1024\n2020-06-25 16:43:54.399945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ac00 next 845 of size 256\n2020-06-25 16:43:54.399981: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ad00 next 846 of size 8192\n2020-06-25 16:43:54.400006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559cd00 next 847 of size 256\n2020-06-25 16:43:54.400043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ce00 next 848 of size 256\n2020-06-25 16:43:54.400073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559cf00 next 849 of size 8192\n2020-06-25 16:43:54.400097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559ef00 next 850 of size 256\n2020-06-25 16:43:54.400265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f000 next 851 of size 512\n2020-06-25 16:43:54.400312: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f200 next 852 of size 512\n2020-06-25 16:43:54.400335: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f400 next 853 of size 1024\n2020-06-25 16:43:54.400367: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559f800 next 854 of size 1024\n2020-06-25 16:43:54.400392: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80559fc00 next 855 of size 8192\n2020-06-25 16:43:54.400425: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a1c00 next 856 of size 1024\n2020-06-25 16:43:54.400447: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2000 next 857 of size 1024\n2020-06-25 16:43:54.400605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2400 next 858 of size 1024\n2020-06-25 16:43:54.400636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2800 next 859 of size 1024\n2020-06-25 16:43:54.400673: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a2c00 next 860 of size 1024\n2020-06-25 16:43:54.400699: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3000 next 861 of size 1024\n2020-06-25 16:43:54.400729: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3400 next 862 of size 256\n2020-06-25 16:43:54.400753: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3500 next 863 of size 256\n2020-06-25 16:43:54.400782: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3600 next 864 of size 1024\n2020-06-25 16:43:54.400960: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3a00 next 865 of size 256\n2020-06-25 16:43:54.400985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a3b00 next 866 of size 8192\n2020-06-25 16:43:54.401021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a5b00 next 867 of size 1024\n2020-06-25 16:43:54.401057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a5f00 next 868 of size 1024\n2020-06-25 16:43:54.401082: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6300 next 869 of size 1024\n2020-06-25 16:43:54.401236: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6700 next 870 of size 1024\n2020-06-25 16:43:54.401272: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6b00 next 871 of size 256\n2020-06-25 16:43:54.401296: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a6c00 next 872 of size 1024\n2020-06-25 16:43:54.401333: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7000 next 873 of size 256\n2020-06-25 16:43:54.401363: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7100 next 874 of size 256\n2020-06-25 16:43:54.401387: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7200 next 875 of size 1024\n2020-06-25 16:43:54.401415: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7600 next 876 of size 1024\n2020-06-25 16:43:54.401603: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7a00 next 877 of size 1024\n2020-06-25 16:43:54.401628: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a7e00 next 878 of size 1024\n2020-06-25 16:43:54.401691: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8200 next 879 of size 1024\n2020-06-25 16:43:54.401715: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8600 next 880 of size 1024\n2020-06-25 16:43:54.401875: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8a00 next 881 of size 1024\n2020-06-25 16:43:54.401906: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a8e00 next 882 of size 1024\n2020-06-25 16:43:54.401932: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9200 next 883 of size 2048\n2020-06-25 16:43:54.401951: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9a00 next 884 of size 256\n2020-06-25 16:43:54.401970: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9b00 next 885 of size 256\n2020-06-25 16:43:54.401988: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055a9c00 next 886 of size 2048\n2020-06-25 16:43:54.402006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa400 next 887 of size 256\n2020-06-25 16:43:54.402023: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa500 next 888 of size 512\n2020-06-25 16:43:54.402039: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aa700 next 889 of size 1024\n2020-06-25 16:43:54.402056: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aab00 next 890 of size 1024\n2020-06-25 16:43:54.402072: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aaf00 next 891 of size 2048\n2020-06-25 16:43:54.402089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ab700 next 892 of size 1024\n2020-06-25 16:43:54.402105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055abb00 next 893 of size 1024\n2020-06-25 16:43:54.402121: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055abf00 next 894 of size 256\n2020-06-25 16:43:54.402137: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac000 next 895 of size 256\n2020-06-25 16:43:54.402154: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac100 next 896 of size 512\n2020-06-25 16:43:54.402170: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac300 next 897 of size 512\n2020-06-25 16:43:54.402189: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac500 next 898 of size 512\n2020-06-25 16:43:54.402207: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac700 next 899 of size 256\n2020-06-25 16:43:54.402223: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ac800 next 900 of size 1024\n2020-06-25 16:43:54.402240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055acc00 next 901 of size 1024\n2020-06-25 16:43:54.402256: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad000 next 902 of size 1024\n2020-06-25 16:43:54.402273: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad400 next 903 of size 1024\n2020-06-25 16:43:54.402289: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ad800 next 904 of size 1024\n2020-06-25 16:43:54.402306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055adc00 next 905 of size 1024\n2020-06-25 16:43:54.402323: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae000 next 906 of size 1024\n2020-06-25 16:43:54.402339: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae400 next 907 of size 256\n2020-06-25 16:43:54.402356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae500 next 908 of size 1024\n2020-06-25 16:43:54.402372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055ae900 next 909 of size 1024\n2020-06-25 16:43:54.402388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aed00 next 910 of size 256\n2020-06-25 16:43:54.402405: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055aee00 next 911 of size 1024\n2020-06-25 16:43:54.402421: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af200 next 912 of size 256\n2020-06-25 16:43:54.402438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af300 next 913 of size 1024\n2020-06-25 16:43:54.402454: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af700 next 914 of size 512\n2020-06-25 16:43:54.402471: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055af900 next 915 of size 256\n2020-06-25 16:43:54.402487: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055afa00 next 916 of size 32768\n2020-06-25 16:43:54.402522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055b7a00 next 917 of size 32768\n2020-06-25 16:43:54.402539: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055bfa00 next 918 of size 4096\n2020-06-25 16:43:54.402556: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8055c0a00 next 919 of size 2359296\n2020-06-25 16:43:54.402572: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805800a00 next 920 of size 2359296\n2020-06-25 16:43:54.402589: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40a00 next 921 of size 256\n2020-06-25 16:43:54.402605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40b00 next 922 of size 512\n2020-06-25 16:43:54.402621: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a40d00 next 923 of size 1024\n2020-06-25 16:43:54.402636: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41100 next 924 of size 1024\n2020-06-25 16:43:54.402652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41500 next 925 of size 256\n2020-06-25 16:43:54.402669: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41600 next 926 of size 1024\n2020-06-25 16:43:54.402694: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41a00 next 927 of size 1024\n2020-06-25 16:43:54.402710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a41e00 next 928 of size 1024\n2020-06-25 16:43:54.402726: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42200 next 929 of size 1024\n2020-06-25 16:43:54.402742: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42600 next 930 of size 1024\n2020-06-25 16:43:54.402758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42a00 next 931 of size 1024\n2020-06-25 16:43:54.402774: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42e00 next 932 of size 256\n2020-06-25 16:43:54.402789: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a42f00 next 933 of size 1024\n2020-06-25 16:43:54.402805: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43300 next 934 of size 1024\n2020-06-25 16:43:54.402841: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43700 next 935 of size 1024\n2020-06-25 16:43:54.402864: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43b00 next 936 of size 1024\n2020-06-25 16:43:54.402886: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a43f00 next 937 of size 512\n2020-06-25 16:43:54.402907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44100 next 938 of size 1024\n2020-06-25 16:43:54.402928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805a44500 next 939 of size 1179648\n2020-06-25 16:43:54.402948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805b64500 next 940 of size 1179648\n2020-06-25 16:43:54.402969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x805c84500 next 941 of size 33554432\n2020-06-25 16:43:54.402991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x807c84500 next 942 of size 33554432\n2020-06-25 16:43:54.403011: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809c84500 next 943 of size 294912\n2020-06-25 16:43:54.403032: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809ccc500 next 944 of size 294912\n2020-06-25 16:43:54.403053: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14500 next 945 of size 256\n2020-06-25 16:43:54.403074: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14600 next 946 of size 256\n2020-06-25 16:43:54.403095: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809d14700 next 947 of size 2097152\n2020-06-25 16:43:54.403117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x809f14700 next 948 of size 2097152\n2020-06-25 16:43:54.403139: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114700 next 949 of size 1024\n2020-06-25 16:43:54.403161: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a114b00 next 950 of size 2048\n2020-06-25 16:43:54.403195: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115300 next 951 of size 1024\n2020-06-25 16:43:54.403219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a115700 next 952 of size 8192\n2020-06-25 16:43:54.403240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117700 next 953 of size 1024\n2020-06-25 16:43:54.403261: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a117b00 next 954 of size 2359296\n2020-06-25 16:43:54.403283: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a357b00 next 955 of size 2359296\n2020-06-25 16:43:54.403304: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a597b00 next 956 of size 1179648\n2020-06-25 16:43:54.403327: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a6b7b00 next 957 of size 1179648\n2020-06-25 16:43:54.403342: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a7d7b00 next 958 of size 2097152\n2020-06-25 16:43:54.403360: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80a9d7b00 next 959 of size 2097152\n2020-06-25 16:43:54.403381: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80abd7b00 next 960 of size 2359296\n2020-06-25 16:43:54.403401: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ae17b00 next 961 of size 2359296\n2020-06-25 16:43:54.403422: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b057b00 next 963 of size 8192\n2020-06-25 16:43:54.403442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b059b00 next 964 of size 8192\n2020-06-25 16:43:54.403464: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05bb00 next 965 of size 8192\n2020-06-25 16:43:54.403484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b05db00 next 966 of size 524288\n2020-06-25 16:43:54.403506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b0ddb00 next 967 of size 524288\n2020-06-25 16:43:54.403529: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15db00 next 968 of size 1024\n2020-06-25 16:43:54.403549: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15df00 next 969 of size 1024\n2020-06-25 16:43:54.403571: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b15e300 next 970 of size 2359296\n2020-06-25 16:43:54.403594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e300 next 971 of size 1024\n2020-06-25 16:43:54.403616: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39e700 next 972 of size 1024\n2020-06-25 16:43:54.403637: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b39eb00 next 974 of size 262144\n2020-06-25 16:43:54.403659: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b3deb00 next 975 of size 2359296\n2020-06-25 16:43:54.403686: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b61eb00 next 976 of size 2359296\n2020-06-25 16:43:54.403709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80b85eb00 next 977 of size 2359296\n2020-06-25 16:43:54.403730: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ba9eb00 next 978 of size 2359296\n2020-06-25 16:43:54.403751: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdeb00 next 979 of size 2048\n2020-06-25 16:43:54.403773: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bcdf300 next 980 of size 2359296\n2020-06-25 16:43:54.403792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80bf1f300 next 981 of size 2359296\n2020-06-25 16:43:54.403830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c15f300 next 982 of size 4096\n2020-06-25 16:43:54.403858: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160300 next 983 of size 256\n2020-06-25 16:43:54.403882: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160400 next 984 of size 1024\n2020-06-25 16:43:54.403904: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c160800 next 985 of size 32768\n2020-06-25 16:43:54.403925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c168800 next 986 of size 32768\n2020-06-25 16:43:54.403948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c170800 next 987 of size 2359296\n2020-06-25 16:43:54.403969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c3b0800 next 988 of size 2359296\n2020-06-25 16:43:54.404002: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c5f0800 next 989 of size 2359296\n2020-06-25 16:43:54.404036: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80c830800 next 990 of size 2359296\n2020-06-25 16:43:54.404057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ca70800 next 991 of size 33554432\n2020-06-25 16:43:54.404079: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x80ea70800 next 992 of size 33554432\n2020-06-25 16:43:54.404100: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810a70800 next 993 of size 2359296\n2020-06-25 16:43:54.404121: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810cb0800 next 994 of size 2359296\n2020-06-25 16:43:54.404142: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810ef0800 next 995 of size 131072\n2020-06-25 16:43:54.404163: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f10800 next 996 of size 131072\n2020-06-25 16:43:54.404183: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x810f30800 next 997 of size 2359296\n2020-06-25 16:43:54.404203: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811170800 next 998 of size 2359296\n2020-06-25 16:43:54.404224: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8113b0800 next 1001 of size 2359296\n2020-06-25 16:43:54.404245: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8115f0800 next 1002 of size 2359296\n2020-06-25 16:43:54.404267: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x811830800 next 1003 of size 8388608\n2020-06-25 16:43:54.404288: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812030800 next 1004 of size 8388608\n2020-06-25 16:43:54.404310: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830800 next 1005 of size 1024\n2020-06-25 16:43:54.404332: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812830c00 next 1006 of size 2359296\n2020-06-25 16:43:54.404353: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812a70c00 next 1007 of size 2359296\n2020-06-25 16:43:54.404374: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb0c00 next 1008 of size 1024\n2020-06-25 16:43:54.404395: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1000 next 1009 of size 1024\n2020-06-25 16:43:54.404416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1400 next 1010 of size 1024\n2020-06-25 16:43:54.404438: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1800 next 1011 of size 1024\n2020-06-25 16:43:54.404460: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cb1c00 next 1012 of size 262144\n2020-06-25 16:43:54.404481: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812cf1c00 next 1013 of size 1179648\n2020-06-25 16:43:54.404501: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812e11c00 next 1014 of size 1179648\n2020-06-25 16:43:54.404522: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f31c00 next 1015 of size 262144\n2020-06-25 16:43:54.404554: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812f71c00 next 1016 of size 262144\n2020-06-25 16:43:54.404574: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x812fb1c00 next 1017 of size 524288\n2020-06-25 16:43:54.404594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813031c00 next 1018 of size 524288\n2020-06-25 16:43:54.404627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8130b1c00 next 1019 of size 2359296\n2020-06-25 16:43:54.404683: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8132f1c00 next 1020 of size 2359296\n2020-06-25 16:43:54.404710: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813531c00 next 1021 of size 12288\n2020-06-25 16:43:54.404758: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813534c00 next 1022 of size 12288\n2020-06-25 16:43:54.404781: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813537c00 next 1023 of size 2048\n2020-06-25 16:43:54.404831: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813538400 next 1024 of size 1179648\n2020-06-25 16:43:54.404859: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813658400 next 1025 of size 1179648\n2020-06-25 16:43:54.404882: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778400 next 1026 of size 256\n2020-06-25 16:43:54.404903: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778500 next 1027 of size 1024\n2020-06-25 16:43:54.404923: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778900 next 1028 of size 1024\n2020-06-25 16:43:54.404944: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813778d00 next 1029 of size 2359296\n2020-06-25 16:43:54.404964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b8d00 next 1030 of size 1024\n2020-06-25 16:43:54.404985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9100 next 1031 of size 1024\n2020-06-25 16:43:54.405005: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139b9500 next 1032 of size 37632\n2020-06-25 16:43:54.405025: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139c2800 next 1033 of size 37632\n2020-06-25 16:43:54.405047: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8139cbb00 next 1034 of size 524288\n2020-06-25 16:43:54.405068: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813a4bb00 next 1035 of size 524288\n2020-06-25 16:43:54.405089: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813acbb00 next 1036 of size 37632\n2020-06-25 16:43:54.405111: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ad4e00 next 1037 of size 37632\n2020-06-25 16:43:54.405134: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813ade100 next 1038 of size 524288\n2020-06-25 16:43:54.405156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813b5e100 next 1039 of size 524288\n2020-06-25 16:43:54.405177: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813bde100 next 1040 of size 262144\n2020-06-25 16:43:54.405209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c1e100 next 1041 of size 262144\n2020-06-25 16:43:54.405230: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813c5e100 next 1042 of size 2359296\n2020-06-25 16:43:54.405252: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x813e9e100 next 1043 of size 2359296\n2020-06-25 16:43:54.405274: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8140de100 next 1044 of size 8388608\n2020-06-25 16:43:54.405295: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8148de100 next 1045 of size 8388608\n2020-06-25 16:43:54.405328: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8150de100 next 1046 of size 262144\n2020-06-25 16:43:54.405362: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81511e100 next 1047 of size 262144\n2020-06-25 16:43:54.405384: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81515e100 next 1048 of size 2359296\n2020-06-25 16:43:54.405405: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81539e100 next 1049 of size 2359296\n2020-06-25 16:43:54.405427: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8155de100 next 1050 of size 33554432\n2020-06-25 16:43:54.405474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8175de100 next 1051 of size 33554432\n2020-06-25 16:43:54.405497: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195de100 next 1052 of size 131072\n2020-06-25 16:43:54.405519: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe100 next 1053 of size 1024\n2020-06-25 16:43:54.405541: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe500 next 1054 of size 1024\n2020-06-25 16:43:54.405563: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8195fe900 next 1055 of size 2097152\n2020-06-25 16:43:54.405587: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fe900 next 1056 of size 1024\n2020-06-25 16:43:54.405609: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8197fed00 next 1057 of size 131072\n2020-06-25 16:43:54.405630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981ed00 next 1058 of size 1024\n2020-06-25 16:43:54.405652: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f100 next 1059 of size 1024\n2020-06-25 16:43:54.405683: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81981f500 next 1060 of size 2359296\n2020-06-25 16:43:54.405709: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819a5f500 next 1061 of size 2359296\n2020-06-25 16:43:54.405731: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819c9f500 next 1062 of size 2359296\n2020-06-25 16:43:54.405777: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x819edf500 next 1063 of size 2359296\n2020-06-25 16:43:54.405800: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a11f500 next 1064 of size 2359296\n2020-06-25 16:43:54.405841: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a35f500 next 1065 of size 2359296\n2020-06-25 16:43:54.405867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x81a59f500 next 18446744073709551615 of size 158075648\n2020-06-25 16:43:54.405915: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 4294967296\n2020-06-25 16:43:54.405938: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x823e60000 next 678 of size 1073741824\n2020-06-25 16:43:54.405960: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x863e60000 next 962 of size 1073741824\n2020-06-25 16:43:54.405984: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8a3e60000 next 973 of size 1073741824\n2020-06-25 16:43:54.406006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x8e3e60000 next 18446744073709551615 of size 1073741824\n2020-06-25 16:43:54.406027: I tensorflow/core/common_runtime/bfc_allocator.cc:898] Next region of size 2202261760\n2020-06-25 16:43:54.406048: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x923e60000 next 1000 of size 1073741824\n2020-06-25 16:43:54.406071: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x963e60000 next 1066 of size 134217728\n2020-06-25 16:43:54.406093: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be60000 next 1067 of size 12288\n2020-06-25 16:43:54.406114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be63000 next 1068 of size 12288\n2020-06-25 16:43:54.406136: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96be66000 next 1069 of size 33554432\n2020-06-25 16:43:54.406156: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96de66000 next 1070 of size 33554432\n2020-06-25 16:43:54.406177: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe66000 next 1071 of size 12288\n2020-06-25 16:43:54.406198: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe69000 next 1072 of size 12288\n2020-06-25 16:43:54.406219: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c000 next 1073 of size 2048\n2020-06-25 16:43:54.406240: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96fe6c800 next 1074 of size 262144\n2020-06-25 16:43:54.406262: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feac800 next 1075 of size 262144\n2020-06-25 16:43:54.406283: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x96feec800 next 1076 of size 2359296\n2020-06-25 16:43:54.406305: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97012c800 next 1077 of size 2359296\n2020-06-25 16:43:54.406326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97036c800 next 1078 of size 294912\n2020-06-25 16:43:54.406349: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703b4800 next 1079 of size 294912\n2020-06-25 16:43:54.406372: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9703fc800 next 1080 of size 2097152\n2020-06-25 16:43:54.406393: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fc800 next 1081 of size 1024\n2020-06-25 16:43:54.406414: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fcc00 next 1082 of size 1024\n2020-06-25 16:43:54.406436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9705fd000 next 1083 of size 2359296\n2020-06-25 16:43:54.406458: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d000 next 1084 of size 1024\n2020-06-25 16:43:54.406479: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083d400 next 1085 of size 2048\n2020-06-25 16:43:54.406500: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97083dc00 next 1086 of size 294912\n2020-06-25 16:43:54.406521: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970885c00 next 1087 of size 294912\n2020-06-25 16:43:54.406542: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9708cdc00 next 1088 of size 294912\n2020-06-25 16:43:54.406562: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970915c00 next 1089 of size 294912\n2020-06-25 16:43:54.406583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x97095dc00 next 1090 of size 37632\n2020-06-25 16:43:54.406605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970966f00 next 1091 of size 37632\n2020-06-25 16:43:54.406627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970970200 next 1092 of size 2359296\n2020-06-25 16:43:54.406648: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970bb0200 next 1093 of size 2359296\n2020-06-25 16:43:54.406670: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df0200 next 1094 of size 8192\n2020-06-25 16:43:54.406705: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df2200 next 1095 of size 8192\n2020-06-25 16:43:54.406727: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df4200 next 1096 of size 8192\n2020-06-25 16:43:54.406749: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x970df6200 next 1097 of size 2359296\n2020-06-25 16:43:54.406770: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971036200 next 1098 of size 2359296\n2020-06-25 16:43:54.406792: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x971276200 next 1099 of size 262144\n2020-06-25 16:43:54.406830: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712b6200 next 1100 of size 262144\n2020-06-25 16:43:54.406858: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9712f6200 next 1101 of size 2097152\n2020-06-25 16:43:54.406880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9714f6200 next 1102 of size 2097152\n2020-06-25 16:43:54.406902: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9716f6200 next 1103 of size 134217728\n2020-06-25 16:43:54.406925: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9796f6200 next 1104 of size 134217728\n2020-06-25 16:43:54.406947: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6200 next 1105 of size 512\n2020-06-25 16:43:54.406969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6400 next 1106 of size 512\n2020-06-25 16:43:54.406991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6600 next 1107 of size 1024\n2020-06-25 16:43:54.407012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9816f6a00 next 1108 of size 2359296\n2020-06-25 16:43:54.407035: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981936a00 next 1109 of size 2359296\n2020-06-25 16:43:54.407057: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x981b76a00 next 1110 of size 8388608\n2020-06-25 16:43:54.407079: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376a00 next 1111 of size 1024\n2020-06-25 16:43:54.407100: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982376e00 next 1112 of size 1024\n2020-06-25 16:43:54.407122: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982377200 next 1113 of size 12288\n2020-06-25 16:43:54.407143: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237a200 next 1114 of size 12288\n2020-06-25 16:43:54.407165: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98237d200 next 1115 of size 2097152\n2020-06-25 16:43:54.407188: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98257d200 next 1116 of size 2097152\n2020-06-25 16:43:54.407209: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98277d200 next 1117 of size 8388608\n2020-06-25 16:43:54.407230: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x982f7d200 next 1118 of size 8388608\n2020-06-25 16:43:54.407251: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377d200 next 1119 of size 8192\n2020-06-25 16:43:54.407272: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98377f200 next 1120 of size 8192\n2020-06-25 16:43:54.407292: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983781200 next 1121 of size 524288\n2020-06-25 16:43:54.407313: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983801200 next 1122 of size 524288\n2020-06-25 16:43:54.407334: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983881200 next 1123 of size 2359296\n2020-06-25 16:43:54.407356: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983ac1200 next 1124 of size 2359296\n2020-06-25 16:43:54.407377: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983d01200 next 1125 of size 2359296\n2020-06-25 16:43:54.407400: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x983f41200 next 1126 of size 2359296\n2020-06-25 16:43:54.407421: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984181200 next 1127 of size 37632\n2020-06-25 16:43:54.407441: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98418a500 next 1128 of size 37632\n2020-06-25 16:43:54.407463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193800 next 1129 of size 1024\n2020-06-25 16:43:54.407484: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984193c00 next 1130 of size 2048\n2020-06-25 16:43:54.407506: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984194400 next 1131 of size 2359296\n2020-06-25 16:43:54.407528: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4400 next 1132 of size 1024\n2020-06-25 16:43:54.407549: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9843d4800 next 1133 of size 2359296\n2020-06-25 16:43:54.407569: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984614800 next 1134 of size 2359296\n2020-06-25 16:43:54.407588: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984854800 next 1135 of size 2359296\n2020-06-25 16:43:54.407609: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984a94800 next 1136 of size 2359296\n2020-06-25 16:43:54.407630: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984cd4800 next 1137 of size 2359296\n2020-06-25 16:43:54.407650: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x984f14800 next 1138 of size 2359296\n2020-06-25 16:43:54.407670: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154800 next 1139 of size 1024\n2020-06-25 16:43:54.407703: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154c00 next 1140 of size 512\n2020-06-25 16:43:54.407726: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985154e00 next 1141 of size 8192\n2020-06-25 16:43:54.407749: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985156e00 next 1142 of size 8192\n2020-06-25 16:43:54.407774: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985158e00 next 1143 of size 1024\n2020-06-25 16:43:54.407795: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159200 next 1144 of size 2048\n2020-06-25 16:43:54.407833: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159a00 next 1145 of size 1024\n2020-06-25 16:43:54.407862: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985159e00 next 1146 of size 1024\n2020-06-25 16:43:54.407885: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98515a200 next 1147 of size 8388608\n2020-06-25 16:43:54.407907: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98595a200 next 1148 of size 524288\n2020-06-25 16:43:54.407928: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9859da200 next 1149 of size 524288\n2020-06-25 16:43:54.407948: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985a5a200 next 1150 of size 2359296\n2020-06-25 16:43:54.407969: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985c9a200 next 1151 of size 2359296\n2020-06-25 16:43:54.407991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x985eda200 next 1152 of size 2097152\n2020-06-25 16:43:54.408012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9860da200 next 1153 of size 2097152\n2020-06-25 16:43:54.408033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9862da200 next 1154 of size 2359296\n2020-06-25 16:43:54.408055: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98651a200 next 1155 of size 2359296\n2020-06-25 16:43:54.408077: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a200 next 1156 of size 1024\n2020-06-25 16:43:54.408100: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98675a600 next 1157 of size 2359296\n2020-06-25 16:43:54.408122: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98699a600 next 1158 of size 2359296\n2020-06-25 16:43:54.408146: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bda600 next 1159 of size 1024\n2020-06-25 16:43:54.408169: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaa00 next 1160 of size 256\n2020-06-25 16:43:54.408191: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdab00 next 1161 of size 256\n2020-06-25 16:43:54.408213: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdac00 next 1162 of size 256\n2020-06-25 16:43:54.408235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdad00 next 1163 of size 256\n2020-06-25 16:43:54.408257: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdae00 next 1164 of size 256\n2020-06-25 16:43:54.408278: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdaf00 next 1165 of size 256\n2020-06-25 16:43:54.408299: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb000 next 1166 of size 256\n2020-06-25 16:43:54.408319: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb100 next 1167 of size 256\n2020-06-25 16:43:54.408340: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb200 next 1168 of size 256\n2020-06-25 16:43:54.408357: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb300 next 1169 of size 256\n2020-06-25 16:43:54.408378: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb400 next 1170 of size 256\n2020-06-25 16:43:54.408399: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb500 next 1171 of size 256\n2020-06-25 16:43:54.408420: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb600 next 1172 of size 256\n2020-06-25 16:43:54.408442: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb700 next 1173 of size 256\n2020-06-25 16:43:54.408463: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb800 next 1174 of size 256\n2020-06-25 16:43:54.408486: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdb900 next 1175 of size 256\n2020-06-25 16:43:54.408508: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdba00 next 1176 of size 256\n2020-06-25 16:43:54.408531: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbb00 next 1177 of size 256\n2020-06-25 16:43:54.408551: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbc00 next 1178 of size 256\n2020-06-25 16:43:54.408572: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbd00 next 1179 of size 256\n2020-06-25 16:43:54.408605: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbe00 next 1180 of size 256\n2020-06-25 16:43:54.408626: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdbf00 next 1181 of size 256\n2020-06-25 16:43:54.408647: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc000 next 1182 of size 256\n2020-06-25 16:43:54.408667: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc100 next 1183 of size 256\n2020-06-25 16:43:54.408699: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc200 next 1184 of size 256\n2020-06-25 16:43:54.408721: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc300 next 1185 of size 256\n2020-06-25 16:43:54.408741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc400 next 1186 of size 256\n2020-06-25 16:43:54.408763: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc500 next 1187 of size 256\n2020-06-25 16:43:54.408785: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc600 next 1188 of size 256\n2020-06-25 16:43:54.408860: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc700 next 1189 of size 256\n2020-06-25 16:43:54.408900: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc800 next 1190 of size 256\n2020-06-25 16:43:54.408936: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdc900 next 1191 of size 256\n2020-06-25 16:43:54.408958: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdca00 next 1192 of size 256\n2020-06-25 16:43:54.408991: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcb00 next 1193 of size 256\n2020-06-25 16:43:54.409012: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcc00 next 1194 of size 256\n2020-06-25 16:43:54.409033: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcd00 next 1195 of size 256\n2020-06-25 16:43:54.409054: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdce00 next 1196 of size 256\n2020-06-25 16:43:54.409076: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdcf00 next 1197 of size 256\n2020-06-25 16:43:54.409097: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd000 next 1198 of size 256\n2020-06-25 16:43:54.409132: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd100 next 1199 of size 256\n2020-06-25 16:43:54.409164: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd200 next 1200 of size 256\n2020-06-25 16:43:54.409180: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd300 next 1201 of size 256\n2020-06-25 16:43:54.409198: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd400 next 1202 of size 256\n2020-06-25 16:43:54.409217: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd500 next 1203 of size 256\n2020-06-25 16:43:54.409249: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd600 next 1204 of size 256\n2020-06-25 16:43:54.409269: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd700 next 1205 of size 256\n2020-06-25 16:43:54.409290: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd800 next 1206 of size 256\n2020-06-25 16:43:54.409311: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdd900 next 1207 of size 256\n2020-06-25 16:43:54.409333: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdda00 next 1208 of size 256\n2020-06-25 16:43:54.409380: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddb00 next 1209 of size 256\n2020-06-25 16:43:54.409413: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddc00 next 1210 of size 256\n2020-06-25 16:43:54.409433: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddd00 next 1211 of size 256\n2020-06-25 16:43:54.409453: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdde00 next 1212 of size 256\n2020-06-25 16:43:54.409473: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bddf00 next 1213 of size 256\n2020-06-25 16:43:54.409493: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde000 next 1214 of size 256\n2020-06-25 16:43:54.409513: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde100 next 1215 of size 256\n2020-06-25 16:43:54.409533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde200 next 1216 of size 256\n2020-06-25 16:43:54.409554: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde300 next 1217 of size 256\n2020-06-25 16:43:54.409574: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde400 next 1218 of size 256\n2020-06-25 16:43:54.409594: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde500 next 1219 of size 256\n2020-06-25 16:43:54.409614: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde600 next 1220 of size 256\n2020-06-25 16:43:54.409635: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde700 next 1221 of size 256\n2020-06-25 16:43:54.409656: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde800 next 1222 of size 256\n2020-06-25 16:43:54.409685: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bde900 next 1223 of size 256\n2020-06-25 16:43:54.409712: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdea00 next 1224 of size 256\n2020-06-25 16:43:54.409745: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdeb00 next 1225 of size 256\n2020-06-25 16:43:54.409767: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdec00 next 1226 of size 256\n2020-06-25 16:43:54.409788: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bded00 next 1227 of size 256\n2020-06-25 16:43:54.409826: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdee00 next 1228 of size 256\n2020-06-25 16:43:54.409856: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdef00 next 1229 of size 256\n2020-06-25 16:43:54.409879: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf000 next 1230 of size 256\n2020-06-25 16:43:54.409900: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf100 next 1231 of size 256\n2020-06-25 16:43:54.409921: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bdf200 next 1232 of size 4096\n2020-06-25 16:43:54.409941: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0200 next 1233 of size 256\n2020-06-25 16:43:54.409961: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be0300 next 1234 of size 4096\n2020-06-25 16:43:54.409982: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1300 next 1235 of size 256\n2020-06-25 16:43:54.410002: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1400 next 1236 of size 1024\n2020-06-25 16:43:54.410022: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1800 next 1237 of size 256\n2020-06-25 16:43:54.410043: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1900 next 1238 of size 1024\n2020-06-25 16:43:54.410064: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1d00 next 1239 of size 512\n2020-06-25 16:43:54.410085: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be1f00 next 1240 of size 256\n2020-06-25 16:43:54.410109: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2000 next 1241 of size 1024\n2020-06-25 16:43:54.410145: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2400 next 1242 of size 1024\n2020-06-25 16:43:54.410192: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2800 next 1243 of size 1024\n2020-06-25 16:43:54.410227: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2c00 next 1358 of size 256\n2020-06-25 16:43:54.410248: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2d00 next 1375 of size 256\n2020-06-25 16:43:54.410282: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2e00 next 1380 of size 256\n2020-06-25 16:43:54.410304: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be2f00 next 1244 of size 256\n2020-06-25 16:43:54.410326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3000 next 1245 of size 1024\n2020-06-25 16:43:54.410347: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3400 next 1246 of size 1024\n2020-06-25 16:43:54.410369: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3800 next 1247 of size 1024\n2020-06-25 16:43:54.410388: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be3c00 next 1251 of size 1024\n2020-06-25 16:43:54.410409: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be4000 next 1252 of size 8192\n2020-06-25 16:43:54.410432: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6000 next 1256 of size 1024\n2020-06-25 16:43:54.410452: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6400 next 1257 of size 2048\n2020-06-25 16:43:54.410474: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be6c00 next 1261 of size 1024\n2020-06-25 16:43:54.410511: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be7000 next 1262 of size 8192\n2020-06-25 16:43:54.410533: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9000 next 1298 of size 256\n2020-06-25 16:43:54.410555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9100 next 1290 of size 256\n2020-06-25 16:43:54.410576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9200 next 1265 of size 256\n2020-06-25 16:43:54.410598: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9300 next 1266 of size 2048\n2020-06-25 16:43:54.410620: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9b00 next 1297 of size 256\n2020-06-25 16:43:54.410642: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9c00 next 1268 of size 256\n2020-06-25 16:43:54.410664: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986be9d00 next 1269 of size 2048\n2020-06-25 16:43:54.410696: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea500 next 1270 of size 256\n2020-06-25 16:43:54.410719: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bea600 next 1271 of size 2048\n2020-06-25 16:43:54.410740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beae00 next 1276 of size 1280\n2020-06-25 16:43:54.410761: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb300 next 1277 of size 256\n2020-06-25 16:43:54.410782: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb400 next 1278 of size 256\n2020-06-25 16:43:54.410803: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb500 next 1279 of size 1024\n2020-06-25 16:43:54.410847: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beb900 next 1280 of size 1024\n2020-06-25 16:43:54.410872: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bebd00 next 1281 of size 1024\n2020-06-25 16:43:54.410896: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec100 next 1282 of size 1024\n2020-06-25 16:43:54.410920: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec500 next 1283 of size 512\n2020-06-25 16:43:54.410942: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec700 next 1405 of size 256\n2020-06-25 16:43:54.410964: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x986bec800 next 1406 of size 256\n2020-06-25 16:43:54.410985: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bec900 next 1293 of size 256\n2020-06-25 16:43:54.411006: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986beca00 next 1284 of size 256\n2020-06-25 16:43:54.411027: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becb00 next 1285 of size 1024\n2020-06-25 16:43:54.411049: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986becf00 next 1286 of size 1024\n2020-06-25 16:43:54.411071: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed300 next 1287 of size 1024\n2020-06-25 16:43:54.411093: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bed700 next 1288 of size 1024\n2020-06-25 16:43:54.411114: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedb00 next 1289 of size 256\n2020-06-25 16:43:54.411135: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bedc00 next 1294 of size 1280\n2020-06-25 16:43:54.411157: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bee100 next 1295 of size 8192\n2020-06-25 16:43:54.411178: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf0100 next 1296 of size 8192\n2020-06-25 16:43:54.411198: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2100 next 1373 of size 256\n2020-06-25 16:43:54.411220: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2200 next 1272 of size 256\n2020-06-25 16:43:54.411242: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2300 next 1299 of size 256\n2020-06-25 16:43:54.411264: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x986bf2400 next 1300 of size 33554432\n2020-06-25 16:43:54.411286: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bf2400 next 1301 of size 32768\n2020-06-25 16:43:54.411307: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988bfa400 next 1302 of size 524288\n2020-06-25 16:43:54.411329: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7a400 next 1303 of size 4096\n2020-06-25 16:43:54.411351: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7b400 next 1304 of size 12288\n2020-06-25 16:43:54.411373: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e400 next 1305 of size 256\n2020-06-25 16:43:54.411394: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988c7e500 next 1306 of size 524288\n2020-06-25 16:43:54.411416: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cfe500 next 1307 of size 4096\n2020-06-25 16:43:54.411436: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988cff500 next 1308 of size 32768\n2020-06-25 16:43:54.411457: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d07500 next 1309 of size 32768\n2020-06-25 16:43:54.411489: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x988d0f500 next 1310 of size 8388608\n2020-06-25 16:43:54.411513: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x98950f500 next 1311 of size 16384\n2020-06-25 16:43:54.411535: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989513500 next 1312 of size 131072\n2020-06-25 16:43:54.411555: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989533500 next 1313 of size 131072\n2020-06-25 16:43:54.411576: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989553500 next 1314 of size 524288\n2020-06-25 16:43:54.411600: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d3500 next 1315 of size 4096\n2020-06-25 16:43:54.411622: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9895d4500 next 1316 of size 8388608\n2020-06-25 16:43:54.411644: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd4500 next 1317 of size 16384\n2020-06-25 16:43:54.411688: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x989dd8500 next 1318 of size 134217728\n2020-06-25 16:43:54.411717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dd8500 next 1319 of size 65536\n2020-06-25 16:43:54.411741: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x991de8500 next 1320 of size 8192\n2020-06-25 16:43:54.411775: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991dea500 next 1321 of size 12288\n2020-06-25 16:43:54.411837: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded500 next 1322 of size 256\n2020-06-25 16:43:54.411880: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991ded600 next 1323 of size 2097152\n2020-06-25 16:43:54.411903: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fed600 next 1324 of size 8192\n2020-06-25 16:43:54.411924: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x991fef600 next 1325 of size 2097152\n2020-06-25 16:43:54.411945: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921ef600 next 1326 of size 8192\n2020-06-25 16:43:54.411966: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9921f1600 next 1327 of size 2097152\n2020-06-25 16:43:54.411988: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f1600 next 1328 of size 8192\n2020-06-25 16:43:54.412008: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3600 next 1389 of size 256\n2020-06-25 16:43:54.412031: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3700 next 1392 of size 256\n2020-06-25 16:43:54.412052: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3800 next 1394 of size 256\n2020-06-25 16:43:54.412073: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9923f3900 next 1398 of size 1024\n2020-06-25 16:43:54.412096: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f3d00 next 1291 of size 1024\n2020-06-25 16:43:54.412117: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f4100 next 1330 of size 1280\n2020-06-25 16:43:54.412138: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923f4600 next 1331 of size 32768\n2020-06-25 16:43:54.412159: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9923fc600 next 1332 of size 32768\n2020-06-25 16:43:54.412181: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992404600 next 1333 of size 12288\n2020-06-25 16:43:54.412203: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407600 next 1334 of size 256\n2020-06-25 16:43:54.412224: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992407700 next 1335 of size 12288\n2020-06-25 16:43:54.412245: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a700 next 1336 of size 256\n2020-06-25 16:43:54.412265: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99240a800 next 1337 of size 8388608\n2020-06-25 16:43:54.412285: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0a800 next 1338 of size 16384\n2020-06-25 16:43:54.412306: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992c0e800 next 1339 of size 2097152\n2020-06-25 16:43:54.412326: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e0e800 next 1340 of size 8192\n2020-06-25 16:43:54.412346: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e10800 next 1341 of size 524288\n2020-06-25 16:43:54.412366: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e90800 next 1342 of size 4096\n2020-06-25 16:43:54.412386: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992e91800 next 1343 of size 131072\n2020-06-25 16:43:54.412408: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992eb1800 next 1344 of size 131072\n2020-06-25 16:43:54.412428: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x992ed1800 next 1345 of size 33554432\n2020-06-25 16:43:54.412450: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994ed1800 next 1346 of size 32768\n2020-06-25 16:43:54.412471: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994ed9800 next 1292 of size 1024\n2020-06-25 16:43:54.412495: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x994ed9c00 next 1347 of size 7168\n2020-06-25 16:43:54.412517: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x994edb800 next 1348 of size 8388608\n2020-06-25 16:43:54.412540: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956db800 next 1349 of size 16384\n2020-06-25 16:43:54.412561: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9956df800 next 1350 of size 134217728\n2020-06-25 16:43:54.412583: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6df800 next 1351 of size 65536\n2020-06-25 16:43:54.412606: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99d6ef800 next 1352 of size 33554432\n2020-06-25 16:43:54.412627: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x99f6ef800 next 1354 of size 33792\n2020-06-25 16:43:54.412649: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f6f7c00 next 1355 of size 524288\n2020-06-25 16:43:54.412692: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f777c00 next 1273 of size 256\n2020-06-25 16:43:54.412717: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f777d00 next 1253 of size 256\n2020-06-25 16:43:54.412740: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f777e00 next 1264 of size 1024\n2020-06-25 16:43:54.412761: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f778200 next 1275 of size 1024\n2020-06-25 16:43:54.412798: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f778600 next 1356 of size 1536\n2020-06-25 16:43:54.412840: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f778c00 next 1357 of size 12288\n2020-06-25 16:43:54.412867: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f77bc00 next 1359 of size 524288\n2020-06-25 16:43:54.412890: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fbc00 next 1263 of size 1024\n2020-06-25 16:43:54.412913: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fc000 next 1258 of size 1024\n2020-06-25 16:43:54.412935: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fc400 next 1259 of size 1024\n2020-06-25 16:43:54.412956: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fc800 next 1360 of size 1024\n2020-06-25 16:43:54.412978: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fcc00 next 1361 of size 8192\n2020-06-25 16:43:54.412999: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f7fec00 next 1362 of size 2097152\n2020-06-25 16:43:54.413021: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99f9fec00 next 1363 of size 32768\n2020-06-25 16:43:54.413042: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x99fa06c00 next 1364 of size 32768\n2020-06-25 16:43:54.413063: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x99fa0ec00 next 1365 of size 8388608\n2020-06-25 16:43:54.413084: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a020ec00 next 1366 of size 16384\n2020-06-25 16:43:54.413105: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0212c00 next 1367 of size 2048\n2020-06-25 16:43:54.413126: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0213400 next 1368 of size 131072\n2020-06-25 16:43:54.413147: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a0233400 next 1369 of size 131072\n2020-06-25 16:43:54.413170: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0253400 next 1370 of size 524288\n2020-06-25 16:43:54.413192: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3400 next 1250 of size 1024\n2020-06-25 16:43:54.413214: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3800 next 1260 of size 256\n2020-06-25 16:43:54.413235: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3900 next 1254 of size 256\n2020-06-25 16:43:54.413258: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3a00 next 1255 of size 256\n2020-06-25 16:43:54.413279: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d3b00 next 1267 of size 256\n2020-06-25 16:43:54.413301: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a02d3c00 next 1371 of size 2048\n2020-06-25 16:43:54.413321: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a02d4400 next 1372 of size 8388608\n2020-06-25 16:43:54.413342: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a0ad4400 next 1381 of size 81920\n2020-06-25 16:43:54.413363: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ae8400 next 1382 of size 12288\n2020-06-25 16:43:54.413385: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0aeb400 next 1376 of size 2294016\n2020-06-25 16:43:54.413407: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0d1b500 next 1377 of size 798976\n2020-06-25 16:43:54.413430: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0dde600 next 1378 of size 798976\n2020-06-25 16:43:54.413451: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a0ea1700 next 1379 of size 4194304\n2020-06-25 16:43:54.413473: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a12a1700 next 1374 of size 4194304\n2020-06-25 16:43:54.413493: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1700 next 1383 of size 2048\n2020-06-25 16:43:54.413514: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a16a1f00 next 1384 of size 2097152\n2020-06-25 16:43:54.413536: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a18a1f00 next 1385 of size 8192\n2020-06-25 16:43:54.413558: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a18a3f00 next 1386 of size 2097152\n2020-06-25 16:43:54.413580: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a1aa3f00 next 1387 of size 8192\n2020-06-25 16:43:54.413601: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a1aa5f00 next 1388 of size 33554432\n2020-06-25 16:43:54.413623: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3aa5f00 next 1329 of size 32768\n2020-06-25 16:43:54.413645: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a3aadf00 next 1390 of size 32768\n2020-06-25 16:43:54.413666: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab5f00 next 1391 of size 12288\n2020-06-25 16:43:54.413697: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3ab8f00 next 1393 of size 12288\n2020-06-25 16:43:54.413721: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3abbf00 next 1395 of size 2097152\n2020-06-25 16:43:54.413743: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a3cbbf00 next 1396 of size 8388608\n2020-06-25 16:43:54.413763: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a44bbf00 next 1397 of size 16384\n2020-06-25 16:43:54.413782: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a44bff00 next 1399 of size 2097152\n2020-06-25 16:43:54.413802: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a46bff00 next 1400 of size 8192\n2020-06-25 16:43:54.413844: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a46c1f00 next 1401 of size 524288\n2020-06-25 16:43:54.413869: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a4741f00 next 1402 of size 4096\n2020-06-25 16:43:54.413891: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4742f00 next 1403 of size 131072\n2020-06-25 16:43:54.413912: I tensorflow/core/common_runtime/bfc_allocator.cc:905] Free at 0x9a4762f00 next 1404 of size 131072\n2020-06-25 16:43:54.413935: I tensorflow/core/common_runtime/bfc_allocator.cc:905] InUse at 0x9a4782f00 next 18446744073709551615 of size 45197824\n2020-06-25 16:43:54.413957: I tensorflow/core/common_runtime/bfc_allocator.cc:914] Summary of in-use Chunks by size: \n2020-06-25 16:43:54.413985: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 340 Chunks of size 256 totalling 85.0KiB\n2020-06-25 16:43:54.414011: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 82 Chunks of size 512 totalling 41.0KiB\n2020-06-25 16:43:54.414038: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 474 Chunks of size 1024 totalling 474.0KiB\n2020-06-25 16:43:54.414063: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 4 Chunks of size 1280 totalling 5.0KiB\n2020-06-25 16:43:54.414088: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 1536 totalling 1.5KiB\n2020-06-25 16:43:54.414112: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 42 Chunks of size 2048 totalling 84.0KiB\n2020-06-25 16:43:54.414137: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 4096 totalling 64.0KiB\n2020-06-25 16:43:54.414173: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 35 Chunks of size 8192 totalling 280.0KiB\n2020-06-25 16:43:54.414199: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 12288 totalling 288.0KiB\n2020-06-25 16:43:54.414219: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 4 Chunks of size 16384 totalling 64.0KiB\n2020-06-25 16:43:54.414242: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 32768 totalling 512.0KiB\n2020-06-25 16:43:54.414279: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 37632 totalling 588.0KiB\n2020-06-25 16:43:54.414303: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 2 Chunks of size 65536 totalling 128.0KiB\n2020-06-25 16:43:54.414328: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 14 Chunks of size 131072 totalling 1.75MiB\n2020-06-25 16:43:54.414353: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 24 Chunks of size 262144 totalling 6.00MiB\n2020-06-25 16:43:54.414377: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 15 Chunks of size 294912 totalling 4.22MiB\n2020-06-25 16:43:54.414403: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 447232 totalling 436.8KiB\n2020-06-25 16:43:54.414427: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 32 Chunks of size 524288 totalling 16.00MiB\n2020-06-25 16:43:54.414451: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 2 Chunks of size 798976 totalling 1.52MiB\n2020-06-25 16:43:54.414476: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 16 Chunks of size 1179648 totalling 18.00MiB\n2020-06-25 16:43:54.414499: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 33 Chunks of size 2097152 totalling 66.00MiB\n2020-06-25 16:43:54.414523: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 2294016 totalling 2.19MiB\n2020-06-25 16:43:54.414547: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 122 Chunks of size 2359296 totalling 274.50MiB\n2020-06-25 16:43:54.414571: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3070464 totalling 2.93MiB\n2020-06-25 16:43:54.414593: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3145728 totalling 3.00MiB\n2020-06-25 16:43:54.414616: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3266560 totalling 3.12MiB\n2020-06-25 16:43:54.414640: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 3400960 totalling 3.24MiB\n2020-06-25 16:43:54.414664: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 4 Chunks of size 4194304 totalling 16.00MiB\n2020-06-25 16:43:54.414701: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 23 Chunks of size 8388608 totalling 184.00MiB\n2020-06-25 16:43:54.414740: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 19 Chunks of size 33554432 totalling 608.00MiB\n2020-06-25 16:43:54.414765: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 45197824 totalling 43.10MiB\n2020-06-25 16:43:54.414791: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 56033280 totalling 53.44MiB\n2020-06-25 16:43:54.414833: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 9 Chunks of size 134217728 totalling 1.12GiB\n2020-06-25 16:43:54.414863: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 1 Chunks of size 158075648 totalling 150.75MiB\n2020-06-25 16:43:54.414887: I tensorflow/core/common_runtime/bfc_allocator.cc:917] 8 Chunks of size 1073741824 totalling 8.00GiB\n2020-06-25 16:43:54.414911: I tensorflow/core/common_runtime/bfc_allocator.cc:921] Sum Total of in-use chunks: 10.55GiB\n2020-06-25 16:43:54.414933: I tensorflow/core/common_runtime/bfc_allocator.cc:923] total_region_allocated_bytes_: 11330115840 memory_limit_: 11330115994 available bytes: 154 curr_region_allocation_bytes_: 17179869184\n2020-06-25 16:43:54.414960: I tensorflow/core/common_runtime/bfc_allocator.cc:929] Stats: \nLimit: 11330115994\nInUse: 11329592320\nMaxInUse: 11330112768\nNumAllocs: 1689\nMaxAllocSize: 1073741824\n\n2020-06-25 16:43:54.415055: W tensorflow/core/common_runtime/bfc_allocator.cc:424] ****************************************************************************************************\n2020-06-25 16:43:54.415121: W tensorflow/core/framework/op_kernel.cc:1651] OP_REQUIRES failed at concat_op.cc:153 : Resource exhausted: OOM when allocating tensor with shape[1,512,64,64] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bfc\n"
],
[
"",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
]
] |
ecaab7885a41a85739ac146ccaefc345cb209d10 | 11,181 | ipynb | Jupyter Notebook | jupyter_notebook/pytorch/60min_blitz/03_neural_networks_tutorial.ipynb | qiyuangong/Deep_Learning_Exercise | 47acbd76ea614bbb5fc0a1c878a08b8faf8fe1c0 | [
"MIT"
] | 3 | 2021-09-24T03:19:58.000Z | 2022-01-17T23:01:23.000Z | deep_learning_with_pytorch_a_60_minute_blitz/neural_networks_tutorial.ipynb | Ronalmoo/pytorch_tutorials | 962c256e41d0bdf1003d4f6f03445c9f151dcffc | [
"MIT"
] | null | null | null | deep_learning_with_pytorch_a_60_minute_blitz/neural_networks_tutorial.ipynb | Ronalmoo/pytorch_tutorials | 962c256e41d0bdf1003d4f6f03445c9f151dcffc | [
"MIT"
] | 2 | 2021-06-13T12:27:39.000Z | 2022-02-21T06:31:21.000Z | 59.791444 | 1,918 | 0.611484 | [
[
[
"%matplotlib inline",
"_____no_output_____"
]
],
[
[
"\nNeural Networks\n===============\n\nNeural networks can be constructed using the ``torch.nn`` package.\n\nNow that you had a glimpse of ``autograd``, ``nn`` depends on\n``autograd`` to define models and differentiate them.\nAn ``nn.Module`` contains layers, and a method ``forward(input)``\\ that\nreturns the ``output``.\n\nFor example, look at this network that classifies digit images:\n\n.. figure:: /_static/img/mnist.png\n :alt: convnet\n\n convnet\n\nIt is a simple feed-forward network. It takes the input, feeds it\nthrough several layers one after the other, and then finally gives the\noutput.\n\nA typical training procedure for a neural network is as follows:\n\n- Define the neural network that has some learnable parameters (or\n weights)\n- Iterate over a dataset of inputs\n- Process input through the network\n- Compute the loss (how far is the output from being correct)\n- Propagate gradients back into the network’s parameters\n- Update the weights of the network, typically using a simple update rule:\n ``weight = weight - learning_rate * gradient``\n\nDefine the network\n------------------\n\nLet’s define this network:\n\n",
"_____no_output_____"
]
],
[
[
"import torch\nimport torch.nn as nn\nimport torch.nn.functional as F\n\n\nclass Net(nn.Module):\n\n def __init__(self):\n super(Net, self).__init__()\n # 1 input image channel, 6 output channels, 3x3 square convolution\n # kernel\n self.conv1 = nn.Conv2d(1, 6, 3)\n self.conv2 = nn.Conv2d(6, 16, 3)\n # an affine operation: y = Wx + b\n self.fc1 = nn.Linear(16 * 6 * 6, 120) # 6*6 from image dimension \n self.fc2 = nn.Linear(120, 84)\n self.fc3 = nn.Linear(84, 10)\n\n def forward(self, x):\n # Max pooling over a (2, 2) window\n x = F.max_pool2d(F.relu(self.conv1(x)), (2, 2))\n # If the size is a square you can only specify a single number\n x = F.max_pool2d(F.relu(self.conv2(x)), 2)\n x = x.view(-1, self.num_flat_features(x))\n x = F.relu(self.fc1(x))\n x = F.relu(self.fc2(x))\n x = self.fc3(x)\n return x\n\n def num_flat_features(self, x):\n size = x.size()[1:] # all dimensions except the batch dimension\n num_features = 1\n for s in size:\n num_features *= s\n return num_features\n\n\nnet = Net()\nprint(net)",
"_____no_output_____"
]
],
[
[
"You just have to define the ``forward`` function, and the ``backward``\nfunction (where gradients are computed) is automatically defined for you\nusing ``autograd``.\nYou can use any of the Tensor operations in the ``forward`` function.\n\nThe learnable parameters of a model are returned by ``net.parameters()``\n\n",
"_____no_output_____"
]
],
[
[
"params = list(net.parameters())\nprint(len(params))\nprint(params[0].size()) # conv1's .weight",
"_____no_output_____"
]
],
[
[
"Let try a random 32x32 input.\nNote: expected input size of this net (LeNet) is 32x32. To use this net on\nMNIST dataset, please resize the images from the dataset to 32x32.\n\n",
"_____no_output_____"
]
],
[
[
"input = torch.randn(1, 1, 32, 32)\nout = net(input)\nprint(out)",
"_____no_output_____"
]
],
[
[
"Zero the gradient buffers of all parameters and backprops with random\ngradients:\n\n",
"_____no_output_____"
]
],
[
[
"net.zero_grad()\nout.backward(torch.randn(1, 10))",
"_____no_output_____"
]
],
[
[
"<div class=\"alert alert-info\"><h4>Note</h4><p>``torch.nn`` only supports mini-batches. The entire ``torch.nn``\n package only supports inputs that are a mini-batch of samples, and not\n a single sample.\n\n For example, ``nn.Conv2d`` will take in a 4D Tensor of\n ``nSamples x nChannels x Height x Width``.\n\n If you have a single sample, just use ``input.unsqueeze(0)`` to add\n a fake batch dimension.</p></div>\n\nBefore proceeding further, let's recap all the classes you’ve seen so far.\n\n**Recap:**\n - ``torch.Tensor`` - A *multi-dimensional array* with support for autograd\n operations like ``backward()``. Also *holds the gradient* w.r.t. the\n tensor.\n - ``nn.Module`` - Neural network module. *Convenient way of\n encapsulating parameters*, with helpers for moving them to GPU,\n exporting, loading, etc.\n - ``nn.Parameter`` - A kind of Tensor, that is *automatically\n registered as a parameter when assigned as an attribute to a*\n ``Module``.\n - ``autograd.Function`` - Implements *forward and backward definitions\n of an autograd operation*. Every ``Tensor`` operation creates at\n least a single ``Function`` node that connects to functions that\n created a ``Tensor`` and *encodes its history*.\n\n**At this point, we covered:**\n - Defining a neural network\n - Processing inputs and calling backward\n\n**Still Left:**\n - Computing the loss\n - Updating the weights of the network\n\nLoss Function\n-------------\nA loss function takes the (output, target) pair of inputs, and computes a\nvalue that estimates how far away the output is from the target.\n\nThere are several different\n`loss functions <https://pytorch.org/docs/nn.html#loss-functions>`_ under the\nnn package .\nA simple loss is: ``nn.MSELoss`` which computes the mean-squared error\nbetween the input and the target.\n\nFor example:\n\n",
"_____no_output_____"
]
],
[
[
"output = net(input)\ntarget = torch.randn(10) # a dummy target, for example\ntarget = target.view(1, -1) # make it the same shape as output\ncriterion = nn.MSELoss()\n\nloss = criterion(output, target)\nprint(loss)",
"_____no_output_____"
]
],
[
[
"Now, if you follow ``loss`` in the backward direction, using its\n``.grad_fn`` attribute, you will see a graph of computations that looks\nlike this:\n\n::\n\n input -> conv2d -> relu -> maxpool2d -> conv2d -> relu -> maxpool2d\n -> view -> linear -> relu -> linear -> relu -> linear\n -> MSELoss\n -> loss\n\nSo, when we call ``loss.backward()``, the whole graph is differentiated\nw.r.t. the loss, and all Tensors in the graph that has ``requires_grad=True``\nwill have their ``.grad`` Tensor accumulated with the gradient.\n\nFor illustration, let us follow a few steps backward:\n\n",
"_____no_output_____"
]
],
[
[
"print(loss.grad_fn) # MSELoss\nprint(loss.grad_fn.next_functions[0][0]) # Linear\nprint(loss.grad_fn.next_functions[0][0].next_functions[0][0]) # ReLU",
"_____no_output_____"
]
],
[
[
"Backprop\n--------\nTo backpropagate the error all we have to do is to ``loss.backward()``.\nYou need to clear the existing gradients though, else gradients will be\naccumulated to existing gradients.\n\n\nNow we shall call ``loss.backward()``, and have a look at conv1's bias\ngradients before and after the backward.\n\n",
"_____no_output_____"
]
],
[
[
"net.zero_grad() # zeroes the gradient buffers of all parameters\n\nprint('conv1.bias.grad before backward')\nprint(net.conv1.bias.grad)\n\nloss.backward()\n\nprint('conv1.bias.grad after backward')\nprint(net.conv1.bias.grad)",
"_____no_output_____"
]
],
[
[
"Now, we have seen how to use loss functions.\n\n**Read Later:**\n\n The neural network package contains various modules and loss functions\n that form the building blocks of deep neural networks. A full list with\n documentation is `here <https://pytorch.org/docs/nn>`_.\n\n**The only thing left to learn is:**\n\n - Updating the weights of the network\n\nUpdate the weights\n------------------\nThe simplest update rule used in practice is the Stochastic Gradient\nDescent (SGD):\n\n ``weight = weight - learning_rate * gradient``\n\nWe can implement this using simple python code:\n\n.. code:: python\n\n learning_rate = 0.01\n for f in net.parameters():\n f.data.sub_(f.grad.data * learning_rate)\n\nHowever, as you use neural networks, you want to use various different\nupdate rules such as SGD, Nesterov-SGD, Adam, RMSProp, etc.\nTo enable this, we built a small package: ``torch.optim`` that\nimplements all these methods. Using it is very simple:\n\n",
"_____no_output_____"
]
],
[
[
"import torch.optim as optim\n\n# create your optimizer\noptimizer = optim.SGD(net.parameters(), lr=0.01)\n\n# in your training loop:\noptimizer.zero_grad() # zero the gradient buffers\noutput = net(input)\nloss = criterion(output, target)\nloss.backward()\noptimizer.step() # Does the update",
"_____no_output_____"
]
],
[
[
".. Note::\n\n Observe how gradient buffers had to be manually set to zero using\n ``optimizer.zero_grad()``. This is because gradients are accumulated\n as explained in `Backprop`_ section.\n\n",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecaad64f510f061fae0f5b09a9d84eec2e9921b9 | 1,397 | ipynb | Jupyter Notebook | ui-tests/notebooks/Marker.ipynb | PROgram52bc/ipyleaflet | 284e0200a8d00ac2ef6f0ac957f13965af62160f | [
"MIT"
] | 903 | 2018-04-12T01:39:33.000Z | 2022-03-22T22:11:55.000Z | ui-tests/notebooks/Marker.ipynb | PROgram52bc/ipyleaflet | 284e0200a8d00ac2ef6f0ac957f13965af62160f | [
"MIT"
] | 620 | 2018-04-09T08:51:40.000Z | 2022-03-30T09:33:05.000Z | ui-tests/notebooks/Marker.ipynb | PROgram52bc/ipyleaflet | 284e0200a8d00ac2ef6f0ac957f13965af62160f | [
"MIT"
] | 253 | 2018-04-13T13:05:14.000Z | 2022-03-22T09:30:27.000Z | 23.283333 | 84 | 0.562634 | [
[
[
"from ipyleaflet import Map, Marker\n\ncenter = (52.204793, 360.121558)\n\nm = Map(center=center, zoom=15)\n\nmarker = Marker(location=center, draggable=True)\nm.add_layer(marker);\n\ndisplay(m)\n\n# Now that the marker is on the Map, you can drag it with your mouse,\n# it will automatically update the `marker.location` attribute in Python\n\n# You can also update the marker location from Python, that will update the\n# marker location on the Map:\nmarker.location = (50, 356)",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code"
]
] |
ecaaf0763b2422d8cf27c76424dd17455114d1cb | 256,201 | ipynb | Jupyter Notebook | notebooks/SIRmodel.ipynb | hunterecon2/epidemics | aef768b4e47c0dce21bd9d3b545b6b0e1b8534d3 | [
"MIT"
] | 1 | 2020-05-27T17:38:37.000Z | 2020-05-27T17:38:37.000Z | notebooks/SIRmodel.ipynb | hunterecon2/epidemics | aef768b4e47c0dce21bd9d3b545b6b0e1b8534d3 | [
"MIT"
] | 2 | 2020-04-01T20:08:05.000Z | 2020-04-19T15:28:47.000Z | notebooks/SIRmodel.ipynb | hunterecon2/epidemics | aef768b4e47c0dce21bd9d3b545b6b0e1b8534d3 | [
"MIT"
] | null | null | null | 282.159692 | 38,912 | 0.923861 | [
[
[
"## A simple Susceptible-Infected-Recovered (SIR) model\n\nThe SIR model is explained in many places (e.g. [here](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology#The_SIR_model)). Economists sometimes embed this in a larger economics model, for example this [NBER paper](https://www.nber.org/papers/w26902) working paper and references cited within. \n\nPython code below by Jonathan Conning, guided by this ['Coronavirus Curve - Numberphile](https://www.youtube.com/watch?v=k6nLfCbAzgo) video. If you're not doing so already you can run this as an interactive [web app](https://ricardian.herokuapp.com/). The notebook with code is [here](https://github.com/jhconning/Econ-Teach/blob/master/notebooks/epidemic/SIRmodel.ipynb)",
"_____no_output_____"
],
[
"### Model\nThe proportion of the population are infected $I_t$, susceptible $S$, and recovered $R$ evolve over time according to these equation swhich depend on the transmission rate $\\beta$ and the recovery rate $\\gamma$:\n\n$$\n\\begin{align}\n\\frac{dI}{dt} &= \\beta \\cdot S \\cdot I - \\gamma \\cdot I \\\\\n\\frac{dS}{dt} &=-\\beta \\cdot S \\cdot I \\\\\n\\frac{dR}{dt} &= \\gamma \\cdot I\n\\end{align}\n$$\n",
"_____no_output_____"
]
],
[
[
"import numpy as np\nimport matplotlib.pyplot as plt\nfrom scipy.integrate import odeint\nfrom ipywidgets import interact",
"_____no_output_____"
],
[
"N = 1 # Size of the population (so everything in proportions)\nI0 = 0.01 # Initial proportion of the population infected\nS0 = N - I0 # Initial proportion of the population susceptible\nR0 = 0.0 # Initial proportion of the population recovered\nmaxT = 25 # max number of periods in simulation\n\nbeta = 0.5 # transmission rate\ngamma = 0.1 # recovery rate",
"_____no_output_____"
],
[
"def SIR(y, t, beta, gamma):\n '''the SIR model'''\n S, I, R = y\n dSdt = -beta*S*I\n dIdt = beta*S*I - gamma*I\n dRdt = gamma*I\n return([dSdt, dIdt, dRdt])",
"_____no_output_____"
],
[
"def plotSIR(beta = beta, gamma = gamma, maxT = maxT):\n '''Solve differential equations in SIR and plot'''\n t = np.linspace(0, maxT, 1000)\n soln = odeint(SIR,[S0,I0,R0], t, args=(beta, gamma))\n soln = np.array(soln)\n plt.figure(figsize=[8,6])\n\n plt.plot(t, soln[:,0], linewidth=3, label = 'S(t)')\n plt.plot(t, soln[:,1], linewidth=3, label = 'I(t)')\n plt.plot(t, soln[:,2], linewidth=3, label = 'R(t)')\n plt.grid()\n plt.legend()\n plt.xlabel(\"Time\")\n plt.ylabel(\"proportions\")\n plt.title(\"SIR model\")\n plt.show()",
"_____no_output_____"
]
],
[
[
"Change the parameters with the sliders below (you'll only have interactivity with a running jupyter notebook server).",
"_____no_output_____"
]
],
[
[
"interact(plotSIR, beta=(0,1,0.05), gamma=(0,1,0.05), maxT=(5,100,5));",
"_____no_output_____"
]
],
[
[
"Below is a plot with the default parameters ($\\beta=0.5$, $\\gamma=0.1$) to have a graphic in case widget above does not display.",
"_____no_output_____"
]
],
[
[
"plotSIR(beta, gamma, maxT)",
"_____no_output_____"
]
],
[
[
"# A More complex model\n\n## In this model, social distancing for all can be counterproductive!\n\nOne feature of the Coronavirus is that some cases are almost Asymptomatic. In general, these cases recover faster. Also, one might expect that these cases move faster to begin with. How would we do this? Let's make a model in which ",
"_____no_output_____"
],
[
"$$\n\\begin{align}\n\\frac{dI}{dt} &= \\beta \\cdot S \\cdot I - \\gamma \\cdot I \\\\\n\\frac{dS}{dt} &=-\\beta \\cdot S \\cdot I \\\\\n\\frac{dR}{dt} &= \\gamma \\cdot I\n\\end{align}\n$$",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
]
] |
ecaaf8e28bb348a419e6f50b1cea8c405fe04cf9 | 21,984 | ipynb | Jupyter Notebook | OptimizationMethod/Optimization and Heuristics.ipynb | johnnychiuchiu/Machine-Learning | 0fd6fd2c08025134cf7d20b245c39f82d5453e14 | [
"MIT"
] | 13 | 2018-03-19T18:16:03.000Z | 2022-03-22T03:44:13.000Z | OptimizationMethod/Optimization and Heuristics.ipynb | johnnychiuchiu/Machine-Learning | 0fd6fd2c08025134cf7d20b245c39f82d5453e14 | [
"MIT"
] | null | null | null | OptimizationMethod/Optimization and Heuristics.ipynb | johnnychiuchiu/Machine-Learning | 0fd6fd2c08025134cf7d20b245c39f82d5453e14 | [
"MIT"
] | 7 | 2018-01-11T04:03:11.000Z | 2021-01-22T07:56:42.000Z | 41.40113 | 721 | 0.606032 | [
[
[
"# Optimization",
"_____no_output_____"
],
[
"**Outline**\n\n* [Introduction](#intro)\n* [Linear Programming](#lp)\n * [Brewer's Problem](#example1)\n * [Shadow Price](#shadow)\n * [Implementation using python Pulp](#exmaple1_implement)\n * [Dual Problem](#dual) \n * [Simplified Shelf Space Problem](#example2)\n* [Some Tips and Definitions](#tips)\n* [Piecewise Linear Programming](#piecewise)\n* [Reference](#reference)",
"_____no_output_____"
],
[
"**Disclaimer**\n\nThis is a note taken from 2018 Fall MSiA 440 Optimization class - Prof. Michael S. Watson. Hence, many of the content below can be copied directly from the class material",
"_____no_output_____"
],
[
"---",
"_____no_output_____"
],
[
"## <a id=\"intro\">Introduction</a>",
"_____no_output_____"
],
[
"This is the [definition from wikipedia](https://en.wikipedia.org/wiki/Constrained_optimization)\n\n\n> In mathematical optimization, **constrained optimization** (in some contexts called constraint optimization) is the process of optimizing an objective function with respect to some variables in the presence of constraints on those variables. The objective function is either a cost function or energy function, which is to be minimized, or a reward function or utility function, which is to be maximized. Constraints can be either **hard constraints**, which set conditions for the variables that are required to be satisfied, or **soft constraints**, which have some variable values that are penalized in the objective function if, and based on the extent that, the conditions on the variables are not satisfied.",
"_____no_output_____"
],
[
"## <a id='lp'>Linear Programming</a>",
"_____no_output_____"
],
[
"> **What is it?**\n\n* Quintessential tool for optimal allocation of scarce resources, among a number of competing activities Powerful and general problem-solving method\n* Linear Programming is a optimization method, a method to achieve the best outcome (such as maximum profit or lowest cost) in a mathematical model whose requirements are represented by linear relationships.\n\n\n> **Why significant?**\n\n* One of the most important mathematical techniques of the 20th century (Nobel Prize in Economics in 1975)\n* Fast commercial solvers\n* Powerful modeling languages\n* Embedded in many types of applications\n* Forms the basis of Integer, Non-Linear Programming, and Heuristics\n* Widely applicable to industry (When someone mentions “optimizing” a process, chances are they are referring to LP Probably used somewhere in the companies you are associated with)\n* When the term “linear programming” was coined, the term “programming” referred to planning or scheduling within a large organization. It has nothing to do with what we now call computer programming.",
"_____no_output_____"
],
[
"> **How Do you Create a Linear Programming Optimization Model?**\n\n* Take your real business problems and challenges...\n* ...and break down your problem so you can model it...\n * Objective\n * Decisions\n * Constraints\n* ...and use this to create a set of equations that become your model.\n\n\\begin{aligned}&{\\text{Maximize}}&&\\mathbf {c} ^{\\mathrm {T} }\\mathbf {x} \\\\&{\\text{subject to}}&&A\\mathbf {x} \\leq \\mathbf {b} \\\\&{\\text{and}}&&\\mathbf {x} \\geq \\mathbf {0} \\end{aligned}",
"_____no_output_____"
],
[
"> **The Components of an Optimization Problem are Worth Repeating**\n\n* What makes one choice better than another? What **target** should be used to compare one set of choices to another? What is the **objective**? \n * Objectives can be costs, revenue, profit, service, others... \n* What **resources** need to managed? How are they **limited**? What are the **constraints**? \n* What **choices** need to be in order to manage these resources? What are the **decision variables**?",
"_____no_output_____"
],
[
"> **Notes About Linear Programs**\n\n* Have to be linear\n * Objective function and constraints must be written as linear equations\n * You can’t multiple decision variables together\n * You can’t divide by decision variables\n * You can’t use if-statements. (I’m going to have you get started in Excel to build intuition– you really don’t want to use any formula in Excel except adding and multiplying by constants.\n\n* The “linear” assumption seems to be limited\n * Let’s make sure we can do this before we try to tackle this assumption!\n\n* Note: We can solve these problems! Two choices:\n * Choice One: You might have to make some assumptions or create work-arounds because of linear assumptions, but you get a reliable answer\n * Choice Two: You don’t use limiting linear assumptions, but you don’t have a way to solve the problem\n* I think you’ll find: the linear assumptions aren’t so bad!\n",
"_____no_output_____"
],
[
"> <a id='example1'>**Brewers Problem**</a>\n\nLet's use a simple example to get a feeling of it! Here we go:\n\nYou are the owner of a small brewery. Since it's just the start of the business, we want to focus on brew 2 types of beer: Ale & Pilsner. These 2 types of beer would yield differet profit, also they need different combination of raw materials to brew it. \n\nThe goal here is to decide how many Ale & Pilsner we want to make in order to have the maximum profit, assuming the only constraints here are raw materials. Here is the information\n\n|Type| Corn(pounds) | Hops(ounces) | Malt(pounds) | Profit($) |\n|------|------|------|\n| Ale | 5 | 4 | 35 | 13 |\n| Pilsner | 15 | 4 | 20 | 23 |\n| Limit | 480 | 160 | 1190 | |",
"_____no_output_____"
],
[
"Let's change this problem into something we can model. Assume the number of Ale produced is **A** and the number of Pilsner produced is **B**\n\n* **Objective**:\n$$\\text{maximize 23A+13B}$$\n\n* **Constraints**\n$$\\begin{aligned}&{\\text{Corn: 5A + 15B <= 480}} \\\\&{\\text{Hops: 4A + 4B <= 160}} \\\\&{\\text{Malt: 35A + 20B <= 1190}}\\end{aligned}$$\n\n* **Decisions**:\n\\begin{cases}\n A = ? \\\\\n B = ?\n \\end{cases}",
"_____no_output_____"
],
[
"> **<a id='shadow'>Shadow Price</a>**",
"_____no_output_____"
],
[
"In many occasions, we may want to know \"what if we have 10 more punds of Corn? How much it would effect our profit?\" or simply \"How much of each of the raw material that we should get more in order to earn more?\"\n\n**Shadow price** can tell us this type of information. It is defined as the __*marginal increase of the objective when the constraint is relaxed by 1 unit*__.\n\nNote:\n* Work for Linear Programs (not Integer)\n* Provide information on the impact to the objective value of small changes to the constraint (or right hand side)\n* show which constraint is tight constraint\n* Can provide value on the relative value of relaxing tight constraints\n* Does not necessarily\n * Provide information on multiple changes at once (should we use all the budget to get Hops or should we get more Hops and some Corn?)\n * Provide information on large changes (should we get 1000 more corns?)\n \nComments on Shadow price:\n* If you know about Linear Programming, you should know about Shadow Prices and Dual Problems\n * Everyone covers it in the classroom\n * The shadow prices can be useful (see below)\n * Sometimes the dual problem has a more intuitive interpretation\n * Some sophisticated algorithms take advantage of dual problems- you should know they exist and what they mean\n\nBut...\n* Shadow prices are only for small changes and for linear programs (and most problems have integer variables)\n* This was a lot more useful when computing power was at a premium and linear programs ran slow (remember, since 1988 LP’s are more than 5 million times faster!!)\n* People are finding that is easier to just run a variety of what-if scenarios\n",
"_____no_output_____"
],
[
"> **<a id='example1_implement'>Implement using Pulp from Python</a>**",
"_____no_output_____"
]
],
[
[
"# This model separates the data from the optimization model\nfrom pulp import *\n\n#Create a list of all the products\nProducts = [\"Ale\",\"Pilsner\"]\n\n#Create a dictionary of the prices for products\nPrices = {\"Ale\": 13,\n \"Pilsner\": 23}\n\n#Create a list of all the raw materials\nRawMaterials = [\"Corn\",\"Hops\",\"Malt\"]\n\n#Create a Dictionary of Amount of each Raw Material Available\nRawAvailability = {\"Corn\": 480,\n \"Hops\": 160,\n \"Malt\": 1190}\n\n#Create a list for amount used of each raw material for each product\nAmountUsed = {\"Ale\": {\"Corn\": 5, \"Hops\": 4, \"Malt\": 35},\n \"Pilsner\":{\"Corn\": 15, \"Hops\": 4, \"Malt\": 20}\n }",
"_____no_output_____"
],
[
"# Create the 'prob' variable to contain the problem data\nprob = LpProblem(\"Ale and Pilsner\",LpMaximize)\n\n# Create --decision variables--\nproduct_vars = LpVariable.dicts(\"Prods\",Products,lowBound=0,upBound=None,cat=LpContinuous)\n\n# The --objective function-- is added to 'prob' first\nprob += lpSum([Prices[i]*product_vars[i] for i in Products]), \"Total Revenue of Production Plan\"\n\n# We can enter the --constraints-- that relate to limited amount of material\nfor r in RawMaterials:\n prob += lpSum([product_vars[i]*AmountUsed[i][r] for i in Products]) <= RawAvailability[r], r\n \n# The problem data is written to an .lp file\nprob.writeLP(\"BeerAle.lp\")\n\n# The problem is solved using PuLP's choice of Solver\nprob.solve()\n\n# The status of the solution is printed to the screen\nprint(\"Status:\", LpStatus[prob.status])\n\n# Each of the variables is printed with it's resolved optimum value\nfor v in prob.variables():\n print(v.name, \"=\", v.varValue)\n \n# The optimised objective function value is printed to the screen\nprint(\"Total Revenue of Plan = \", value(prob.objective))\n\nfor constraint in prob.constraints:\n # print(prob.constraints[constraint].name, prob.constraints[constraint].value() - prob.constraints[constraint].constant)\n print(prob.constraints[constraint].name,\"Remaining Slack\" , prob.constraints[constraint].value()) \n print(prob.constraints[constraint].name,\"Original RHS Value\" , prob.constraints[constraint].constant)\n print(prob.constraints[constraint].name,\"Shadow Price\" , prob.constraints[constraint].pi) ",
"Status: Optimal\nProds_Ale = 12.0\nProds_Pilsner = 28.0\nTotal Revenue of Plan = 800.0\nCorn Remaining Slack 0.0\nCorn Original RHS Value -480\nCorn Shadow Price 1.0\nHops Remaining Slack 0.0\nHops Original RHS Value -160\nHops Shadow Price 2.0\nMalt Remaining Slack -210.0\nMalt Original RHS Value -1190\nMalt Shadow Price -0.0\n"
],
[
"prob",
"_____no_output_____"
]
],
[
[
"The result indicats that we should brew 13 barrels of Ale and 23 barrels of Pilzner, and this would yield the maximum revenue of 800. As for the raw materials, we would use all the corn and hops, but still have 210 pounds of Malt left.\n\nIn term of the raw material, if we still have budget, our first priority is to get more Hops.\n\nIn reality, there might be many other constraints come into play, such as\n* **Time**: maybe pilsner can be done faster than Ale, and we need to hand in our products within certain amount of time. \n* **Laber**: there may be only a certain people know how to brew ale.\n* **Demand**: Pilsner may be less popular than Ale, we may over produce it if we don't take this into account.\n* **Budget**: the factory would must have the total amount of money that they can spend\n* **Space**: Maybe the factory don't have so much space to put all the barrels.\n* **Other**",
"_____no_output_____"
],
[
"> **<a id='dual'>Dual Problems</a>**\n\nEvery Linear Program has a Dual. In rough terms, the dual problem is the reverse of the Primal (Think of the original Linear Program as the Primal). The constraints become decision variables, the decision variables become constraints.\n\nHere shows the duality of brewer's problem:\n\n<img src=\"_pic/duality.png\" style=\"width: 500px;height: 350px;\"/>",
"_____no_output_____"
],
[
"> **<a id='example2'>Simplified Shelf Space Problem using Open Solver</a>**",
"_____no_output_____"
],
[
"In a supermarker, since people's decision would be effect by where the product is located, it naturally make sense that how the product is located would effect the final profit.\n\nIn this model we want to determine which product will go onto which slot on the shelf. For each product, at each location, you know the expected daily profit as seen in this table.\n\n<img src=\"_pic/ShelfSpaceTable.png\" style=\"width: 800px;height: 200px;\"/>\n\nWe need to determine what product should be slotted in which location. Only one product can go in each location and each product can only be slotted once.\n\nDetermine the profit if each item was slotted in its best possible location- not considering the overall feasibility of the solution. What does this number tell you from a business point of view?\n\nThe complete solution can be found [here in the google sheet](https://docs.google.com/spreadsheets/d/1Ey6uk2G4d2GYWT3bP6sIrPvSIsb9f9S__n9KQ3Tuv3k/edit?usp=sharing).",
"_____no_output_____"
],
[
"## <a id='tips'>Some Tips and Definitiion</a> ",
"_____no_output_____"
],
[
"> **Tips**\n\n* Optimization Approaches: Getting The True Optimal Answer\n * **Enumeration**: when doing optimization problems, make sure we give user choices by listing out all the possible solutions and pick the best one\n * Pro’s\n * Easy\n * Works for small problems\n * Can help you explicit trade-offs\n * Con’s\n * Fails completely when the solution set is large. \n * And, may real world problems have so many possible solutions, that enumeration is impossible\n * **Mathematical Optimization**: formulate the problem in the language of mathematics and use an approach that leads to a provable optimal solution\n * Pro’s\n * Can solve large problems\n * Guaranteed optimal solution\n * Robust with new constraints, variables, and data\n * Con’s\n * You have to be able to formulate the problem and may need to make assumptions to do so\n * Can be slow ",
"_____no_output_____"
],
[
"> **Definition**\n\n* **Integer Programming**: like linear programming, except some of the variables can be forced to be binary– 0 or 1, or just an integer value\n * Where it seems like you would need integer variables\n * You must make an integer amount of product (120 cans, not 120.2)\n * You must order an integer amount of coils (263 vs 262.5)\n * You must order an integer amount of food (depending on how it is packaged)\n * Or, maybe you just don’t like to see decimal amounts \n * And, many more cases...\n * Surprisingly, this is not the real reason IP exists. And, this use of IP usually makes the problems much harder, with limited benefits\n * Problems with IP:\n * We can not solve IP’s as fast as LP’s.\n * Problem is worse than not being just as fast\n * At the risk of oversimplifying, there are two basic type of optimization problems P and NP-Complete\n * We cannot solve IP’s as large as LP’s.\n * We do not get the sensitivity results for IP’s we get for LP’s.\n* **Non-Linear Optimization**: For some non-linear equations, there are techniques for finding the best solutions (think of the derivative in your Calculus class)\n * For some specific problems, there are other techniques\n * Options pricing\n * Queuing theory\n",
"_____no_output_____"
],
[
"## <a id='piecewise'>Piecewise Linear Programming</a>",
"_____no_output_____"
],
[
"Linear programming is good, but it's still linear. Linear formulations can be good approximations. To capture some aspects of the problem that follow cost structure as a curve, we can formulate the problem as piece-wise linear programs. \n\nHere we want to illustrate using a simple example.\n\n* Company buys slabs of raw steel, does minor processing and resells the slabs\n* They can sell for $5.50 per slab\n* They have a budget of \\$3,000 to buy slabs\n* They can buy slabs at the following prices\n\n<img src=\"_pic/piecewise.png\" style=\"width: 400px;height: 120px;\"/>\n\nThe solution can be found here: \n* [Case 1](https://docs.google.com/spreadsheets/d/1Ey6uk2G4d2GYWT3bP6sIrPvSIsb9f9S__n9KQ3Tuv3k/edit#gid=2125242938)\n* [Case 2](https://docs.google.com/spreadsheets/d/1Ey6uk2G4d2GYWT3bP6sIrPvSIsb9f9S__n9KQ3Tuv3k/edit#gid=610776840)\n\n",
"_____no_output_____"
],
[
"## <a id=\"reference\">Reference</a>\n\n* [OpenSolver Website](https://opensolver.org/)\n* [Youtube: Linear Programming - Shadow Price, Slack/Surplus calculations](https://www.youtube.com/watch?v=uaxOfTIC_pI)",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
]
] |
ecab033822779d6f6949d3c32e73fea168a47cff | 1,649 | ipynb | Jupyter Notebook | Markdown_Files/Text_Cleaning/Text Processing.ipynb | DSEI21000-S21/project-product-price-prediction | b98bff46e882de0ac1dade525a14beeaea224ffc | [
"MIT"
] | 1 | 2021-04-26T20:48:43.000Z | 2021-04-26T20:48:43.000Z | Markdown_Files/Text_Cleaning/Text Processing.ipynb | ZhiLi51/project-product-price-prediction | bbd1eb9577b40fcb538a6b33f5ba71096b5af72f | [
"MIT"
] | 20 | 2021-04-23T22:54:53.000Z | 2021-05-10T01:36:52.000Z | Markdown_Files/Text_Cleaning/Text Processing.ipynb | ZhiLi51/project-product-price-prediction | bbd1eb9577b40fcb538a6b33f5ba71096b5af72f | [
"MIT"
] | 2 | 2021-04-26T20:48:55.000Z | 2021-05-21T00:47:11.000Z | 26.596774 | 166 | 0.624015 | [
[
[
"# Text Data Cleaning ",
"_____no_output_____"
],
[
"We built a function called `cleaning_text` which does the following steps in sequence:\n\n1. Standardize all text to its lower case\n2. Use the re package to extract only characters and numbers and remove any special characters and emoji\n3. Use the NLTK stopwords package to remove stop word and non-alphabetical words\n4. Use the WordNetLemmatizer package to reduce word to its root form\n5. Use the string package to replace all punctuation by white space\n\nThis function takes an input column of a dataframe, perform all the five steps mentioned above sequentially, and output a cleaner version of the input feature. ",
"_____no_output_____"
]
]
] | [
"markdown"
] | [
[
"markdown",
"markdown"
]
] |
ecab12e8196d5c48bdb9af7f3bd5a492b81621a3 | 18,137 | ipynb | Jupyter Notebook | libretas/1a_perceptron.ipynb | bereml/iap | 42b51fd2b9fdd6821acaabbbe4d0080538162813 | [
"MIT"
] | 6 | 2021-02-13T14:09:57.000Z | 2021-12-14T04:26:35.000Z | libretas/1a_perceptron.ipynb | bereml/iap-21-2 | 42b51fd2b9fdd6821acaabbbe4d0080538162813 | [
"MIT"
] | null | null | null | libretas/1a_perceptron.ipynb | bereml/iap-21-2 | 42b51fd2b9fdd6821acaabbbe4d0080538162813 | [
"MIT"
] | 1 | 2021-05-27T06:15:02.000Z | 2021-05-27T06:15:02.000Z | 29.300485 | 736 | 0.478745 | [
[
[
"<a href=\"https://colab.research.google.com/github/bereml/iap/blob/master/libretas/1a_perceptron.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
],
[
"# Neuronas artificiales\n\nCurso: [Introducción al Aprendizaje Profundo](http://turing.iimas.unam.mx/~ricardoml/course/iap/). Profesores: [Bere](https://turing.iimas.unam.mx/~bereml/) y [Ricardo](https://turing.iimas.unam.mx/~ricardoml/) Montalvo Lezama.\n\n---\n---\n\nLa neurona artificial es un modelo simplificado de la neurona natural que trata de imitar 3 aspectos principales: \n\n1. La fuerza sináptica que pondera los impulsos recibidos\n2. La acumulación de estos impulsos ponderados \n3. La activación de la neurona que produce un impulso de respuesta a su salida. \n\nLa primera neurona artificial fue la llamada Unidad de Umbral Lineal propuesta en 1943 por Warren McCulloch y Walter Pitts. Este modelo presupone que tanto los valores de los atributos de entrada como los valores de salida son binarios.",
"_____no_output_____"
]
],
[
[
"# arreglos multidimensionales\nimport numpy as np",
"_____no_output_____"
]
],
[
[
"## Unidad de umbral lineal\nLa operación que lleva a cabo una neurona artificial está dada por la suma pesada evaluada en una función de activación $\\phi$. Una de las primeras funciones de activación utilizadas fue la escalón unitario, definida como\n\n$\n\\phi(x) = \\begin{cases} 1, & \\text{si } x > 0\\\\0, & \\text{en caso contrario}\\end{cases}\n$\n\nEsta se puede implementar en Python de la siguiente manera:",
"_____no_output_____"
]
],
[
[
"def step(z):\n \"\"\"Computes step function.\"\"\"\n return 1.0 if z > 0 else 0.0",
"_____no_output_____"
]
],
[
[
"Por su parte, la suma pesada simplemente consiste en multiplicar cada entrada por su correspondiente peso y sumarle el sesgo. Esto lo podemos expresar como\n\n$\nz = w_1 \\cdot x_1 + w_2 \\cdot x_2 + \\cdots + w_d \\cdot x_d + b \n$\n\nEn su forma vectorial\n\n$\nz = \\mathbf{w}^T \\mathbf{x} + b\n$\n\nPara realizar esto en Python, podemos usar la función [`np.dot`](https://numpy.org/doc/stable/reference/generated/numpy.dot.htmlhttps://www.reddit.com/r/nvidia/comments/lri6as/did_newegg_leak_the_msi_3060_or_was_this_already/https://www.reddit.com/r/nvidia/comments/lri6as/did_newegg_leak_the_msi_3060_or_was_this_already/) de Numpy de la siguiente manera `z = np.dot(w.T, x) + b`. Así, la operación de la neurona completa sería:",
"_____no_output_____"
]
],
[
[
"def neuron(x, w, b):\n \"\"\"Returns forward pass as step(`w`·`x`+`b`).\"\"\"\n # preactivación\n z = np.dot(w.T, x) + b\n # activación\n a = step(z)\n return a",
"_____no_output_____"
]
],
[
[
"### Compuerta AND ($\\land$)\nEsta neurona es capaz de aproximar el operador AND, cuya salida es 1 cuando ambas entradas son 1:\n\n| $x_1$ | $x_2$ | $y$ |\n|-------|-------|-----|\n| 0 | 0 | 0 |\n| 0 | 1 | 0 |\n| 1 | 0 | 0 |\n| 1 | 1 | 1 |\n\nLa neurona recibe 2 valores binarios como entrada y produce un valor binario como salida. Específicamente, la neurona calcularía\n\n$\\hat{y} = \\phi(w_1 \\cdot x_1 + w_2 \\cdot x_2 + b)$\n\nPara poder aproximar la operación AND es necesario encontrar los valores apropiados de $w_1$, $w_2$ y $b$. Una posible elección sería 10, 10 y -15 respectivamente. Verifiquemos estos valores:",
"_____no_output_____"
]
],
[
[
"# tabla de verdad\nX = np.array([\n [0., 0.], \n [0., 1.], \n [1., 0.], \n [1., 1.]\n])\n\n# pesos y sesgo para AND\nw = np.array([10, 10]).T\nb = -15\n\n# predicción por cada ejemplo\nprint('-----------------------------')\nprint('x_1 \\tx_2 \\ty_hat')\nprint('-----------------------------')\nfor i in range(X.shape[0]):\n x1, x2 = x = X[i]\n y_hat = neuron(x, w, b)\n print(f'{x1}\\t{x2}\\t{y_hat}')",
"-----------------------------\nx_1 \tx_2 \ty_hat\n-----------------------------\n0.0\t0.0\t0.0\n0.0\t1.0\t0.0\n1.0\t0.0\t0.0\n1.0\t1.0\t1.0\n"
]
],
[
[
"### Participación: Compuerta OR ($\\lor$)\n\nPropon y evalua un conjunto de pesos y sesgo para aproximar la operación OR.\n\n| $x_1$ | $x_2$ | $y$ |\n|-------|-------|-----|\n| 0 | 0 | 0 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 1 |",
"_____no_output_____"
],
[
"### Participación: Compuerta NAND \nPropon y evalua un conjunto de pesos y sesgo para aproximar la operación NAND.\n\n| $x_1$ | $x_2$ | $y$ |\n|-------|-------|-----|\n| 0 | 0 | 1 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 0 |",
"_____no_output_____"
],
[
"## Algoritmo del perceptrón",
"_____no_output_____"
]
],
[
[
"def perceptron_algorithm(X, y, n_epochs=10):\n \n # inicilizamos los pesos y sesgo\n w_new = np.zeros(X.shape[1])\n b_new = 0\n \n # entrenamiento por un numero fijo de épocas\n for i in range(n_epochs):\n \n # error total\n total_error = 0.0\n \n # por cada ejemplo computamos \n # nuevos pesos y sesgo\n for j in range(X.shape[0]):\n \n # guadamos los anteriores\n w_old = w_new\n b_old = b_new\n \n # computamos la predicción y error\n y_hat = neuron(X[j], w_old, b_old)\n error = y[j] - y_hat\n \n # compuamos nuevos pesos y sesgo\n w_new = w_old + error * X[j]\n b_new = b_old + error\n\n # agragmos al error total\n total_error += np.abs(error)\n\n #imprimos el error de la época\n total_error /= float(X.shape[0])\n print(f\"Epoch {i}: error = {total_error}\")\n\n # regresamos pesos y sesgo aprendidos\n return w_new, b_new",
"_____no_output_____"
]
],
[
[
"### Aprendiendo la operación OR",
"_____no_output_____"
],
[
"Probemos el algoritmo del perceptrón para aprender la operación lógica OR.",
"_____no_output_____"
]
],
[
[
"# salida para OR\ny_or = np.array([0., 1., 1., 1.]) \n\n# aprendizaje de pesos y sesgo\nw, b = perceptron_algorithm(X, y_or)\n\n# predicción por cada ejemplo\nprint('\\nw_1 = {0}, w_2 = {1}, b = {2}'.format(w[0], w[1], b))\nprint('-----------------------------')\nprint('x_1 \\tx_2 \\t y\\ty_hat')\nprint('-----------------------------')\nfor i in range(X.shape[0]):\n x1, x2 = x = X[i]\n y_hat = neuron(x, w, b)\n print(f'{x1}\\t{x2}\\t{y_or[i]}\\t{y_hat}')",
"Epoch 0: error = 0.25\nEpoch 1: error = 0.5\nEpoch 2: error = 0.25\nEpoch 3: error = 0.0\nEpoch 4: error = 0.0\nEpoch 5: error = 0.0\nEpoch 6: error = 0.0\nEpoch 7: error = 0.0\nEpoch 8: error = 0.0\nEpoch 9: error = 0.0\n\nw_1 = 1.0, w_2 = 1.0, b = 0.0\n-----------------------------\nx_1 \tx_2 \t y\ty_hat\n-----------------------------\n0.0\t0.0\t0.0\t0.0\n0.0\t1.0\t1.0\t1.0\n1.0\t0.0\t1.0\t1.0\n1.0\t1.0\t1.0\t1.0\n"
]
],
[
[
"### Aprendiendo la operación AND\nAhora veamos qué ocurre si en lugar de la operación OR tratamos de aprender la operación AND",
"_____no_output_____"
]
],
[
[
"# salida de AND\ny_and = np.array([0., 0., 0., 1.])\n\n# aprendizaje de pesos y sesgo\nw, b = perceptron_algorithm(X, y_and)\n\nprint('\\nw_1 = {0}, w_2 = {1}, b = {2}'.format(w[0], w[1], b))\nprint('-----------------------------')\nprint('x_1 \\tx_2 \\t y\\ty_hat')\nprint('-----------------------------')\nfor i in range(X.shape[0]):\n x1, x2 = x = X[i]\n y_hat = neuron(x, w, b)\n print(f'{x1}\\t{x2}\\t{y_and[i]}\\t{y_hat}')",
"Epoch 0: error = 0.25\nEpoch 1: error = 0.75\nEpoch 2: error = 0.75\nEpoch 3: error = 0.5\nEpoch 4: error = 0.25\nEpoch 5: error = 0.0\nEpoch 6: error = 0.0\nEpoch 7: error = 0.0\nEpoch 8: error = 0.0\nEpoch 9: error = 0.0\n\nw_1 = 2.0, w_2 = 1.0, b = -2.0\n-----------------------------\nx_1 \tx_2 \t y\ty_hat\n-----------------------------\n0.0\t0.0\t0.0\t0.0\n0.0\t1.0\t0.0\t0.0\n1.0\t0.0\t0.0\t0.0\n1.0\t1.0\t1.0\t1.0\n"
]
],
[
[
"## Aproximando funciones no lineales: XOR ($\\oplus$)\nMinsky y Papert mostraron que una neurona del tipo LTU no puede aproximar de forma precisa una función no lineal como la compuerta XOR ($\\oplus$):\n\n| $x_1$ | $x_2$ | $y$ |\n|-------|-------|-----|\n| 0 | 0 | 0 |\n| 0 | 1 | 1 |\n| 1 | 0 | 1 |\n| 1 | 1 | 0 |\n\nSin embargo, es posible aproximar este tipo combinando múltiples LTU conectadas en red. Por ejemplo, es posible llevar a cabo la operación XOR con operaciones OR, AND y NAND en la siguiente ecuación:\n\n$x_1 \\mathbin{\\oplus} x_2 = (x_1 \\lor x_2) \\land \\neg(x_1 \\land x_2)$\n\nque podemos diagramar de la siguiente forma:\n\n\n<img src=\"https://raw.githubusercontent.com/bereml/iap/master/fig/xor.svg\" width=\"350\"> \n\nEsto lo llevamos a cabo con la siguiente función:",
"_____no_output_____"
]
],
[
[
"# vectorizamos la función para que\n# aplique a un arreglo de entradas\nstep_vec = np.vectorize(step)\n\n# red con dos capas\n# capa 1: OR y NAND\n# capa 2: AND\ndef multi_layer(x, W1, b1, W2, b2):\n # capa 1\n z1 = np.dot(W1.T, x) + b1\n a1 = step_vec(z1)\n # capa 2\n z2 = np.dot(W2.T, a1) + b2\n a2 = step_vec(z2)\n return a2",
"_____no_output_____"
]
],
[
[
"Encontrando los valores de pesos y sesgos adecuados, podemos usar esta función para aproximar la operación XOR. Ya hemos encontrado los pesos y sesgos para las operaciones OR, AND y NAND, por lo que podemos usar estas neuronas con sus correspondientes pesos y sesgos. La red tendría 2 neuronas conectadas a las entradas que realizan las operaciones OR ($w_{11}^{\\{1\\}} = 10$, $w_{12}^{\\{1\\}} = 10$ y $b_1^{\\{1\\}} = -5$) y NAND ($w_{21}^{\\{1\\}} = -10$, $w_{22}^{\\{1\\}} = -10$ y $b_2^{\\{1\\}} = 15$) respectivamente. La salida de estas 2 neuronas estarían conectadas a una tercera neurona que realiza la operacioón AND ($w_{11}^{\\{2\\}} = 10$, $w_{12}^{\\{2\\}} = 10$ y $b_1^{\\{2\\}} = -15$). En su forma matricial:\n\n$$\n\\mathbf{W}^{\\{1\\}} = \\left[\\begin{matrix} \n10 & -10\\\\\n10 & -10\n\\end{matrix}\\right] \n$$\n\n$$\n\\mathbf{b}^{\\{1\\}} = \\left[\\begin{matrix} \n-5 \\\\\n15\n\\end{matrix}\\right] \n$$\n\n$$\n\\mathbf{W}^{\\{2\\}} = \\left[\\begin{matrix} \n10\\\\\n10\n\\end{matrix}\\right] \n$$\n\n$$\n\\mathbf{b}^{\\{2\\}} = \\left[\\begin{matrix} \n-15\\\\\n\\end{matrix}\\right] \n$$",
"_____no_output_____"
]
],
[
[
"# salida de XOR\ny_xor = np.array([0., 1., 1., 0.])\n\n# pesos y sesgo para la primera capa\n# compuertas OR y NAND\nW1 = np.array([[10, 10], [-10, -10]]).T\nb1 = np.array([-5, 15])\n# pesos y sesgo para la segunda capa\n# compuerta AND\nW2 = np.array([[10], [10]])\nb2 = np.array([-15])\n\nprint('Pesos y sesgos para compuertas OR y NAND')\nprint('W_1 = [{0}{1}], b_1 = {2}'.format(W1[0, :], W1[1, :], b1))\nprint('Pesos y sesgos para compuerta AND')\nprint('W_2 = [{0}{1}], b_2 = {2}'.format(W2[0], W2[1], b2))\nprint('-----------------------------')\nprint('x_1 \\tx_2 \\ty\\ty_hat')\nprint('-----------------------------')\nfor i in range(X.shape[0]):\n x1, x2 = x = X[i]\n y_hat = multi_layer(x, W1, b1, W2, b2)\n print(f'{x1}\\t{x2}\\t{y_xor[i]}\\t{y_hat[0]}')",
"Pesos y sesgos para compuertas OR y NAND\nW_1 = [[ 10 -10][ 10 -10]], b_1 = [-5 15]\nPesos y sesgos para compuerta AND\nW_2 = [[10][10]], b_2 = [-15]\n-----------------------------\nx_1 \tx_2 \ty\ty_hat\n-----------------------------\n0.0\t0.0\t0.0\t0.0\n0.0\t1.0\t1.0\t1.0\n1.0\t0.0\t1.0\t1.0\n1.0\t1.0\t0.0\t0.0\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecab1db0806130d2ce2e2e5bb992ea3845570779 | 6,469 | ipynb | Jupyter Notebook | machine-learning/plotly-visualization/Plotly_Viz.ipynb | gizzmo25/pythoncode-tutorials | 39a413fc1da232ad6de7e5f1e8955564dc65448e | [
"MIT"
] | null | null | null | machine-learning/plotly-visualization/Plotly_Viz.ipynb | gizzmo25/pythoncode-tutorials | 39a413fc1da232ad6de7e5f1e8955564dc65448e | [
"MIT"
] | null | null | null | machine-learning/plotly-visualization/Plotly_Viz.ipynb | gizzmo25/pythoncode-tutorials | 39a413fc1da232ad6de7e5f1e8955564dc65448e | [
"MIT"
] | null | null | null | 27.180672 | 166 | 0.514454 | [
[
[
"import plotly.offline as py\nimport plotly.graph_objs as go\nimport plotly.figure_factory as ff\nimport pandas as pd\nimport numpy as np\nimport yfinance as yf\nimport pandas_datareader as pdr\n\npy.init_notebook_mode()",
"_____no_output_____"
],
[
"x = [ i for i in range(-10,10) ]\n\ny = [ i*2 for i in range(-10,10) ]\n\nxaxis = go.layout.XAxis(title=\"X Axis\")\nyaxis = go.layout.YAxis(title=\"Y Axis\")\n\nfig = go.Figure(layout=go.Layout(title=\"Simple Line Plot\", xaxis=xaxis, yaxis=yaxis))\nfig.add_trace(go.Scatter(x=x, y=y))",
"_____no_output_____"
],
[
"def sigmoid(x):\n return 1 / (1 + np.exp((-1) * x))\n\nx = sorted(np.random.random(100) * 10 - 5)\ny = [ sigmoid(i) for i in x ]\n\nxaxis = go.layout.XAxis(title=\"X Axis\")\nyaxis = go.layout.YAxis(title=\"Y Axis\")\n\nfig=go.Figure(layout=go.Layout(title=\"Sigmoid Plot\",xaxis=xaxis, yaxis=yaxis))\nfig.add_trace(go.Scatter(x=x, y=y, marker=dict(color=\"red\")))",
"_____no_output_____"
],
[
"l = []\n\nfor _ in range(5):\n l.append([ sorted(np.random.randint(low=0, high=10000, size=50)), sorted(np.random.randint(low=0, high=10000, size=50)) ])\n\nl = np.array(l)\n\nfigure = go.Figure(layout=go.Layout(title=\"Simple Scatter Example\", xaxis=go.layout.XAxis(title=\"X\"), yaxis=go.layout.YAxis(title=\"Y\")))\nfor i in range(len(l)):\n figure.add_trace(go.Scatter(x=l[i][0],y=l[i][1], mode=\"markers\", name=f\" Distribution {i+1} \"))\nfigure.show()",
"_____no_output_____"
],
[
"dist = np.random.normal(loc=0, scale=1, size=50000)",
"_____no_output_____"
],
[
"figure = go.Figure()\nfigure.add_trace(go.Histogram(x=dist,))",
"_____no_output_____"
],
[
"\n\nd=[{\"values\":np.random.normal(0,0.5,10000), \"information\": \" Normal Distribution with mean 0 and std= 0.5\"},\n {\"values\":np.random.normal(0,1,10000), \"information\": \" Normal Distribution with mean 0 and std= 1\"},\n {\"values\":np.random.normal(0,1.5,10000), \"information\": \" Normal Distribution with mean 0 and std= 1.5\"},\n {\"values\":np.random.normal(0,2,10000), \"information\": \" Normal Distribution with mean 0 and std= 2\"},\n {\"values\":np.random.normal(0,5,10000), \"information\": \" Normal Distribution with mean 0 and std= 5\"}]\n\nff.create_distplot([ele[\"values\"] for ele in d], group_labels=[ele[\"information\"] for ele in d], show_hist=False)",
"_____no_output_____"
],
[
"x = np.random.randint(low=5, high=100, size=15)\ny = np.random.randint(low=5, high=100 ,size=15)\nz = np.random.randint(low=5, high=100, size=15)\n\nfig = go.Figure()\nfig.add_trace(go.Scatter3d(x=x, y=y, z=z, mode=\"markers\"))",
"_____no_output_____"
],
[
"df_iris = pd.read_csv(\"iris.csv\")",
"_____no_output_____"
],
[
"fig = go.Figure()\nspecies_types = df_iris.species.unique().tolist()\n\nfor specie in species_types:\n b = df_iris.species == specie\n fig.add_trace(go.Scatter3d(x=df_iris[\"sepal_length\"][b], y=df_iris[\"sepal_width\"][b], z=df_iris[\"petal_width\"][b], name=specie, mode=\"markers\"))\n\n\nfig.show()",
"_____no_output_____"
],
[
"yf.pdr_override()\n\nsymbols = [\"AAPL\",\"MSFT\"]\nstocks = []\nfor symbol in symbols:\n stocks.append(pdr.get_data_yahoo(symbol, start=\"2020-01-01\", end=\"2020-05-31\"))",
"_____no_output_____"
],
[
"fig = go.Figure()\n\nfor stock,symbol in zip(stocks,symbols):\n fig.add_trace(go.Scatter(x=stock.index, y=stock.Close, name=symbol))\n\nfig.show()",
"_____no_output_____"
],
[
"df_aapl = pdr.get_data_yahoo(symbol, start=\"2020-01-01\", end=\"2020-05-31\")",
"_____no_output_____"
],
[
"ff.create_candlestick(dates=df_aapl.index, open=df_aapl.Open, high=df_aapl.High, low=df_aapl.Low, close=df_aapl.Close)",
"_____no_output_____"
],
[
"\n",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecab449ece9414403b51612a5d809b66f8b15ff9 | 5,684 | ipynb | Jupyter Notebook | Advent of Code 2018 - Day 3.ipynb | baogianghoangvu/Advent-Of-Code-2018 | a9ed41d57fbbb99edc5994903d5f499993cf8c55 | [
"Unlicense"
] | 1 | 2018-12-15T13:55:24.000Z | 2018-12-15T13:55:24.000Z | Advent of Code 2018 - Day 3.ipynb | baogianghoangvu/Advent-Of-Code-2018 | a9ed41d57fbbb99edc5994903d5f499993cf8c55 | [
"Unlicense"
] | null | null | null | Advent of Code 2018 - Day 3.ipynb | baogianghoangvu/Advent-Of-Code-2018 | a9ed41d57fbbb99edc5994903d5f499993cf8c55 | [
"Unlicense"
] | null | null | null | 22.377953 | 103 | 0.497185 | [
[
[
"https://adventofcode.com/2018/day/3",
"_____no_output_____"
]
],
[
[
"import numpy as np\nimport pandas as pd",
"_____no_output_____"
],
[
"puzzle_input = pd.read_csv(\"day3_input.txt\", header=None, sep=\"\\W+|x\", engine=\"python\")\npuzzle_input.columns = [\"drop\", \"id\", \"x\", \"y\", \"x_length\", \"y_length\"]\npuzzle_input.drop(labels=\"drop\", axis=1, inplace=True)",
"_____no_output_____"
],
[
"def selected_area(x, y, x_length, y_length):\n fabric = np.zeros((1000, 1000))\n fabric[y : (y + y_length), x : (x + x_length)] += 1\n return fabric",
"_____no_output_____"
],
[
"all_claim = np.zeros((1000, 1000))\nfor i in puzzle_input.itertuples():\n all_claim += selected_area(i.x, i.y, i.x_length, i.y_length)",
"_____no_output_____"
]
],
[
[
"## Part 1",
"_____no_output_____"
]
],
[
[
"np.count_nonzero(all_claim >= 2)",
"_____no_output_____"
]
],
[
[
"## Part 2",
"_____no_output_____"
]
],
[
[
"one_claim_area = all_claim == 1\nis_not_overlapped_mask = []\nfor i in puzzle_input.itertuples():\n area = selected_area(i.x, i.y, i.x_length, i.y_length)\n completely_inside_one_claim = np.count_nonzero((area - one_claim_area) == 1) == 0\n is_not_overlapped_mask.append(completely_inside_one_claim)",
"_____no_output_____"
],
[
"puzzle_input[[\"id\"]][is_not_overlapped_mask]",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
]
] |
ecab585211c893c14b8504107dc3957ba6a713d4 | 72,655 | ipynb | Jupyter Notebook | basic_examples/torsiondrive_datasets.ipynb | mattwelborn/QCArchiveExamples | 2ba34b6b72ebf85e720efffe2f1708bc57bd6a2d | [
"BSD-3-Clause"
] | null | null | null | basic_examples/torsiondrive_datasets.ipynb | mattwelborn/QCArchiveExamples | 2ba34b6b72ebf85e720efffe2f1708bc57bd6a2d | [
"BSD-3-Clause"
] | null | null | null | basic_examples/torsiondrive_datasets.ipynb | mattwelborn/QCArchiveExamples | 2ba34b6b72ebf85e720efffe2f1708bc57bd6a2d | [
"BSD-3-Clause"
] | null | null | null | 33.730269 | 8,464 | 0.416282 | [
[
[
"# TorsionDrive Datasets\n\nAn individual TorsionDrive is specific workflow in the QCArchive ecosystem that computes the energy profile of rotatable dihedral (torsion) for use in Force Field fitting. This workflow has been developed by the QCArchive Team in conjunction with:\n\n - [Lee-Ping Wang](https://chemistry.ucdavis.edu/people/lee-ping-wang)\n - [John Chodera](http://www.choderalab.org)\n - Chaya Stern\n - Yudong Qiu\n - [The Open Force Field Initiative](https://openforcefield.org)\n\nThe top-level TorsionDrive code can be found [here](https://github.com/lpwgroup/torsiondrive).\n\nThe TorsionDrive Dataset organizes many TorsionDrives together for data exploration, analysis, and methodology comparison. To begin, we can connect to the MolSSI QCArchive server and query all known TorsionDrive Datasets:",
"_____no_output_____"
]
],
[
[
"import qcportal as ptl\nclient = ptl.FractalClient()\nclient",
"_____no_output_____"
],
[
"client.list_collections(\"TorsionDriveDataset\")",
"_____no_output_____"
]
],
[
[
"One of the datasets can be obtained in the canonical manner:",
"_____no_output_____"
]
],
[
[
"ds = client.get_collection(\"TorsionDriveDataset\", \"OpenFF Fragmenter Phenyl Benchmark\")",
"_____no_output_____"
]
],
[
[
"## Exploring the Dataset\n\nEach row of the dataset is comprised of a `Entry` which contains a list of starting molecules for the TorsionDrive, the dihedral of interest (in this case zero-indexed), and the scan resolution of the dihedral. For the purposes of the underlying DataFrame each row is the name of this `Entry`.",
"_____no_output_____"
]
],
[
[
"ds.df.head()",
"_____no_output_____"
]
],
[
[
"New computations are based off specifications which contain many additional parameters to tune the torsiondrive as well as the underlying computational method. Here, we can list all specifications that are attributed to this dataset.",
"_____no_output_____"
]
],
[
[
"ds.list_specifications()",
"_____no_output_____"
]
],
[
[
"As we can see, we have several specifications at different levels of theory. It is important to recall that these Collections are \"live\": new specifications can be added and individual TorsionDrives can be under computation. To see the current status of each specification the `status` function is provided:",
"_____no_output_____"
]
],
[
[
"ds.status([\"uff\", \"b3lyp-d3\"])",
"_____no_output_____"
],
[
"ds.status([\"b3lyp-d3\"], collapse=False, status=\"COMPLETE\").head()",
"_____no_output_____"
]
],
[
[
"## Visualizing the TorsionDrives\n\nTorsionDrives can be visualized via the ``visualize`` command. Multiple torsiondrives can be plotted on the same graph for comparison.",
"_____no_output_____"
]
],
[
[
"ds.visualize([\"[CH3:4][O:3][c:2]1[cH:1]cccc1\", \"[CH3:4][O:3][c:2]1[cH:1]ccnc1\"], \"B3LYP-D3\", units=\"kJ / mol\")",
"_____no_output_____"
]
],
[
[
"## Computational Requirements\n\nWe can check the number of optimizations and individual gradient evaluations by using the ``count`` method. \nBy default, the ``count`` method shows the number of individual geometry optimizations:",
"_____no_output_____"
]
],
[
[
"ds.counts([\"[CH3:4][O:3][c:2]1[cH:1]cccc1\", \"[CH3:4][O:3][c:2]1[cH:1]ccnc1\"])",
"_____no_output_____"
]
],
[
[
"In addition to individual optimization runs, we can also find a sum of how many gradient evaluations were performed in the course of the run.",
"_____no_output_____"
]
],
[
[
"ds.counts([\"[CH3:4][O:3][c:2]1[cH:1]cccc1\", \"[CH3:4][O:3][c:2]1[cH:1]ccnc1\"], count_gradients=True)",
"_____no_output_____"
]
],
[
[
"## Deep data inspection\n\nThe TorsionDriveDataset also allows exploration of every single computation and molecule created during the individual TorsionDrive executions. Examples below this point will only be for those who wish to explore all of the individual computations in a TorsionDrive Dataset.\n\nThese TorsionDrive Datasets are different from canonical ``ReactionDataset`` and ``Dataset`` collections as each item in the underlying Pandas DataFrame is a TorsionDriveRecord object which contains links to all data used in the TorsionDrive. We can observe the these in the underlying DataFrame:",
"_____no_output_____"
]
],
[
[
"ds.df.head()",
"_____no_output_____"
]
],
[
[
"We can then begin to explore an individual TorsionDriveRecord by first pulling it from the DataFrame:",
"_____no_output_____"
]
],
[
[
"td = ds.df.loc[\"[CH3:4][O:3][c:2]1[cH:1]cccc1\", \"B3LYP-D3\"]",
"_____no_output_____"
]
],
[
[
"We can then request a variety of attributes off this TorsionDriveRecord:",
"_____no_output_____"
]
],
[
[
"print(\"Torsion of interest : {}\".format(td.keywords.dihedrals))\nprint(\"Final optimization energy in hartree: {}\".format(td.get_final_energies(180)))",
"Torsion of interest : [(3, 5, 7, 6)]\nFinal optimization energy in hartree: -346.5319986074462\n"
],
[
"td.get_final_molecules(90)",
"_____no_output_____"
]
],
[
[
"The `Molecule` object has a `measure` attribute so that we check the dihedral angle is in fact 180 degrees.",
"_____no_output_____"
]
],
[
[
"\"3-5-7-6 dihedral in degrees: {}\".format(td.get_final_molecules(180).measure([3, 5, 7, 6]))",
"_____no_output_____"
]
],
[
[
"You can also get a dictionary of all final molecules:",
"_____no_output_____"
]
],
[
[
"td.get_final_molecules()",
"_____no_output_____"
]
],
[
[
"## Exploring connection optimizations\n\nIf desired, we can pull each geometry optimization belonging to the torsiondrive with the `get_history` function. \nIn this case, we will pull the lowest energy optimization for the 180 degree dihedral:",
"_____no_output_____"
]
],
[
[
"opt = td.get_history(180, minimum=True)\nopt",
"_____no_output_____"
],
[
"opt.energies",
"_____no_output_____"
]
],
[
[
"## Exploring individual gradient evaluations\n\nWe can go even deeper in the calculations to look at each gradient calculation of the `Optimization` calculation if we so choose and see even more details about how the `TorsionDrive` object was constructed.",
"_____no_output_____"
]
],
[
[
"result = opt.get_trajectory()[-1]",
"_____no_output_____"
],
[
"print(\"Program: {}\".format(result.program))\nprint(\"Number of Basis Functions: {}\".format(result.properties.calcinfo_nbasis))\nprint(\"Total execution time: {:.2f}s\".format(result.provenance.wall_time))",
"Program: psi4\nNumber of Basis Functions: 152\nTotal execution time: 12.15s\n"
]
],
[
[
"This example also contains the Wiberg-Lowdin indices. \nAs this is specific to Psi4, this data resides inside the `extras` tag rather than general properties. \nThis data is not yet well curated and currently exists as a 1D list. \nWe will first pull this data and transform it to a 2D array:",
"_____no_output_____"
]
],
[
[
"import numpy as np\nwiberg = np.array(result.extras[\"qcvars\"][\"WIBERG_LOWDIN_INDICES\"]).reshape(-1, 16)",
"_____no_output_____"
]
],
[
[
"As this particular example is exploring the `3-5-7-6` dihedral, we would find the most use in the `5-7` bond. This can be acquired as follows: ",
"_____no_output_____"
]
],
[
[
"wiberg[5, 7]",
"_____no_output_____"
]
],
[
[
"We can continue to explore these results and even obtain the standard Psi4 logging information!",
"_____no_output_____"
]
],
[
[
"print(result.get_stdout()[:1000])",
"\n Memory set to 60.800 GiB by Python driver.\ngradient() will perform analytic gradient computation.\n\n*** tstart() called on dt039\n*** at Mon Mar 25 04:02:23 2019\n\n => Loading Basis Set <=\n\n Name: DEF2-SVP\n Role: ORBITAL\n Keyword: BASIS\n atoms 1-7 entry C line 90 file /home/lnaden/miniconda3/envs/qca/share/psi4/basis/def2-svp.gbs \n atoms 8 entry O line 130 file /home/lnaden/miniconda3/envs/qca/share/psi4/basis/def2-svp.gbs \n atoms 9-16 entry H line 15 file /home/lnaden/miniconda3/envs/qca/share/psi4/basis/def2-svp.gbs \n\n\n ---------------------------------------------------------\n SCF\n by Justin Turney, Rob Parrish, Andy Simmonett\n and Daniel G. A. Smith\n RKS Reference\n 6 Threads, 62259 MiB Core\n ---------------------------------------------------------\n\n ==> Geometry <==\n\n Molecular \n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecab791b3f740544387b3b77c08a7a7749e24ca9 | 6,471 | ipynb | Jupyter Notebook | examples/A1_walk_through.ipynb | MA171/Information | bc9ecad616b00f366dd70d5b0336784d85a89b7f | [
"MIT"
] | null | null | null | examples/A1_walk_through.ipynb | MA171/Information | bc9ecad616b00f366dd70d5b0336784d85a89b7f | [
"MIT"
] | null | null | null | examples/A1_walk_through.ipynb | MA171/Information | bc9ecad616b00f366dd70d5b0336784d85a89b7f | [
"MIT"
] | null | null | null | 26.198381 | 98 | 0.549838 | [
[
[
"import pandas as pd\nimport numpy as np\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.metrics import f1_score\nfrom pprint import pprint",
"_____no_output_____"
],
[
"data = pd.read_csv('train.csv')\ndata_test = pd.read_csv('test.csv')\ndata.shape",
"_____no_output_____"
],
[
"data.isnull().sum().hist()",
"_____no_output_____"
],
[
"data['match'].hist()",
"_____no_output_____"
],
[
"# if you haven't installed xgboost on your system, uncomment the line below\n# !pip install xgboost\n# if you haven't installed bayesian-optimization on your system, uncomment the line below\n!pip install scikit-optimize",
"_____no_output_____"
],
[
"x = data.drop('match', axis=1)\nfeatures_numeric = list(x.select_dtypes(include=['float64']))\nfeatures_categorical = list(x.select_dtypes(include=['object']))\ny = data['match']",
"_____no_output_____"
],
[
"print(features_categorical)",
"_____no_output_____"
],
[
"import numpy as np\nfrom sklearn.compose import ColumnTransformer\nfrom sklearn.datasets import fetch_openml\nfrom sklearn.pipeline import Pipeline\nfrom sklearn.impute import SimpleImputer\nfrom sklearn.preprocessing import StandardScaler, OneHotEncoder\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.model_selection import train_test_split, GridSearchCV\nfrom xgboost.sklearn import XGBClassifier\n\nnp.random.seed(0)\n\ntransformer_numeric = Pipeline(\n steps=[\n ('imputer', SimpleImputer(strategy='median')),\n ('scaler', StandardScaler())]\n)\n\ntransformer_categorical = Pipeline(\n steps=[\n ('imputer', SimpleImputer(strategy='constant', fill_value='missing')),\n ('onehot', OneHotEncoder(handle_unknown='ignore'))\n ]\n)\n\npreprocessor = ColumnTransformer(\n transformers=[\n ('num', transformer_numeric, features_numeric),\n ('cat', transformer_categorical, features_categorical)\n ]\n)\n\nfull_pipline = Pipeline(\n steps=[\n ('preprocessor', preprocessor),\n ('my_classifier', XGBClassifier(\n objective='binary:logistic', seed=1))\n ]\n)\n\n\n\n# `__` denotes attribute \n# (e.g. my_classifier__n_estimators means the `n_estimators` param for `my_classifier`\n# which is our xgb)\nparam_grid = {\n 'preprocessor__num__imputer__strategy': ['mean'],\n 'my_classifier__n_estimators': [10, 20, 100],\n 'my_classifier__max_depth':[10, 20]\n}\n\ngrid_search = GridSearchCV(\n full_pipline, param_grid, cv=5, verbose=3, n_jobs=2, \n scoring='roc_auc')\n\ngrid_search.fit(x, y)\n\nprint('best score {}'.format(grid_search.best_score_))\nprint('best score {}'.format(grid_search.best_params_))",
"_____no_output_____"
],
[
"# prepare submission:\nsubmission = pd.DataFrame()\nsubmission['id'] = data_test['id']\nsubmission['match'] = grid_search.predict_proba(data_test)[:,1]\nsubmission.to_csv('sample_submission_walkthrough.csv', index=False)\nsubmission",
"_____no_output_____"
],
[
"from skopt import BayesSearchCV\nfrom skopt.space import Real, Categorical, Integer\nfrom sklearn.svm import SVC\n\n\nSVC_pipline = Pipeline(\n steps=[\n ('preprocessor', preprocessor),\n ('my_svc', SVC(class_weight='balanced'))\n ]\n)\n# SVC has a class_weight attribute for unbalanced data\n\n\n# define ranges for bayes search\nbayes_search = BayesSearchCV(\n SVC_pipline,\n {\n 'my_svc__C': Real(1e-6, 1e+6, prior='log-uniform'),\n 'my_svc__gamma': Real(1e-6, 1e+1, prior='log-uniform'),\n 'my_svc__degree': Integer(1,8),\n 'my_svc__kernel': Categorical(['linear', 'poly', 'rbf']),\n },\n n_iter=3,\n random_state=0,\n verbose=3,\n)\n\nbayes_search.fit(x, y)\n\n",
"_____no_output_____"
],
[
"print('best score {}'.format(bayes_search.best_score_))\nprint('best score {}'.format(bayes_search.best_params_))",
"_____no_output_____"
],
[
"print('all the cv scores')\npprint(bayes_search.cv_results_)",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecab8feaebafd045a944d525cc94b1f8467de6d4 | 28,462 | ipynb | Jupyter Notebook | examples/advanced/predict_plus_optimize.ipynb | jrobben/cpmpy | df8ae5cd7d5a3e02187756f9a7a1e896a57499af | [
"Apache-2.0"
] | 39 | 2021-07-14T08:24:11.000Z | 2022-03-22T21:30:59.000Z | examples/advanced/predict_plus_optimize.ipynb | jrobben/cpmpy | df8ae5cd7d5a3e02187756f9a7a1e896a57499af | [
"Apache-2.0"
] | 54 | 2021-07-05T20:23:01.000Z | 2022-03-30T14:43:50.000Z | examples/advanced/predict_plus_optimize.ipynb | jrobben/cpmpy | df8ae5cd7d5a3e02187756f9a7a1e896a57499af | [
"Apache-2.0"
] | 5 | 2021-07-29T20:15:49.000Z | 2022-01-08T10:46:13.000Z | 31.380375 | 184 | 0.50123 | [
[
[
"from cpmpy import *\n## torch for training neural network\nimport torch\nfrom torch import nn, optim\nimport torch.utils.data as data_utils\nimport numpy as np\nimport pandas as pd\n## sklean module for data transforming and model running\nfrom sklearn.preprocessing import StandardScaler\nfrom sklearn.metrics import mean_squared_error as mse\nfrom sklearn.model_selection import cross_validate\nfrom sklearn.metrics import make_scorer\nimport sklearn\n#seaborn for creating nice plot\nimport seaborn as sns\nimport time\nfrom tqdm import tqdm\n# sns.set_theme()\nsns.set_context(\"notebook\", font_scale=1.5, rc={\"lines.linewidth\": 2.5})\nimport os\nfrom sklearn.model_selection import learning_curve\nimport shutil\nif os.path.exists('runs/CPMPY'):\n shutil.rmtree('runs/CPMPY')\n",
"_____no_output_____"
]
],
[
[
"#### If the following cell is kept with initial cell, it does not remove the directory!!!",
"_____no_output_____"
]
],
[
[
"## tensorboard to look at learning curve\nfrom torch.utils.tensorboard import SummaryWriter\nwriter = SummaryWriter('runs/CPMPY')\n%load_ext tensorboard",
"The tensorboard extension is already loaded. To reload it, use:\n %reload_ext tensorboard\n"
]
],
[
[
"### First we write a knapsack solver using CPMpy",
"_____no_output_____"
]
],
[
[
"class problem_solver:\n def __init__(self,weights,capacity,n_items):\n self.weights = weights\n self.capacity = capacity\n self.n_items = n_items\n self.x = boolvar(shape=n_items, name=\"x\")\n self.model = Model(sum(self.x*weights[0]) <= capacity)\n \n def solve_knapsack(self,cost):\n cost_ = (1000*cost).astype(int)\n # We have to convert the cost variable into integer, as ORtools only accepts integer variable\n self.model.maximize((self.x*cost_).sum())\n self.model.solve()\n return self.x.value()\n \n \n def solve_from_pytorch(self,cost_inpytorch):\n # cost_inpytorch is a pytorch tensor object\n cost_ = cost_inpytorch.detach().numpy()\n x = self.solve_knapsack(cost_)\n return torch.from_numpy(x).float()\n ",
"_____no_output_____"
]
],
[
[
"#### Let us use it to solve a simple knapsack problem.",
"_____no_output_____"
]
],
[
[
"knapsack_solver = problem_solver(weights = [[1,2,3,1]], capacity=3,n_items=4)\nknapsack_solver.solve_knapsack(np.array([10,20,25,15]))",
"_____no_output_____"
]
],
[
[
"#### In this example, out of the 4 objects, the 2nd and the 4th one are selcted.",
"_____no_output_____"
],
[
"### Now we will use this module to implement the **SPO approach** of `Elmachtoub, Adam N., and Paul Grigas. \"Smart “predict, then optimize”.\" Management Science (2021).`",
"_____no_output_____"
],
[
"#### First we load the data. We have training and test data.",
"_____no_output_____"
]
],
[
[
"if not os.path.exists('Data.npz'):\n torch.hub.download_url_to_file(\"https://github.com/JayMan91/aaai_predit_then_optimize/raw/master/Data.npz\", \"Data.npz\")\ndata = np.load(\"Data.npz\")\nx_train, x_test, y_train,y_test = data['X_1gtrain'],data['X_1gtest'],data['y_train'],data['y_test']\nx_train = x_train[:,1:]\nx_test = x_test[:,1:]\nprint(x_train.shape)",
"(26496, 8)\n"
]
],
[
[
"#### 8 features: HolidayFlag, DayOfWeek, WeekOfYear, Month, ForecastWindProduction, Forecasted SystemLoad, Forecasted Energy price, Forecasted CO2Intensity\n#### And the predictor variable: Energy Price",
"_____no_output_____"
],
[
"#### First we standardize the feature variables. We also reshape the data in groups of 48 so that each group is an instance.",
"_____no_output_____"
]
],
[
[
"scaler = StandardScaler()\nx_train = scaler.fit_transform(x_train)\nx_test = scaler.transform(x_test)\nx_train = x_train.reshape(-1,48,x_train.shape[1])\ny_train = y_train.reshape(-1,48)\nx_test = x_test.reshape(-1,48,x_test.shape[1])\ny_test = y_test.reshape(-1,48)\nx_test = x_test[:50]\ny_test = y_test[:50]\nprint(\"Number of instances in training {} and testing {}\".format(x_train.shape, x_test.shape))\n## we now randomize the training and test data\nx = np.concatenate((x_train, x_test), axis=0)\ny = np.concatenate((y_train,y_test), axis=0)\nx,y = sklearn.utils.shuffle(x,y,random_state=0)",
"Number of instances in training (552, 48, 8) and testing (50, 48, 8)\n"
]
],
[
[
"#### As we see, we have 552 training instances and test on 50 instances.",
"_____no_output_____"
],
[
"### We will use this data in the context of knapsack problem. The predicted Energy Price forms the value of knapsack. In our setup, each knapsack instance consists of 48 items. ",
"_____no_output_____"
]
],
[
[
"weights = [data['weights'].tolist()]\nweights = np.array(weights)\nn_items = 48\ncapacity = 60\nprint(np.sum(weights))",
"240\n"
]
],
[
[
"#### The weights are the costs of each item. The weights are kept same for each instance. The summation of 48 weights are 240. The knapsack capacity in this example is 60",
"_____no_output_____"
],
[
"#### Next, we create a solver instance with the specified weights and capacity",
"_____no_output_____"
]
],
[
[
"knapsack_solver = problem_solver(weights,capacity,n_items)",
"_____no_output_____"
]
],
[
[
"### The desirable goal to minimze the regret,\n### Regret is the loss in the objective value for using the solution of predicted value rather than the solution of true value (which we do not know).\n",
"_____no_output_____"
],
[
"### If $c$ are the true values and $\\hat{c}$ are the predicted values and $w^\\star(c)$ and $w^\\star(\\hat{c})$ are their solutions. \n### Then regret $=c^\\top( w^\\star(c) -w^\\star(\\hat{c}) )$",
"_____no_output_____"
]
],
[
[
"## A function to compute regret\ndef regret_score(y,y_pred):\n total_loss =0 \n for i in range(len(y)):\n sol_true = knapsack_solver.solve_knapsack(y[i])\n sol = knapsack_solver.solve_knapsack(y_pred[i])\n total_loss += ((sol_true - sol).dot(y[i]))\n return total_loss/len(y)",
"_____no_output_____"
]
],
[
[
"#### We will use the sklearn module for model training and scoring. For that we need a scoring function which will compute average regret of the instances. ",
"_____no_output_____"
]
],
[
[
"@torch.no_grad()\ndef score_fucn(model,X,y):\n model.eval()\n y_pred = model(torch.from_numpy(X).float()).squeeze()\n regret = regret_score(y,y_pred)\n model.train()\n return regret",
"_____no_output_____"
]
],
[
[
"#### We will also need a dataloder module, which will segregate the training data into batches",
"_____no_output_____"
]
],
[
[
"class Dataloader():\n def __init__(self, X,y):\n self.X = X.astype(np.float32)\n self.y = y.astype(np.float32)\n\n \n sol = []\n for i in range(len(y)):\n x_sol = knapsack_solver.solve_knapsack(y[i]) \n sol.append( x_sol)\n self.sol = np.array(sol)\n \n def __len__(self):\n return len(self.y)\n \n def __getitem__(self, idx):\n return self.X[idx],self.y[idx],self.sol[idx]",
"_____no_output_____"
]
],
[
[
"## Two-stage Regression Model",
"_____no_output_____"
]
],
[
[
"class reg:\n def __init__(self, net = nn.Linear(8,1),\n epochs=8,optim=optim.Adam,batch_size=24,lr=1,**kwg):\n self.net = net\n self.epochs = epochs\n self.batch_size = batch_size\n\n self.kwg = kwg\n self.optim = optim\n self.lr = lr\n\n def get_params(self, deep=True):\n para_dict = {\"net\": self.net, \"epochs\": self.epochs,\n \"batch_size\":self.batch_size,\n \"optim\":self.optim,\"lr\":self.lr}\n return para_dict\n def set_params(self, **parameters):\n for parameter, value in parameters.items():\n setattr(self, parameter, value)\n return self\n\n def fit(self,X,y):\n self.model = self.net\n self.optimizer = self.optim(self.model.parameters(),lr=self.lr, **self.kwg)\n criterion = nn.MSELoss(reduction='mean')\n\n train_df = Dataloader(X,y)\n fit_time= 0\n \n for e in tqdm(range(self.epochs)):\n train_dl = data_utils.DataLoader(train_df, batch_size=self.batch_size,shuffle=True)\n bb = 0\n for x_train,y_train,sol_train in train_dl:\n start_time = time.time()\n self.optimizer.zero_grad()\n y_pred = self.model(x_train).squeeze()\n loss= criterion(y_pred,y_train)\n loss.retain_grad()\n y_pred.retain_grad()\n loss.backward() \n self.optimizer.step()\n end_training = time.time()\n ## now we will save mse and regret and traininng data, this will take more time\n if (e)%3==0:\n mse_loss = loss.item()\n regret_loss = regret_score(y_train.detach().numpy(),y_pred.detach().numpy())\n end_regret = time.time()\n fit_time += end_training - start_time\n writer.add_scalar('Two stage MSE loss',mse_loss, e + bb/self.batch_size, fit_time)\n writer.add_scalar('Two stage Regret',regret_loss, e + bb/self.batch_size, fit_time)\n bb =+1\n\n def score(self,X,y):\n return score_fucn(self.model,X,y)\n\n def predict(self,X):\n self.model.eval()\n y_pred = self.model(torch.from_numpy(X).float()).squeeze()\n self.model.train()\n return y_pred.detach().numpy() ",
"_____no_output_____"
]
],
[
[
"#### A wrapper module to to train and test multiple times. We will use the inbuilt cross_validate module to train and test `n_run` times.",
"_____no_output_____"
]
],
[
[
"def repeatrun(n_train, n_test,n_run=1):\n i = 0\n while i < n_run:\n idx1 = np.arange(0, n_train , dtype=int)\n idx2 = np.arange(n_train, n_train+n_test, dtype=int)\n yield idx1, idx2\n i += 1\n",
"_____no_output_____"
]
],
[
[
"### Now we will run the two-stage model and save the regret and MSE on test and train data\n#### We also monitor the leanring curve. It will take 1 minute.",
"_____no_output_____"
]
],
[
[
"regression_df = pd.DataFrame()\nepoch=10\nscoring = {'Regret': make_scorer(regret_score),\n 'MSE': make_scorer(mse)}\nmodel = reg(optim=optim.SGD, epochs=epoch,lr= 0.01)\ncv = repeatrun(len(y_train),len(y_test))\nscores = cross_validate(model, x,y, scoring=scoring,cv=cv, return_train_score=True)\nscores = pd.DataFrame.from_dict(scores)\nscores['epoch'] = epoch\nregression_df = regression_df.append(scores)\nregression_df['model'] =\"Two-stage\"\nregression_df.reset_index(inplace=True)",
"100%|██████████| 10/10 [00:48<00:00, 4.83s/it]\n"
]
],
[
[
"### We will examine the learning curve on training data",
"_____no_output_____"
]
],
[
[
"%tensorboard --logdir=runs --port=6005",
"_____no_output_____"
]
],
[
[
"## Smart Predict and Optimize Regression Model ",
"_____no_output_____"
]
],
[
[
"class SPO:\n def __init__(self, net = nn.Linear(8,1),\n epochs=8,optim=optim.Adam,batch_size=24,lr=1,\n **kwg):\n self.net = net\n self.epochs = epochs\n self.batch_size = batch_size\n self.kwg = kwg\n self.optim = optim\n self.lr = lr\n\n def get_params(self, deep=True):\n para_dict = {\"net\": self.net, \"epochs\": self.epochs,\n \"batch_size\":self.batch_size,\"optim\":self.optim,\n \"lr\":self.lr}\n return para_dict\n def set_params(self, **parameters):\n for parameter, value in parameters.items():\n setattr(self, parameter, value)\n return self\n\n\n def fit(self,X,y):\n self.model = self.net\n self.optimizer = self.optim(self.model.parameters(),lr=self.lr, **self.kwg)\n \n train_df = Dataloader(X,y)\n criterion = nn.MSELoss(reduction='mean')\n fit_time= 0\n \n for e in tqdm(range(self.epochs)):\n train_dl = data_utils.DataLoader(train_df, batch_size=self.batch_size,shuffle=True)\n bb = 0\n for x_train,y_train,sol_train in train_dl:\n start_time = time.time()\n self.optimizer.zero_grad()\n y_pred = self.model(x_train).squeeze()\n \n # The difference from the Two-stage approah is that,\n # the loss function considers what happen after solving the knapsack instances\n y_spo = 2*y_pred - y_train\n grad_list = []\n # we have to solve the knpsack problem for all training instances with the predicted energy price\n for i in range(len(y_train)):\n sol_spo = knapsack_solver.solve_from_pytorch(y_spo[i])\n # We compute the (sub)gradients directly, see SPO paper\n grad = sol_spo - sol_train[i]\n grad_list.append(grad)\n grad = torch.stack(grad_list,0)\n y_pred.retain_grad()\n # gradients do not come from a loss , but we use SPO subgradients \n y_pred.backward(gradient=grad)\n # This is where SPO differes from the Two-stage model\n self.optimizer.step()\n end_training = time.time()\n ## now we will save mse and regret and traininng data, this will take more time\n if (e)%3==0:\n mse_loss = criterion(y_pred,y_train).item()\n regret_loss = regret_score(y_train.detach().numpy(),y_pred.detach().numpy())\n end_regret = time.time()\n fit_time += end_training - start_time\n writer.add_scalar('SPO MSE loss',mse_loss, e + bb/self.batch_size,fit_time)\n writer.add_scalar('SPO Regret',regret_loss, e + bb/self.batch_size,fit_time)\n bb =+1\n\n def score(self,X,y):\n return score_fucn(self.model,X,y)\n\n def predict(self,X):\n self.model.eval()\n y_pred = self.model(torch.from_numpy(X).float()).squeeze()\n self.model.train()\n return y_pred.detach().numpy()",
"_____no_output_____"
]
],
[
[
"### Now we will run the SPO model and save the regret and MSE on test and train data\n#### We also monitor the leanring curve. It will take 2-3 minutes.",
"_____no_output_____"
]
],
[
[
"spo_df = pd.DataFrame()\n\nscoring = {'Regret': make_scorer(regret_score),\n 'MSE': make_scorer(mse)}\nmodel = SPO(optim=optim.Adam, epochs=epoch,lr= 0.01)\ncv = repeatrun(len(y_train),len(y_test))\nscores = cross_validate(model, x,y, scoring=scoring,cv=cv, return_train_score=True)\nscores = pd.DataFrame.from_dict(scores)\nscores['epoch'] = epoch\nspo_df = spo_df.append(scores)\nspo_df['model'] =\"SPO\"\nspo_df.reset_index(inplace=True)",
"100%|██████████| 10/10 [01:48<00:00, 10.87s/it]\n"
]
],
[
[
"### We will see the learning curve on tensorboard",
"_____no_output_____"
]
],
[
[
"%tensorboard --logdir=runs --port=6005",
"_____no_output_____"
]
],
[
[
"## For a two-stage model even though MSE goes down, regret goes up\n## For SPO, Regret goes down",
"_____no_output_____"
],
[
"### Now we examine the performance on test data.",
"_____no_output_____"
]
],
[
[
"rslt_df = pd.concat([spo_df,regression_df],ignore_index=True)\nrslt_df.groupby(['model']).agg({'test_Regret':['mean'],'test_MSE': ['mean'],'fit_time':['mean'] })",
"_____no_output_____"
]
],
[
[
"### We see, on test data, regret is significantly lower for SPO. ",
"_____no_output_____"
],
[
"## We demonstrate for an prediction+optimisation problem, SPO generates predictions that are better suited to the optimisation problem, that is, a lower regret",
"_____no_output_____"
],
[
"## Because we repeatedly call solver while training SPO model, the model fitting time is high for SPO.",
"_____no_output_____"
]
],
[
[
"#### Implementation with growth #####\nclass problem_solver:\n def __init__(self,weights,capacity,n_items, grow=0.01):\n self.weights = weights\n self.capacity = capacity\n self.n_items = n_items\n self.x = boolvar(shape=n_items, name=\"x\")\n self.pool = np.empty([0, n_items])\n self.grow = grow\n self.model = Model(sum(self.x*weights[0]) <= capacity)\n \n def solve_knapsack(self,cost):\n cost_ = (1000*cost).astype(int)\n # We have to convert the cost variable into integer, as ORtools only accepts integer variable\n self.model.maximize((self.x*cost_).sum())\n self.model.solve()\n return self.x.value()\n \n \n def solve_from_pytorch(self,cost_inpytorch):\n # cost_inpytorch is a pytorch tensor object\n cost_ = cost_inpytorch.detach().numpy()\n if (np.random.random(1)[0]< self.grow) or len(self.pool)==0:\n x = self.solve_knapsack(cost_)\n self.pool = np.unique(np.append(self.pool,np.array([x]),axis=0),axis=0)\n else:\n x = self.pool[np.argmax((self.pool*cost_).sum(1))]\n return torch.from_numpy(x).float()\n######################################################",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
]
] |
ecab9af952e549ad2221affb0281b6f2fefaa861 | 7,052 | ipynb | Jupyter Notebook | 05_1_cross_validation_uni_class_cdc16/create_testing_sets_Oct_NT.ipynb | jingzbu/InverseVITraffic | c0d33d91bdd3c014147d58866c1a2b99fb8a9608 | [
"MIT"
] | null | null | null | 05_1_cross_validation_uni_class_cdc16/create_testing_sets_Oct_NT.ipynb | jingzbu/InverseVITraffic | c0d33d91bdd3c014147d58866c1a2b99fb8a9608 | [
"MIT"
] | null | null | null | 05_1_cross_validation_uni_class_cdc16/create_testing_sets_Oct_NT.ipynb | jingzbu/InverseVITraffic | c0d33d91bdd3c014147d58866c1a2b99fb8a9608 | [
"MIT"
] | null | null | null | 24.571429 | 116 | 0.510493 | [
[
[
"%run ../Python_files/util_data_storage_and_load.py",
"_____no_output_____"
],
[
"%run ../Python_files/load_dicts.py",
"_____no_output_____"
],
[
"%run ../Python_files/util.py",
"_____no_output_____"
],
[
"import numpy as np\nfrom numpy.linalg import inv",
"_____no_output_____"
],
[
"# load link flow data\n\nimport json\n\nwith open('../temp_files/link_day_minute_Oct_dict_JSON_adjusted.json', 'r') as json_file:\n link_day_minute_Oct_dict_JSON = json.load(json_file)",
"_____no_output_____"
],
[
"# week_day_Oct_list = [1, 2, 3, 4, 5, 8, 9, 10, 11, 12, 15, 16, 17, 18, 19, 22, 23, 24, 25, 26, 29, 30, 31]\n\n# testing set 1\nweek_day_Oct_list_1 = [22, 23, 24, 25, 26, 29, 30, 31]\n\n# testing set 2\nweek_day_Oct_list_2 = [10, 11, 12, 15, 16, 17, 18, 19]\n\n# testing set 3\nweek_day_Oct_list_3 = [1, 2, 3, 4, 5, 8, 9, 10]",
"_____no_output_____"
],
[
"link_flow_testing_set_Oct_NT_1 = []\nfor link_idx in range(24):\n for day in week_day_Oct_list_1: \n key = 'link_' + str(link_idx) + '_' + str(day)\n link_flow_testing_set_Oct_NT_1.append(link_day_minute_Oct_dict_JSON[key] ['NT_flow'])\n \nlink_flow_testing_set_Oct_NT_2 = []\nfor link_idx in range(24):\n for day in week_day_Oct_list_2: \n key = 'link_' + str(link_idx) + '_' + str(day)\n link_flow_testing_set_Oct_NT_2.append(link_day_minute_Oct_dict_JSON[key] ['NT_flow'])\n \nlink_flow_testing_set_Oct_NT_3 = []\nfor link_idx in range(24):\n for day in week_day_Oct_list_3: \n key = 'link_' + str(link_idx) + '_' + str(day)\n link_flow_testing_set_Oct_NT_3.append(link_day_minute_Oct_dict_JSON[key] ['NT_flow'])",
"_____no_output_____"
],
[
"len(link_flow_testing_set_Oct_NT_1)",
"_____no_output_____"
],
[
"testing_set_1 = np.matrix(link_flow_testing_set_Oct_NT_1)\ntesting_set_1 = np.matrix.reshape(testing_set_1, 24, 8)\ntesting_set_1 = np.nan_to_num(testing_set_1)\ny = np.array(np.transpose(testing_set_1))\ny = y[np.all(y != 0, axis=1)]\ntesting_set_1 = np.transpose(y)\ntesting_set_1 = np.matrix(testing_set_1)\n\ntesting_set_2 = np.matrix(link_flow_testing_set_Oct_NT_2)\ntesting_set_2 = np.matrix.reshape(testing_set_2, 24, 8)\ntesting_set_2 = np.nan_to_num(testing_set_2)\ny = np.array(np.transpose(testing_set_2))\ny = y[np.all(y != 0, axis=1)]\ntesting_set_2 = np.transpose(y)\ntesting_set_2 = np.matrix(testing_set_2)\n\ntesting_set_3 = np.matrix(link_flow_testing_set_Oct_NT_3)\ntesting_set_3 = np.matrix.reshape(testing_set_3, 24, 8)\ntesting_set_3 = np.nan_to_num(testing_set_3)\ny = np.array(np.transpose(testing_set_3))\ny = y[np.all(y != 0, axis=1)]\ntesting_set_3 = np.transpose(y)\ntesting_set_3 = np.matrix(testing_set_3)",
"_____no_output_____"
],
[
"np.size(testing_set_1, 1), np.size(testing_set_3, 0)",
"_____no_output_____"
],
[
"testing_set_3[:,:1]",
"_____no_output_____"
],
[
"# write testing sets to file\n\nzdump([testing_set_1, testing_set_2, testing_set_3], '../temp_files/testing_sets_Oct_NT.pkz')",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecaba6378cdc79941c93e4e588493c4cba3ae99e | 35,615 | ipynb | Jupyter Notebook | section-04-research-and-development/03-machine-learning-pipeline-feature-selection.ipynb | KRliang04/deploying-machine-learning-models | 0306ff7a7806eb2d8217ac59bdcb47ac8b50e516 | [
"BSD-3-Clause"
] | null | null | null | section-04-research-and-development/03-machine-learning-pipeline-feature-selection.ipynb | KRliang04/deploying-machine-learning-models | 0306ff7a7806eb2d8217ac59bdcb47ac8b50e516 | [
"BSD-3-Clause"
] | 1 | 2021-08-02T07:43:36.000Z | 2021-08-02T07:43:36.000Z | section-04-research-and-development/03-machine-learning-pipeline-feature-selection.ipynb | KRliang04/deploying-machine-learning-models | 0306ff7a7806eb2d8217ac59bdcb47ac8b50e516 | [
"BSD-3-Clause"
] | null | null | null | 34.477251 | 245 | 0.373831 | [
[
[
"# Machine Learning Pipeline - Feature Selection\n\nIn this notebook, we pick up the transformed datasets that we saved in the previous notebook.",
"_____no_output_____"
],
[
"## Reproducibility: Setting the seed\n\nWith the aim to ensure reproducibility between runs of the same notebook, but also between the research and production environment, for each step that includes some element of randomness, it is extremely important that we **set the seed**.",
"_____no_output_____"
]
],
[
[
"# to handle datasets\nimport pandas as pd\nimport numpy as np\n\n# for plotting\nimport matplotlib.pyplot as plt\n\n# to build the models\nfrom sklearn.linear_model import Lasso\nfrom sklearn.feature_selection import SelectFromModel\n\n# to visualise al the columns in the dataframe\npd.pandas.set_option('display.max_columns', None)",
"_____no_output_____"
],
[
"# load the train and test set with the engineered variables\n\n# we built and saved these datasets in the previous lecture.\n# If you haven't done so, go ahead and check the previous notebook\n# to find out how to create these datasets\n\nX_train = pd.read_csv('xtrain.csv')\nX_test = pd.read_csv('xtest.csv')\n\nX_train.head()",
"_____no_output_____"
],
[
"X_train.shape",
"_____no_output_____"
],
[
"# load the target (remember that the target is log transformed)\ny_train = pd.read_csv('ytrain.csv')\ny_test = pd.read_csv('ytest.csv')\n\ny_train.head()",
"_____no_output_____"
],
[
"y_train.shape",
"_____no_output_____"
]
],
[
[
"### Feature Selection\n\nLet's go ahead and select a subset of the most predictive features. There is an element of randomness in the Lasso regression, so remember to set the seed.",
"_____no_output_____"
]
],
[
[
"# We will do the model fitting and feature selection\n# altogether in a few lines of code\n\n# first, we specify the Lasso Regression model, and we\n# select a suitable alpha (equivalent of penalty).\n# The bigger the alpha the less features that will be selected.\n\n# Then we use the selectFromModel object from sklearn, which\n# will select automatically the features which coefficients are non-zero\n\n# remember to set the seed, the random state in this function\nsel_ = SelectFromModel(Lasso(alpha=0.001, random_state=0))\n\n# train Lasso model and select features\nsel_.fit(X_train, y_train)",
"_____no_output_____"
],
[
"sel_.get_support().sum()",
"_____no_output_____"
],
[
"# let's visualise those features that were selected.\n# (selected features marked with True)\n\nsel_.get_support()",
"_____no_output_____"
],
[
"# let's print the number of total and selected features\n\n# this is how we can make a list of the selected features\nselected_feats = X_train.columns[(sel_.get_support())]\n\n# let's print some stats\nprint('total features: {}'.format((X_train.shape[1])))\nprint('selected features: {}'.format(len(selected_feats)))\nprint('features with coefficients shrank to zero: {}'.format(\n np.sum(sel_.estimator_.coef_ == 0)))",
"total features: 81\nselected features: 36\nfeatures with coefficients shrank to zero: 45\n"
],
[
"# print the selected features\nselected_feats",
"_____no_output_____"
],
[
"pd.Series(selected_feats).to_csv('selected_features.csv', index=False)",
"_____no_output_____"
]
],
[
[
"# Additional Resources\n\n- [Feature Selection for Machine Learning](https://www.udemy.com/course/feature-selection-for-machine-learning/?referralCode=186501DF5D93F48C4F71) - Online Course\n- [Feature Selection for Machine Learning: A comprehensive Overview](https://trainindata.medium.com/feature-selection-for-machine-learning-a-comprehensive-overview-bd571db5dd2d) - Article",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
]
] |
ecabe6ec4090848f5f8d7e04885c5742413c7758 | 23,031 | ipynb | Jupyter Notebook | Perceptron from scratch.ipynb | jolivaresc/simple_perceptron | c0d168fe30c298052c851ce4a25089736b93ed3b | [
"MIT"
] | null | null | null | Perceptron from scratch.ipynb | jolivaresc/simple_perceptron | c0d168fe30c298052c851ce4a25089736b93ed3b | [
"MIT"
] | null | null | null | Perceptron from scratch.ipynb | jolivaresc/simple_perceptron | c0d168fe30c298052c851ce4a25089736b93ed3b | [
"MIT"
] | null | null | null | 87.238636 | 16,584 | 0.823412 | [
[
[
"# Simple Perceptron for logical gates.\nsome dependecies:\n",
"_____no_output_____"
]
],
[
[
"from random import choice,random\nimport numpy as np\nimport matplotlib.pyplot as plt\n%matplotlib inline",
"_____no_output_____"
]
],
[
[
"# `set_data`\nReceives a numpy array `target` thar represents the output of a logical gate and return a list with the next format:\n**[x1 | x0 | bias | target]**\n",
"_____no_output_____"
]
],
[
[
"def set_data(target):\n\tx = [np.array([0,0]),\n\t\t np.array([0,1]),\n\t np.array([1,0]),\n\t\t np.array([1,1])]\n\tbias = np.array([1 for _ in range(4)])\n\t# inputs: [x1 | x0 | bias]\n\tinputs = np.column_stack((x,bias))\n\t# return data: [x1 | x0 | bias | target]\n\treturn [(np.array(i),j) for i,j in zip(inputs,target)]",
"_____no_output_____"
]
],
[
[
"# Activation function\nI used a Heaviside as a threshold.",
"_____no_output_____"
]
],
[
[
"heaviside = lambda x: 1 if x >= 0 else -1",
"_____no_output_____"
]
],
[
[
"# Training\nGiven the data target and random weights.\nThe arguments for the learning rate (`eta`) & number of iterations (`epochs`) are optional. Returns the weights updated and the error.\n",
"_____no_output_____"
]
],
[
[
"def train(data,w,eta=0.1,epochs=40):\n\t# Activation function\n\terrors = []\n\t#w_tmp = []\n\t# Updating weights\n\tfor _ in range(epochs):\n\t\tx,expected = choice(data)\n\t\tresult = np.dot(w,x)\n\t\terror = expected - heaviside(result)\n\t\terrors.append(error)\n\t\tw += eta*error*x\n\treturn [w,error]",
"_____no_output_____"
]
],
[
[
"# Predicting\nReceives a vector to test and the weights. \n\n**Note:** The vector must includes the bias. \n\ni.e:\n`predict([x1,x0,1],w)`",
"_____no_output_____"
]
],
[
[
"def predict(inputs,w):\n\t# inputs: X + bias\n\treturn 1 if np.dot(inputs,w) >= 0 else -1",
"_____no_output_____"
]
],
[
[
"# Display\n\nPlotting the outputs of the logical gate and the line that represents the decision boundary.\nThe triangles represent a 0 & the circles a 1.",
"_____no_output_____"
]
],
[
[
"def display(data,w):\n\tfor dot in data:\n\t\tinputs,y = dot\n\t\tif y > 0:\n\t\t\tplt.scatter(inputs[0],inputs[1],color = 'g',s=200)\n\t\telse:plt.scatter(inputs[0],inputs[1],marker='^',color = 'b',s=200)\n\tplt.grid()\n\tplt.title('truth table')\n\tx1 = -0.1\n\ty1 = (-w[2] - w[0] * x1) / w[1]\n\tprint(x1,y1)\n\tx2 = 1.2\n\ty2 = (-w[2] - w[0] * x2) / w[1]\n\tprint(x2,y2)\n\tplt.plot([x1,x2],[y1,y2],label=\"Decision boundery\",lw=2)\n\tplt.legend(loc='upper right')\n\tplt.show()",
"_____no_output_____"
]
],
[
[
"# Run\n\nRunning & training the perceptron.\n\n**Note** In the numpy array `target` a 0 is represented by a -1.",
"_____no_output_____"
]
],
[
[
"def run():\n\t# output for a nand gate\n\ttarget = np.array([1,1,1,-1])\n\t# Random weights\n\tw = np.array([random() for _ in range(3)])\n\tprint(\"random weights: {0}\".format(w))\n\tnand = set_data(target)\n\tw,error = train(nand,w,eta=0.1,epochs=100)\n\tprint(\"weights updated: {0}\".format(w))\n\tprint(\"Predicting\\tAproximation\\tResult\")\n\tprint(\"{0}\\t\\t{1:.5f}\\t\\t{2}\".format([0,0],np.dot([0,0,1],w),predict([0,0,1],w)))\n\tprint(\"{0}\\t\\t{1:.5f}\\t\\t{2}\".format([0,1],np.dot([0,1,1],w),predict([0,1,1],w)))\n\tprint(\"{0}\\t\\t{1:.5f}\\t\\t{2}\".format([1,0],np.dot([1,0,1],w),predict([1,0,1],w)))\n\tprint(\"{0}\\t\\t{1:.5f}\\t{2}\".format([1,1],np.dot([1,1,1],w),predict([1,1,1],w)))\n\tdisplay(nand,w)\n\nif __name__ == '__main__':\n\trun()",
"random weights: [ 0.29065932 0.03606822 0.32724607]\nweights updated: [-0.30934068 -0.36393178 0.52724607]\nPredicting\tAproximation\tResult\n[0, 0]\t\t0.52725\t\t1\n[0, 1]\t\t0.16331\t\t1\n[1, 0]\t\t0.21791\t\t1\n[1, 1]\t\t-0.14603\t-1\n-0.1 1.53374937074\n1.2 0.428754133195\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecac085ebdfe77236c65ac5973165b09a6f18fae | 2,897 | ipynb | Jupyter Notebook | nbs/index.ipynb | brainud/UPIT | 020f8e2d8dbab6824cd4bef2690ea93e3ff69a6e | [
"Apache-2.0"
] | null | null | null | nbs/index.ipynb | brainud/UPIT | 020f8e2d8dbab6824cd4bef2690ea93e3ff69a6e | [
"Apache-2.0"
] | null | null | null | nbs/index.ipynb | brainud/UPIT | 020f8e2d8dbab6824cd4bef2690ea93e3ff69a6e | [
"Apache-2.0"
] | null | null | null | 27.590476 | 256 | 0.602692 | [
[
[
"#hide\nimport sys\nsys.path.append(\"../\")\nfrom upit import *",
"_____no_output_____"
]
],
[
[
"# Unpaired image-to-image translation\n\n> A fastai/PyTorch package for unpaired image-to-image translation currently with CycleGAN implementation.\n",
"_____no_output_____"
],
[
"This is a package for training and testing unpaired image-to-image translation models. It currently only includes the [CycleGAN model](https://junyanz.github.io/CycleGAN/), but other models will be implemented in the future. \n\nThis package uses [fastai](https://github.com/fastai/fastai) to accelerate deep learning experimentation. Additionally, [nbdev](https://github.com/fastai/nbdev) was used to develop the package and produce documentation based on a series of notebooks.",
"_____no_output_____"
],
[
"## Install",
"_____no_output_____"
],
[
"To install, use `pip`:\n\n`pip install git+https://github.com/tmabraham/UPIT.git`\n\nThe package uses torch 1.6.0, torchvision 0.7.0, and fastai 2.0.0 (and its dependencies). It also requires nbdev 0.2.26 if you would like to add features to the package. Finally, for creating a web app model interface, gradio 1.1.6 is used.",
"_____no_output_____"
],
[
"## How to use",
"_____no_output_____"
],
[
"Training a CycleGAN model is easy with UPIT! Given the paths of the images from the two domains `trainA_path` and `trainB_path`, you can do the following:",
"_____no_output_____"
]
],
[
[
"#hide\nfrom fastai.vision.all import *\nhorse2zebra = untar_data('https://people.eecs.berkeley.edu/~taesung_park/CycleGAN/datasets/horse2zebra.zip')\nfolders = horse2zebra.ls().sorted()\ntrainA_path = folders[2]\ntrainB_path = folders[3]\ntestA_path = folders[0]\ntestB_path = folders[1]",
"_____no_output_____"
],
[
"#cuda\ndls = get_dls(trainA_path, trainB_path)\ncycle_gan = CycleGAN(3,3,64)\nlearn = cycle_learner(dls, cycle_gan,opt_func=partial(Adam,mom=0.5,sqr_mom=0.999))\nlearn.fit_flat_lin(100,100,2e-4)",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code"
] | [
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
]
] |
ecac1ef95922024d3d3d770f9999aee732b274e8 | 562,197 | ipynb | Jupyter Notebook | 2327609.ipynb | linsl1986/Prediction-of-electricity-consumption-based-on-neural-network-algorithm | f0170a732b2219e7c58d5cbc881eb6a0feef5e72 | [
"Apache-2.0"
] | null | null | null | 2327609.ipynb | linsl1986/Prediction-of-electricity-consumption-based-on-neural-network-algorithm | f0170a732b2219e7c58d5cbc881eb6a0feef5e72 | [
"Apache-2.0"
] | null | null | null | 2327609.ipynb | linsl1986/Prediction-of-electricity-consumption-based-on-neural-network-algorithm | f0170a732b2219e7c58d5cbc881eb6a0feef5e72 | [
"Apache-2.0"
] | null | null | null | 735.859948 | 155,524 | 0.949052 | [
[
[
"# 基于神经网络算法的用电量预测\n\n作者信息:linsl1986 (https://github.com/linsl1986)\n\n我在AI Studio上获得白银等级,点亮1个徽章,来互关呀~ https://aistudio.baidu.com/aistudio/personalcenter/thirdview/134639\n\n## 1. 简要介绍\n 开展电力系统用电量及负荷预测的目的是:为了电力系统供电范围内电力工业的发展能够适应国民经济和社会发展的需要。\n 用电量及负荷预测是电力工业生产建设计划及经营管理的基础,又是电力系统规划设计的基础。\n 本项目以A地区一年的用电量和相应的气象因素为依据,使用神经网络算法进行电量及负荷预测。\n\n## 2. 环境设置\n导入包,设置所用的归一化方法、神经网络结构、训练轮数和预测时间段等信息\n",
"_____no_output_____"
]
],
[
[
"import pandas as pd\r\nimport numpy as np\r\nimport paddle\r\nimport paddle.fluid as fluid\r\nimport numpy as np\r\nimport pickle\r\nfrom tqdm import tqdm\r\nimport matplotlib.pyplot as plt\r\n# 选择归一化方法\r\nnormalization=1 # 0表示Max-min归一化, 1表示Zscore归一化\r\n# 选择神经网络\r\nflag = 0 # 0表示全连接神经网络, 1表示LSTM神经网络\r\nday_num = 1 # 选择前一天的特征作为输入数据。\r\n# 训练参数设置\r\nBATCH_SIZE = 5\r\nlearning_rate = 0.001\r\nEPOCH_NUM = 200\r\n\r\n# 可视化天数选择,建议大于7,这样才能展示一周的预测情况\r\ndate_n = 7",
"/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/__init__.py:107: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n from collections import MutableMapping\n/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/rcsetup.py:20: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n from collections import Iterable, Mapping\n/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/matplotlib/colors.py:53: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working\n from collections import Sized\n"
]
],
[
[
"\n## 3. 数据集\n本数据集包含了近一年A地区用电量以及气象要素的原始数据,每天有96个时刻的温度,湿度,风速,降雨和用电量。\n具体步骤包括:\n\n1、从excel中读取数据\n\n\n\n2、划分训练集和测试集。由于本项目是基于N天的用电量和气象要素等信息预测N+1天的用电量,因此训练集和测试集的数据是需要连续若干天的,这里有别于多元线性回归时的训练集和测试集的划分过程。\n\n\n\n\n3、数据集调整思路\n* 减少特征,也就是不考虑温度,湿度,风速,降雨和负荷数据中的一种或者多种,重新构建输入特征\n* 使用前几天的数据预测性后一天的负荷,修改上面的day_num数值\n* 由于温度,湿度,风速,降雨等数据是可以预测得到的,因此在输入特征中添加后一天的温度,湿度,风速,降雨。\n\n讲述数据集的一些基础信息,描述数据集组成等。进行数据集的下载、抽样查看、数据集定义等。\n\n",
"_____no_output_____"
]
],
[
[
"# 从excel中读取温度,湿度,风速,降雨和用电量数据\r\ntrain_set = []\r\ntest_set = []\r\nfor i in range(5):\r\n sheet = pd.read_excel('work/Load_Forcast.xlsx',\r\n sheet_name = i,usecols = range(1,97))\r\n train_set.append(sheet[0:365].values)#对应excel中的第2行到366行\r\n test_set.append(sheet[365:365+31].values)#对应excel中第367行到397行\r\nprint(train_set[0].shape)\r\nprint(test_set[0].shape)",
"(365, 96)\n(31, 96)\n"
],
[
"#生成训练集和测试集\r\ndef data_pro(train_set, test_set, day_num):\r\n # 定义训练标签数据\r\n train_y = train_set[4]\r\n # 数据为一年的用电量数据,共365天,由于前一天day_num的数据作为输入,因此需要删去第一天的数据\r\n train_y = train_y[day_num:, :]\r\n print(train_y.shape)\r\n # print(train_y[0]) #检验是否已经删除了第一天的数据\r\n\r\n # 选择特征,定义训练的输入数据\r\n # train_set[0]表示温度数据,train_set[1]:表示湿度数据,train_set[2]:表示风速数据, train_set[3]:表示降雨数据, train_set[4]:表示用电量数据, \r\n\r\n \r\n temperature_data = train_set[0]\r\n humidity_data = train_set[1]\r\n wind_velocity_data = train_set[2]\r\n rainfall_data = train_set[3]\r\n load_data = train_set[4]\r\n\r\n # 将温度,湿度,风速,降雨,用电量合并,成为输入的特征向量,所以有96*5=480列数据\r\n train_x_temp = np.concatenate((temperature_data,humidity_data, wind_velocity_data, rainfall_data, load_data),axis = 1)\r\n temp = []\r\n for x in range(day_num):\r\n temp.append(train_x_temp[x:(365-day_num+x), :]) # 训练集的输入train_x中删除第一年的最后一天的数据\r\n \r\n train_x = np.concatenate(temp, axis=1)\r\n print(train_x.shape)\r\n # print(train_x[363])#检验训练集的输入train_x最后一组数据\r\n\r\n\r\n # 根据选择特征的定义,修改测试集的数据\r\n # 修改测试集的标签数据\r\n test_y = test_set[0-day_num]\r\n test_y = test_y[day_num:, :]\r\n print(test_y.shape)\r\n # 修改测试集的输入数据\r\n temperature_data = test_set[0]\r\n humidity_data = test_set[1]\r\n wind_velocity_data = test_set[2]\r\n rainfall_data = test_set[3]\r\n load_data = test_set[4]\r\n test_x_temp = np.concatenate((temperature_data,humidity_data, wind_velocity_data, rainfall_data, load_data),axis = 1)\r\n\r\n temp = []\r\n for x in range(day_num):\r\n temp.append(test_x_temp[x:(31-day_num+x), :])\r\n # print(test_x_temp[x:(31-day_num+x), :].shape)\r\n \r\n test_x = np.concatenate(temp, axis=1)\r\n print(test_x.shape)\r\n\r\n\r\n return train_x, train_y, test_x, test_y\r\n\r\n\r\ntrain_x, train_y, test_x, test_y = data_pro(train_set=train_set, test_set=test_set, day_num=day_num)",
"(364, 96)\n(364, 480)\n(30, 96)\n(30, 480)\n"
],
[
"#本部分为数据归一化的代码,一般不需要修改\r\nif normalization==0: # 使用Max-min归一化处理函数\r\n def normalization_Maxmin(train_x):\r\n Min = np.min(train_x, axis=0)\r\n Max = np.max(train_x, axis=0)\r\n train_x = (train_x-Min)/ (Max - Min)\r\n # 处理异常情况\r\n train_x[np.isnan(train_x)] = 0\r\n train_x[np.isinf(train_x)] = 0\r\n return train_x, Min, Max\r\n\r\n # 对输入数据进行归一化处理\r\n train_x, Min_x, Max_x = normalization_Maxmin(train_x)\r\n test_x = (test_x -Min_x)/ (Max_x - Min_x)\r\n # 对输出数据进行归一化处理\r\n train_y, Min_y, Max_y = normalization_Maxmin(train_y)\r\n test_y = (test_y-Min_y)/ (Max_y - Min_y)\r\nelse:#zscore归一化处理函数,适用于数据服从正态分布\r\n def normalization_zscore(train_x):\r\n mu = np.mean(train_x, axis=0)\r\n sigma = np.std(train_x, axis=0)\r\n train_x = (train_x-mu)/sigma\r\n # 处理异常情况\r\n train_x[np.isnan(train_x)] = 0\r\n train_x[np.isinf(train_x)] = 0\r\n return train_x, mu, sigma\r\n\r\n # 对输入数据进行归一化处理\r\n train_x, mu_x, sgma_x = normalization_zscore(train_x)\r\n test_x = (test_x - mu_x)/sgma_x\r\n # 对输出数据进行归一化处理\r\n train_y, mu_y, sgma_y = normalization_zscore(train_y)\r\n test_y = (test_y-mu_y)/sgma_y",
"_____no_output_____"
]
],
[
[
"## 4. 模型组网\n下面的示例中,使用全连接神经网络,可以修改成其他神经网络,例如LSTM。**注意,因为预测的负荷十五分钟一个时刻,一天共96个时刻,所以输出的维度必须为96。**\n\n",
"_____no_output_____"
]
],
[
[
"# 定义全连接神经网络 \r\ndef Full_connected(input): \r\n hidden1 = fluid.layers.fc(input=input, size=50, act='relu') \r\n hidden2 = fluid.layers.fc(input=hidden1, size=50, act='relu')\r\n hidden3 = fluid.layers.fc(input=hidden2, size=50, act='relu')\r\n hidden4 = fluid.layers.fc(input=hidden3, size=50, act='relu')\r\n prediction = fluid.layers.fc(input=hidden2, size=96, act=None) \r\n return prediction\r\n\r\n# 定义LSTM\r\ndef LSTM_pre(x):\r\n # Lstm layer\r\n fc0 = fluid.layers.fc(input=x, size=16)\r\n lstm_h, c = fluid.layers.dynamic_lstm(input=fc0, size=16, is_reverse=False)\r\n\r\n # max pooling layer\r\n lstm_max = fluid.layers.sequence_pool(input=lstm_h, pool_type='max')\r\n lstm_max_tanh = fluid.layers.tanh(lstm_max)\r\n\r\n # full connect layer\r\n # lstm_max_tanh = fluid.layers.fc(input=lstm_max_tanh, size=16, act='relu')\r\n prediction = fluid.layers.fc(input=lstm_max_tanh, size=96, act=None)# 'tanh')\r\n return prediction\r\n",
"_____no_output_____"
]
],
[
[
"## 5. 模型训练\n使用模型网络结构和数据集进行模型训练。具体包括如下步骤\n\n1、定义数据生成器\n\n2、定义训练时数据的读取方式、损失函数和优化器\n\n3、定义训练程序\n\n效果如下\n\n\n\n",
"_____no_output_____"
]
],
[
[
"#定义数据生成器\r\ndef readers(x, y):\r\n def reader():\r\n for i in range(x.shape[0]):\r\n yield x[i], y[i]\r\n return reader",
"_____no_output_____"
],
[
"# 定义数据读取方式\ntrainer_reader = readers(train_x, train_y)\ntrain_reader = paddle.batch(\n paddle.reader.shuffle(\n reader=trainer_reader,buf_size=300),\n batch_size=BATCH_SIZE)\n\npaddle.enable_static()# PaddlePaddle 2.x需要使用这句话才能进行静态模型\n\n# 搭建神经网络\nif flag==0: # 使用全连接神经网络\n # 定义神经网络输入和输出, 注意输入的维度必须和选择特征的维度一致, 输出的维度必须为96\n x = fluid.layers.data(name='x', shape=[480*day_num], dtype='float32')\n y = fluid.layers.data(name='y', shape=[96], dtype='float32')\n\n # 选择神经网络\n pred = Full_connected(x)\nelse:\n # 定义神经网络输入和输出, 注意输入的维度必须和选择特征的维度一致, 输出的维度必须为96\n x = fluid.layers.data(name='x', shape=[1], dtype='float32', lod_level=1)\n y = fluid.layers.data(name='y', shape=[96], dtype='float32')\n\n # 选择神经网络\n pred = LSTM_pre(x)\n\n# 定义损失函数\ncost = fluid.layers.square_error_cost(input=pred, label=y)\navg_cost = fluid.layers.mean(cost)\n\n# 选择优化器https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/fluid/optimizer/MomentumOptimizer_cn.html\noptimizer = fluid.optimizer.MomentumOptimizer(learning_rate=learning_rate, momentum=0.9)\nopts = optimizer.minimize(avg_cost)",
"_____no_output_____"
],
[
"# 定义训练程序\r\ntest_program = fluid.default_main_program().clone(for_test=True)\r\nuse_cuda = False\r\nplace = fluid.CUDAPlace(0) if use_cuda else fluid.CPUPlace()\r\nexe = fluid.Executor(place)\r\nexe.run(fluid.default_startup_program())\r\n\r\nfeeder = fluid.DataFeeder(place=place, feed_list=[x, y])\r\n\r\nlosses = []\r\nfor pass_id in range(EPOCH_NUM):\r\n loss = []\r\n for batch_id, data in enumerate(train_reader()):\r\n train_cost = exe.run(program=fluid.default_main_program(), feed=feeder.feed(data), fetch_list=[avg_cost]) \r\n loss.append(train_cost[0][0]) \r\n losses.append(np.mean(loss))\r\n if pass_id % 10==0:\r\n print('Epoch:', pass_id, 'loss:', np.mean(loss))\r\n\r\nfluid.io.save_inference_model('./pd', ['x'], [pred], exe)\r\n\r\nplt.figure(dpi=50,figsize=(24,8))\r\nplt.plot(range(EPOCH_NUM), losses)\r\nplt.xlabel('epoch')\r\nplt.ylabel('Loss')\r\nplt.show()",
"Epoch: 0 loss: 1.1151296\nEpoch: 10 loss: 0.15404606\nEpoch: 20 loss: 0.13686994\nEpoch: 30 loss: 0.12620154\nEpoch: 40 loss: 0.11993254\nEpoch: 50 loss: 0.11418716\nEpoch: 60 loss: 0.10808734\nEpoch: 70 loss: 0.10360893\nEpoch: 80 loss: 0.09905642\nEpoch: 90 loss: 0.094708666\nEpoch: 100 loss: 0.090344004\nEpoch: 110 loss: 0.08762974\nEpoch: 120 loss: 0.08389911\nEpoch: 130 loss: 0.08119105\nEpoch: 140 loss: 0.07857406\nEpoch: 150 loss: 0.07300305\nEpoch: 160 loss: 0.07000438\nEpoch: 170 loss: 0.06870857\nEpoch: 180 loss: 0.06455473\nEpoch: 190 loss: 0.062369313\n"
]
],
[
[
"## 6. 模型评估\n使用评估数据评估训练好的模型,检查预测值与真实值的差异。\n\n\n",
"_____no_output_____"
]
],
[
[
"infer_exe = fluid.Executor(place)\r\ninference_scope = fluid.core.Scope()\r\ndef convert2LODTensor(temp_arr, len_list):\r\n temp_arr = np.array(temp_arr) \r\n temp_arr = temp_arr.flatten().reshape((-1, 1))#把测试样本的array平坦化到一维数据[N,1]的格式\r\n print(temp_arr.shape)\r\n return fluid.create_lod_tensor(\r\n data=temp_arr,#对测试样本来说这里表示样本的平坦化数据列表,维度为[N,1]\r\n recursive_seq_lens =[len_list],#对于测试样本来说这里labels列的数量\r\n place=fluid.CPUPlace()\r\n )#返回:A fluid LoDTensor object with tensor data and recursive_seq_lens info\r\n \r\ndef get_tensor_label(mini_batch): \r\n tensor = None\r\n labels = []\r\n \r\n temp_arr = []\r\n len_list = []\r\n for _ in mini_batch: #mini_batch表示测试样本数据\r\n labels.append(_[1]) #收集 label----y----------1维\r\n temp_arr.append(_[0]) #收集序列本身--x---------96维\r\n len_list.append(len(_[0])) #收集每个序列x的长度,和上边x的维度对应,这里全为6\r\n tensor = convert2LODTensor(temp_arr, len_list) \r\n return tensor, labels\r\n\r\n\r\nif flag==0: # 全连接神经网络的数据处理\r\n tester_reader = readers(test_x, test_y)\r\n test_reader = paddle.batch(tester_reader, batch_size=31)\r\n test_data = next(test_reader())\r\n test_x = np.array([data[0] for data in test_data]).astype(\"float32\")\r\n test_y= np.array([data[1] for data in test_data]).astype(\"float32\")\r\nelse: # LSTM 网络的数据处理\r\n test_x = test_x.astype(\"float32\")\r\n test_y= test_y.astype(\"float32\")\r\n tester_reader = readers(test_x, test_y)\r\n test_reader = paddle.batch(tester_reader, batch_size=31-day_num)#一次性把样本取完\r\n for mini_batch in test_reader():\r\n test_x,labels = get_tensor_label(mini_batch)#其实就是变成tensor格式的x和y\r\n break\r\n \r\n \r\nprint(test_x.shape)\r\nwith fluid.scope_guard(inference_scope):\r\n [inference_program, feed_target_names, fetch_targets] =\\\r\n fluid.io.load_inference_model('./pd', infer_exe)\r\n results = infer_exe.run(inference_program,\r\n feed={feed_target_names[0]: test_x},\r\n fetch_list=fetch_targets)",
"(30, 480)\n"
],
[
"# print(results)\r\nif normalization==0: \r\n results= (Max_y - Min_y)*results+Min_y\r\n test_y= (Max_y - Min_y)*test_y+Min_y\r\nelse:\r\n results = results*sgma_y+mu_y\r\n test_y = test_y*sgma_y + mu_y\r\nprint(test_y.shape)\r\n\r\ny1 = np.reshape(results, (1,test_y.shape[0]*test_y.shape[1]))\r\ny2 = np.reshape(test_y, (1,test_y.shape[0]*test_y.shape[1]))\r\nprint(y1[0, :].shape)\r\nplt.figure(dpi=50,figsize=(24,8))\r\nplt.plot(range(date_n*96), y1[0, :date_n*96], color='r', label='Real')\r\nplt.plot(range(date_n*96), y2[0, :date_n*96], color='g', label='Predict') #绿线为预测值\r\nplt.xlabel('Time', fontsize = 20)\r\nplt.ylabel('Load', fontsize = 20)\r\nplt.legend()\r\nplt.show()\r\n\r\nprint(results.shape)\r\n# print(test_y)\r\ns = \"真值-预测分割线 \"\r\n# print(\"{:*^90}\".format(s))\r\n# print(results)\r\nmape = np.mean(np.abs((results - test_y) / test_y)) * 100\r\nerror = abs(results - test_y)\r\n# print(mape)\r\nprint(results.shape)\r\ntest_y.resize((31-day_num,96))\r\nresults.resize((31-day_num,96))\r\nerror.resize((31-day_num,96))\r\n# print(mape)\r\n# print(error)",
"(30, 96)\n(2880,)\n(1, 30, 96)\n(1, 30, 96)\n"
]
],
[
[
"\n## 7. 模型预测\n利用模型对30天后的用电量进行预测,展示效果如下。\n\n\n\n",
"_____no_output_____"
]
],
[
[
"df_test_y = pd.DataFrame(test_y)\r\ndf_results = pd.DataFrame(results)\r\ndf_error = pd.DataFrame(error)\r\n# print(df_results)\r\n\r\nfrom mpl_toolkits.mplot3d import Axes3D\r\nimport matplotlib.pyplot as plt\r\nimport pandas as pd\r\nimport seaborn as sns\r\n%matplotlib inline\r\nmy_dpi=96\r\nplt.figure(figsize=(480/my_dpi, 480/my_dpi), dpi=my_dpi)\r\ndata = df_test_y\r\ndf=data.unstack().reset_index() \r\ndf.columns=[\"X\",\"Y\",\"Z\"]\r\n \r\ndf['X']=pd.Categorical(df['X'])\r\ndf['X']=df['X'].cat.codes\r\n \r\nfig = plt.figure(figsize=(15,5))\r\nax = fig.gca(projection='3d')\r\n#交换X,Y,可以旋转90度\r\nsurf=ax.plot_trisurf(df['X'], df['Y'], df['Z'], cmap=plt.cm.viridis, linewidth=0.2)\r\n# surf=surf.rotate(90)\r\nfig.colorbar( surf, shrink=0.5, aspect=5)\r\nax.set_xlabel('Time', fontsize = 15)\r\nax.set_ylabel('Day', fontsize = 15)\r\nax.set_zlabel('Load', fontsize = 15)\r\nax.set_title('Actual value of load', fontsize = 20)\r\n\r\nplt.show()\r\n#********************\r\ndata = df_results\r\ndf=data.unstack().reset_index() \r\ndf.columns=[\"X\",\"Y\",\"Z\"]\r\n \r\ndf['X']=pd.Categorical(df['X'])\r\ndf['X']=df['X'].cat.codes\r\n \r\nfig = plt.figure(figsize=(15,5))\r\nax = fig.gca(projection='3d')\r\n#交换X,Y,可以旋转90度\r\nsurf=ax.plot_trisurf(df['X'], df['Y'], df['Z'], cmap=plt.cm.viridis, linewidth=0.2)\r\n# surf=surf.rotate(90)\r\nax.set_xlabel('Time', fontsize = 15)\r\nax.set_ylabel('Day', fontsize = 15)\r\nax.set_zlabel('Load', fontsize = 15)\r\nax.set_title('Predicted value of load', fontsize = 20)\r\nfig.colorbar( surf, shrink=0.5, aspect=5)\r\nplt.show()\r\n#********************\r\ndata = df_error\r\ndf=data.unstack().reset_index() \r\ndf.columns=[\"X\",\"Y\",\"Z\"]\r\n \r\ndf['X']=pd.Categorical(df['X'])\r\ndf['X']=df['X'].cat.codes\r\n \r\nfig = plt.figure(figsize=(15,5))\r\nax = fig.gca(projection='3d')\r\n# ax = fig.gca(projection='2d')\r\n#交换X,Y,可以旋转90度\r\nsurf=ax.plot_trisurf(df['Y'], df['X'], df['Z'], cmap=plt.cm.viridis, linewidth=0.2)\r\n# surf=surf.rotate(90)\r\n# cax = ax.matshow(surf, cmap='GnBu')\r\nax.set_xlabel('Time', fontsize = 15)\r\nax.set_ylabel('Day', fontsize = 15)\r\nax.set_zlabel('Load', fontsize = 15)\r\nax.set_title('Predicted error of load', fontsize = 20)\r\nfig.colorbar( surf, shrink=0.5, aspect=10)\r\nplt.show()\r\n#********************画误差图",
"_____no_output_____"
]
],
[
[
"请点击[此处](https://ai.baidu.com/docs#/AIStudio_Project_Notebook/a38e5576)查看本环境基本用法. <br>\nPlease click [here ](https://ai.baidu.com/docs#/AIStudio_Project_Notebook/a38e5576) for more detailed instruction``s. ",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecac2cf434ee58210e27f09401b559a36511fddf | 12,109 | ipynb | Jupyter Notebook | jupyter-notebook-CSE-110/.ipynb_checkpoints/week07-checkpoint.ipynb | vwolfley/cse110-22w-22 | f8b76778a1fbd92fd0e2be783ae93e20377e9d95 | [
"MIT"
] | null | null | null | jupyter-notebook-CSE-110/.ipynb_checkpoints/week07-checkpoint.ipynb | vwolfley/cse110-22w-22 | f8b76778a1fbd92fd0e2be783ae93e20377e9d95 | [
"MIT"
] | null | null | null | jupyter-notebook-CSE-110/.ipynb_checkpoints/week07-checkpoint.ipynb | vwolfley/cse110-22w-22 | f8b76778a1fbd92fd0e2be783ae93e20377e9d95 | [
"MIT"
] | null | null | null | 27.583144 | 214 | 0.455529 | [
[
[
"# CSE 110 Week 7\n\n## 07 Prepare: Checkpoint\n\n#### Assignment\nWrite a Python Program that does each of the following:\n\n1. Use a while loop to ask the user for a positive number (>= 0). Continue asking as long as the number is negative, then display the number. For example:\n\n2. Use a while loop, to simulate a child asking their parent for a piece of candy. Have the program keep looping until the user answers \"yes\", then have the program output \"Thank you.\" For example:\n\n\n#### Testing Procedure\nVerify that your program works correctly by following each step in this testing procedure:\n\n1. For the positive number program, enter several negative numbers, then a positive one.\n2. Try entering a positive number first, and ensure that it doesn't ask again.\n3. Try entering 0 and ensure that it correctly treats it as a positive number.\n4. For the piece of candy program, test your last loop by entering different amounts of no's before finally saying yes.\n5. Try saying \"yes\" the very first time, and ensure that it works as expected.",
"_____no_output_____"
]
],
[
[
"# 01 While Loop\nnum = int(input(\"Please type a positive number: \"))\n\nwhile num < 0:\n print(\"Sorry, that is a negative number. Please try again.\")\n num = int(input(\"Please type a positive number: \"))\n\nprint(f\"The number is: {num}\")",
"Please type a positive number: 0\nThe number is: 0\n"
],
[
"# 01 While Loop\nyes = ['yes', 'y']\nno = ['no','n']\n\nQ = input(\"May I have a piece of candy? \")\n\nwhile Q in no:\n Q = input(\"May I have a piece of candy? \")\n \nprint(\"Thank You!\")\n",
"May I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? n\nMay I have a piece of candy? y\nThank You!\n"
]
],
[
[
"## 07 Prepare: Team Activity\n### Guess My Number Game\n\n#### Assignment\n\nI. HAVING THE COMPUTER PICK A RANDOM NUMBER\n\n#### CORE REQUIREMENTS\n\n1. <p>Start by asking the user for the magic number. (In future steps, we will change this to have the computer generate a random number, but to get started, we'll just let the user decide what it is.)<br>\nAsk the user for a guess.<br>\nUsing an if statement, determine if the user needs to guess higher or lower next time, or tell them if they guessed it.</p>\n\n2. <p>Add a loop that keeps looping as long as the guess does not match the magic number.<br>\nAt this point, the user should be able to keep playing until they get the correct answer.</p>\n\n3. <p>Instead of having the user supply the magic number, import the random library and use it to generate a random number from 1 to 100.<br>\nPlay the game and make sure it works!</p>\n",
"_____no_output_____"
]
],
[
[
"import random\n\nnumber = random.randint(1, 10)\nprint(number)",
"5\n"
],
[
"# Core Requirement 1\nnumber = int(input(\"What is the magic number? \"))\nguess = int(input(\"What is your guess? \"))\n\nif guess > number:\n print(\"Lower\")\nelif guess < number:\n print(\"Higher\")\nelse:\n print(\"You guessed it!\")",
"What is the magic number? 6\nWhat is your guess? 6\nYou guessed it!\n"
],
[
"# Core Requirement 2\nnumber = int(input(\"What is the magic number? \"))\nguess = int(input(\"What is your guess? \"))\n\nwhile guess != number:\n if guess > number:\n print(\"Lower\")\n guess = int(input(\"Guess Again? \"))\n elif guess < number:\n print(\"Higher\")\n guess = int(input(\"Guess Again? \"))\n\nprint(\"You guessed it!\")",
"What is the magic number? 4\nWhat is your guess? 5\nLower\nGuess Again? 2\nHigher\nGuess Again? 7\nLower\nGuess Again? 4\nYou guessed it!\n"
],
[
"# Core Requirement 3\nimport random\n\nnumber = random.randint(1, 100)\nguess = int(input(\"Pick a number between 1 and 100: \"))\n\nwhile guess != number:\n if guess > number:\n print(\"Lower\")\n guess = int(input(\"Guess Again? \"))\n elif guess < number:\n print(\"Higher\")\n guess = int(input(\"Guess Again? \"))\n\nprint(\"You guessed it!\")",
"Pick a number between 1 and 100: 3\nHigher\nGuess Again? 4\nHigher\nGuess Again? 5\nHigher\nGuess Again? 1\nHigher\nGuess Again? 9\nLower\nGuess Again? 8\nYou guessed it!\n"
],
[
"# Stretch Challenge 2\nimport random\n\nprint(\"Welcome to the Game!\")\nnumber = random.randint(1, 5)\nguess = int(input(\"Pick a number between 1 and 100: \"))\ncount = 0\n\nwhile guess != number:\n if guess > number:\n print(\"Lower\")\n guess = int(input(\"Guess Again? \"))\n count += 1 \n elif guess < number:\n print(\"Higher\")\n guess = int(input(\"Guess Again? \"))\n count += 1 \ncount += 1\n\nif count == 1:\n word = \"try\"\nword = \"try's\"\n\nwin = (f'''\n{\"*\":*^80}\n*{f\"It took you {count} {word} to guess it!\":^78}*\n*{\"GAME OVER\":^78}*\n{\"*\":*^80}\n''')\n\nprint(win)",
"Welcome to the Game!\nPick a number between 1 and 100: 1\nHigher\nGuess Again? 2\nHigher\nGuess Again? 3\nHigher\nGuess Again? 4\n\n********************************************************************************\n* It took you 4 to guess it! *\n* GAME OVER *\n********************************************************************************\n\n"
],
[
"##### Stretch Challenge 3\nimport random\n\nagain = True\nyes = [\"yes\", \"y\"]\nprint(\"Welcome to the Game!\\n\")\n\nwhile again == True:\n number = random.randint(1, 5)\n guess = int(input(\"Pick a number between 1 and 100: \"))\n count = 0\n\n while guess != number:\n if guess > number:\n print(\"Lower\")\n guess = int(input(\"Guess Again? \"))\n count += 1 \n elif guess < number:\n print(\"Higher\")\n guess = int(input(\"Guess Again? \"))\n count += 1 \n count += 1\n\n if count == 1:\n word = \"try\"\n word = \"try's\"\n\n win = (f'''\n {\"*\":*^80}\n *{f\"It took you {count} {word} to guess it!\":^78}*\n *{\"GAME OVER\":^78}*\n {\"*\":*^80}\n ''')\n\n print(win)\n\n play_again = input(\"Do you want to play again? (Y/N) \").lower()\n\n if play_again in yes:\n print(play_again)\n again = True\n else:\n again = False\n\nprint(f'''\n*** Thanks for Playing! ***\n''')\n ",
"Welcome to the Game!\n\nPick a number between 1 and 100: 5\nLower\nGuess Again? 4\nLower\nGuess Again? 3\nLower\nGuess Again? 2\n\n ********************************************************************************\n * It took you 4 try's to guess it! *\n * GAME OVER *\n ********************************************************************************\n \nDo you want to play again? (Y/N) n\n\n*** Thanks for Playing! ***\n\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecac31cb0f6d95075d290920f8290a7a8db433b4 | 11,119 | ipynb | Jupyter Notebook | docs/source/examples/notebooks/planners_interface.ipynb | priyansh-1902/olympus | f57ad769918c0d5d805c439ab5ffbd180af698fa | [
"MIT"
] | 36 | 2020-10-10T14:05:40.000Z | 2022-02-12T07:21:47.000Z | docs/source/examples/notebooks/planners_interface.ipynb | priyansh-1902/olympus | f57ad769918c0d5d805c439ab5ffbd180af698fa | [
"MIT"
] | 12 | 2020-10-14T09:04:06.000Z | 2021-10-01T19:25:34.000Z | docs/source/examples/notebooks/planners_interface.ipynb | priyansh-1902/olympus | f57ad769918c0d5d805c439ab5ffbd180af698fa | [
"MIT"
] | 8 | 2020-10-24T12:43:45.000Z | 2022-02-12T07:21:50.000Z | 36.69637 | 416 | 0.616512 | [
[
[
"# Planners Interfaces",
"_____no_output_____"
],
[
"Optimization algorithms in **Olympus** can be accessed via ``Planners`` objects. They have higher- and lower-level methods to allow more/less control of the optimization. ",
"_____no_output_____"
],
[
"The most important methods for any ``Planner`` in **Olympus** are:\n- ``optimize``\n- ``recommend``\n- ``ask`` and ``tell``",
"_____no_output_____"
],
[
"Here we show how these three interfaces can be used to optimize a surface of choice. Let's start by instanciating a specific optimizer and emulator",
"_____no_output_____"
]
],
[
[
"from olympus import Planner, Emulator, Campaign\n\nplanner = Planner('Hyperopt', goal='maximize')\nemulator = Emulator(dataset='hplc', model='BayesNeuralNet')",
"\u001b[0;37m[INFO] Loading emulator using a BayesNeuralNet model for the dataset hplc...\n\u001b[0m"
]
],
[
[
"### Optimize",
"_____no_output_____"
]
],
[
[
"# optimise the surface for 5 iterations\ncampaign = planner.optimize(emulator, num_iter=5, verbose=True)",
"\u001b[0;37m[INFO] Optimize iteration 1\n\u001b[0m\u001b[0;37m[INFO] Obtaining parameters from planner...\n\u001b[0m\u001b[0;37m[INFO] Obtaining measurement from emulator...\n\u001b[0m\u001b[0;37m[INFO] Optimize iteration 2\n\u001b[0m\u001b[0;37m[INFO] Obtaining parameters from planner...\n\u001b[0m\u001b[0;37m[INFO] Obtaining measurement from emulator...\n\u001b[0m\u001b[0;37m[INFO] Optimize iteration 3\n\u001b[0m\u001b[0;37m[INFO] Obtaining parameters from planner...\n\u001b[0m\u001b[0;37m[INFO] Obtaining measurement from emulator...\n\u001b[0m\u001b[0;37m[INFO] Optimize iteration 4\n\u001b[0m\u001b[0;37m[INFO] Obtaining parameters from planner...\n\u001b[0m\u001b[0;37m[INFO] Obtaining measurement from emulator...\n\u001b[0m\u001b[0;37m[INFO] Optimize iteration 5\n\u001b[0m\u001b[0;37m[INFO] Obtaining parameters from planner...\n\u001b[0m\u001b[0;37m[INFO] Obtaining measurement from emulator...\n\u001b[0m"
],
[
"# print the results\nfor p, v in zip(campaign.params, campaign.values):\n print(p, v)",
"[3.99634412e-02 5.92366755e-02 5.56513608e-01 1.32164115e+00\n 1.28585018e+02 2.29232642e+00] [794.28760118]\n[5.21297934e-02 4.11513637e-02 8.28823539e-01 2.12991777e+00\n 1.34636851e+02 4.56346874e+00] [190.70192684]\n[6.88022674e-02 2.31711378e-02 7.86579842e-01 1.45240663e+00\n 1.06799456e+02 3.21836802e+00] [25.05118119]\n[3.57485194e-02 1.01848064e-02 4.79433112e-01 1.59496475e+00\n 9.11006486e+01 8.93052795e+00] [837.64479039]\n[3.19394342e-02 1.03955562e-02 2.87069883e-01 2.24478218e+00\n 1.22440051e+02 2.82028857e+00] [2000.172279]\n"
]
],
[
[
"### Recommend",
"_____no_output_____"
],
[
"As you can see, the ``optimize`` method is very convenient, but does not allow much control in what happens at each step of the optimization. The ``recommend`` method runs instead a single iteration of the optimization, such that you can have access to the parameters and measurements at each iteraion. As an example, we perform the same 10-step optimization as above but using ``recommend`` instead this time.",
"_____no_output_____"
]
],
[
[
"max_iter = 5\n\n# instantiate a Campaign object, which stores the results of the optimization\ncampaign = Campaign()\n\n# tell the planner what is the optimization domain\nplanner.set_param_space(emulator.param_space)\n\nfor i in range(max_iter):\n print(f\"Iter {i+1}\\n------\")\n \n # ask the planner for a new set of parameters\n params = planner.recommend(observations=campaign.observations)\n print('Parameters:', params)\n \n # evaluate the merit of the new parameters\n values = emulator.run(params.to_array(), return_paramvector=True)\n print('Values:', values[0])\n\n # store parameter and measurement pair in campaign\n campaign.add_observation(params, values)\n \n print()",
"Iter 1\n------\nParameters: ParamVector(sample_loop = 0.04214239677999049, additional_volume = 0.053410186023081355, tubing_volume = 0.6886106912572801, sample_flow = 1.2313387694567246, push_speed = 120.33877426478782, wait_time = 9.831562416147625)\nValues: ParamVector(peak_area = 182.92490526330087)\n\nIter 2\n------\nParameters: ParamVector(sample_loop = 0.043293140897302164, additional_volume = 0.048965823324975226, tubing_volume = 0.686463996645267, sample_flow = 1.8937519623656645, push_speed = 98.51430725969507, wait_time = 5.601818498433116)\nValues: ParamVector(peak_area = 215.42974384808343)\n\nIter 3\n------\nParameters: ParamVector(sample_loop = 0.07643185535530703, additional_volume = 0.05667404894922595, tubing_volume = 0.6650598532796427, sample_flow = 1.916183318424112, push_speed = 122.7209899443508, wait_time = 1.510488953562232)\nValues: ParamVector(peak_area = 324.8829338472122)\n\nIter 4\n------\nParameters: ParamVector(sample_loop = 0.03882589187468909, additional_volume = 0.012301890870887077, tubing_volume = 0.278553853395321, sample_flow = 2.2053614339750007, push_speed = 104.96898650189364, wait_time = 9.562302646869888)\nValues: ParamVector(peak_area = 2072.8976459933033)\n\nIter 5\n------\nParameters: ParamVector(sample_loop = 0.009822229434326219, additional_volume = 0.029049327494845626, tubing_volume = 0.8460893640743111, sample_flow = 1.3473238976680675, push_speed = 123.70914753868718, wait_time = 4.0203055504668015)\nValues: ParamVector(peak_area = 0.0)\n\n"
]
],
[
[
"### Ask and Tell",
"_____no_output_____"
],
[
"Finally, one can use the ``ask`` and ``tell`` methods instead of ``recommend``. This allows to control what the planner knows before suggesting the next experiment to run. However, note that not all planners use the history of the optimization when to choose what experiment to propose next.",
"_____no_output_____"
]
],
[
[
"max_iter = 5\n\n# instantiate a Campaign object, which stores the results of the optimization\ncampaign = Campaign()\n\n# tell the planner what is the optimization domain\nplanner.set_param_space(emulator.param_space)\n\nfor i in range(max_iter):\n print(f\"Iter {i+1}\\n------\")\n \n # tell the planner about the optimization history\n planner.tell(campaign.observations)\n \n # ask the planner for a new set of parameters\n params = planner.ask()\n print('Parameters:', params)\n \n # evaluate the merit of the new parameters\n values = emulator.run(params.to_array(), return_paramvector=True)\n print('Values:', values[0])\n\n # store parameter and measurement pair in campaign\n campaign.add_observation(params, values)\n \n print()",
"Iter 1\n------\nParameters: ParamVector(sample_loop = 0.03549386694005813, additional_volume = 0.03330348781561569, tubing_volume = 0.20541452615744327, sample_flow = 0.9918564339279039, push_speed = 85.3836698503327, wait_time = 7.732563361348338)\nValues: ParamVector(peak_area = 0.0)\n\nIter 2\n------\nParameters: ParamVector(sample_loop = 0.07948685024663711, additional_volume = 0.01405398186830723, tubing_volume = 0.4008361777353059, sample_flow = 1.213248706166157, push_speed = 122.85990779892668, wait_time = 1.9588104184592865)\nValues: ParamVector(peak_area = 1087.4971033499935)\n\nIter 3\n------\nParameters: ParamVector(sample_loop = 0.07459429555877291, additional_volume = 0.04632047521192829, tubing_volume = 0.8636585456822277, sample_flow = 2.4340302954514517, push_speed = 127.34080433592416, wait_time = 9.348306043102033)\nValues: ParamVector(peak_area = 0.0)\n\nIter 4\n------\nParameters: ParamVector(sample_loop = 0.04469537573702059, additional_volume = 0.016678012840125878, tubing_volume = 0.6607858069330779, sample_flow = 1.8523761717851137, push_speed = 138.98260252526268, wait_time = 9.501125947667138)\nValues: ParamVector(peak_area = 330.6013244397631)\n\nIter 5\n------\nParameters: ParamVector(sample_loop = 0.05279966827346898, additional_volume = 0.04876100437059912, tubing_volume = 0.7023206540114464, sample_flow = 1.0172256976081377, push_speed = 138.30474028379786, wait_time = 1.4750453547630402)\nValues: ParamVector(peak_area = 70.43434451522799)\n\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
]
] |
ecac339881948221d5d7f244e550caed29f5ad4a | 30,735 | ipynb | Jupyter Notebook | CS331/Test.ipynb | Quananhle/Python | 96b5901159ca18d5908d6dfb46a94080f8ca2ec6 | [
"Apache-2.0"
] | 1 | 2021-06-10T22:08:21.000Z | 2021-06-10T22:08:21.000Z | CS331/Test.ipynb | Quananhle/Python | 96b5901159ca18d5908d6dfb46a94080f8ca2ec6 | [
"Apache-2.0"
] | null | null | null | CS331/Test.ipynb | Quananhle/Python | 96b5901159ca18d5908d6dfb46a94080f8ca2ec6 | [
"Apache-2.0"
] | 1 | 2021-05-13T20:48:43.000Z | 2021-05-13T20:48:43.000Z | 30.043988 | 113 | 0.4177 | [
[
[
"from IPython.core.interactiveshell import InteractiveShell\nInteractiveShell.ast_node_interactivity = \"all\"",
"_____no_output_____"
],
[
"l = []\n\nfor letter in \"I really realy like cake\":\n l.append(letter)\nprint(l)",
"_____no_output_____"
],
[
"#List comprehension\nl = \"I really really like cake\"\nl = [letter for letter in l] # internal for loop\nprint(l)",
"_____no_output_____"
],
[
"lst = [x+y for x in ['a', 'the', 'one']for y in [' car', ' fish']]\nlst",
"_____no_output_____"
],
[
"class MyIt:\n def __init__(self):\n self.x = 100\n \n def __iter__(self):\n return self\n \n def __next__(self):\n if self.x < 0:\n raise StopIteration\n else:\n self.x -= 20\n return self.x",
"_____no_output_____"
],
[
"[x for x in MyIt()]",
"_____no_output_____"
],
[
"def my_gen(i, j, k):\n while i <= j:\n if i % k == 0:\n yield k\n yield i\n i += 1",
"_____no_output_____"
],
[
"[x for x in my_gen(1, 8, 2)]",
"_____no_output_____"
],
[
"class ArrayList:\n def __int__(self):\n self.data = []\n\n def insert_all(self,idx,other):\n for _ in range(len(other)):\n self.data.append(None)\n x = 0\n for i in range(idx,len(self.data)-len(other)+1):\n print(i)\n if i == len(self.data)-len(other):\n self.data[i] = other[x]\n else:\n self.data[i+len(other)] = self.data[i]\n self.data[i] = other[x]\n x += 1",
"_____no_output_____"
],
[
"l = ArrayList\nl.insert_all(3, ['a', 'b', 'c'], [0,1,2,3,4])",
"_____no_output_____"
],
[
"accums = 0\nfor j in range(9, -1, -1):\n print (accums)\n accums += lst[j]",
"_____no_output_____"
],
[
"accums = 0\nl = [1,2,3,4,5,6,7,8,9]\nfor i in range (len(l)-1, -1, -2):\n print (i)\n accums += l[i]\n print (\"accums \", accums)",
"_____no_output_____"
],
[
"l[-1]",
"_____no_output_____"
],
[
"def gen(lim):\n print (\"Lim: \", lim)\n for i in range (lim):\n yield (i)\ngen(5)",
"_____no_output_____"
],
[
"class LinkedList:\n class Node:\n def __init__(self, val, prior=None, next=None):\n self.val = val\n self.prior = prior\n self.next = next\n \n def __init__(self):\n self.head = LinkedList.Node(None)\n self.head.prior = self.head.next = self.head\n self.count = 0\n self.cursor = None\n self.cursor_idx = -1\n \n def append(self, val):\n n = LinkedList.Node(val, prior=self.head.prior, next=self.head)\n self.head.prior.next = self.head.prior = n\n self.count += 1\n \n def set_cursor(self, idx):\n #assert idx < self.count\n self.cursor = self.head.next\n for _ in range(idx):\n self.cursor = self.cursor.next\n self.cursor_idx = idx\n print(self.cursor_idx)\n \n ### don't modify any code above this line! ###\n\n def del_after_cursor(self):\n assert self.cursor\n # your code below\n if self.count > 1:\n self.count = self.cursor_idx + 1\n self.cursor.next = self.head\n self.head.prior = self.cursor",
"_____no_output_____"
],
[
"l = LinkedList() \nfor x in range(4): \n l.append(x)\nl.set_cursor(1)",
"_____no_output_____"
],
[
"l.del_after_cursor()",
"_____no_output_____"
],
[
"\n# Python code to insert a node in AVL tree \n \n# Generic tree node class \nclass TreeNode(object): \n def __init__(self, val): \n self.val = val \n self.left = None\n self.right = None\n self.height = 1\n \n# AVL tree class which supports the \n# Insert operation \nclass AVL_Tree(object): \n \n # Recursive function to insert key in \n # subtree rooted with node and returns \n # new root of subtree. \n def insert(self, root, key): \n \n # Step 1 - Perform normal BST \n if not root: \n return TreeNode(key) \n elif key < root.val: \n root.left = self.insert(root.left, key) \n else: \n root.right = self.insert(root.right, key) \n \n # Step 2 - Update the height of the \n # ancestor node \n root.height = 1 + max(self.getHeight(root.left), \n self.getHeight(root.right)) \n \n # Step 3 - Get the balance factor \n balance = self.getBalance(root) \n \n # Step 4 - If the node is unbalanced, \n # then try out the 4 cases \n # Case 1 - Left Left \n if balance > 1 and key < root.left.val: \n return self.rightRotate(root) \n \n # Case 2 - Right Right \n if balance < -1 and key > root.right.val: \n return self.leftRotate(root) \n \n # Case 3 - Left Right \n if balance > 1 and key > root.left.val: \n root.left = self.leftRotate(root.left) \n return self.rightRotate(root) \n \n # Case 4 - Right Left \n if balance < -1 and key < root.right.val: \n root.right = self.rightRotate(root.right) \n return self.leftRotate(root) \n \n return root \n \n def leftRotate(self, z): \n \n y = z.right \n T2 = y.left \n \n # Perform rotation \n y.left = z \n z.right = T2 \n \n # Update heights \n z.height = 1 + max(self.getHeight(z.left), \n self.getHeight(z.right)) \n y.height = 1 + max(self.getHeight(y.left), \n self.getHeight(y.right)) \n \n # Return the new root \n return y \n \n def rightRotate(self, z): \n \n y = z.left \n T3 = y.right \n \n # Perform rotation \n y.right = z \n z.left = T3 \n \n # Update heights \n z.height = 1 + max(self.getHeight(z.left), \n self.getHeight(z.right)) \n y.height = 1 + max(self.getHeight(y.left), \n self.getHeight(y.right)) \n \n # Return the new root \n return y \n \n def getHeight(self, root): \n if not root: \n return 0\n \n return root.height \n \n def getBalance(self, root): \n if not root: \n return 0\n \n return self.getHeight(root.left) - self.getHeight(root.right) \n \n def preOrder(self, root): \n \n if not root: \n return\n \n print(\"{0} \".format(root.val), end=\"\") \n self.preOrder(root.left) \n self.preOrder(root.right) \n \n \n# Driver program to test above function \nmyTree = AVL_Tree() \nroot = None\n \nroot = myTree.insert(root, 5) \nroot = myTree.insert(root, 2) \nroot = myTree.insert(root, 9) \nroot = myTree.insert(root, 6) \nroot = myTree.insert(root, 3) \nroot = myTree.insert(root, 8) \nroot = myTree.insert(root, 1) \n \n\"\"\"The constructed AVL Tree would be \n 30 \n / \\ \n 20 40 \n / \\ \\ \n 10 25 50\"\"\"\n\n\n\"\"\"\n 5\n / \\\n 2 \n \n\"\"\" \nroot\n# Preorder Traversal \nprint(\"Preorder traversal of the\", \n \"constructed AVL tree is\") \nmyTree.preOrder(root) \nprint() \n \n# This code is contributed by Ajitesh Pathak \n",
"_____no_output_____"
],
[
"# AVL tree implementation in Python\n\nimport sys\n\nclass TreeNode(object): \n def __init__(self, key): \n self.key = key \n self.left = None\n self.right = None\n self.height = 1\n\nclass AVL_Tree(object): \n\n def insertNode(self, root, key): \n \n if not root: \n return TreeNode(key) \n elif key < root.key: \n root.left = self.insertNode(root.left, key) \n else: \n root.right = self.insertNode(root.right, key) \n\n root.height = 1 + max(self.getHeight(root.left), \n self.getHeight(root.right)) \n \n balanceFactor = self.getBalance(root) \n\n if balanceFactor > 1:\n if key < root.left.key: \n return self.rightRotate(root) \n else:\n root.left = self.leftRotate(root.left) \n return self.rightRotate(root)\n \n if balanceFactor < -1:\n if key > root.right.key: \n return self.leftRotate(root)\n else:\n root.right = self.rightRotate(root.right) \n return self.leftRotate(root)\n \n return root \n\n def delete(self, root, key): \n\n if not root: \n return root \n\n elif key < root.key: \n root.left = self.delete(root.left, key) \n\n elif key > root.key: \n root.right = self.delete(root.right, key) \n\n else: \n if root.left is None: \n temp = root.right \n root = None\n return temp \n\n elif root.right is None: \n temp = root.left \n root = None\n return temp \n\n temp = self.getMinValueNode(root.right) \n root.key = temp.key \n root.right = self.delete(root.right, \n temp.key) \n\n if root is None: \n return root \n\n root.height = 1 + max(self.getHeight(root.left), \n self.getHeight(root.right)) \n\n balanceFactor = self.getBalance(root) \n\n if balanceFactor > 1:\n if self.getBalance(root.left) >= 0: \n return self.rightRotate(root) \n else:\n root.left = self.leftRotate(root.left) \n return self.rightRotate(root) \n\n\n if balanceFactor < -1:\n if self.getBalance(root.right) <= 0: \n return self.leftRotate(root) \n else:\n root.right = self.rightRotate(root.right) \n return self.leftRotate(root)\n\n return root \n\n def leftRotate(self, z): \n\n y = z.right \n T2 = y.left \n\n y.left = z \n z.right = T2 \n\n z.height = 1 + max(self.getHeight(z.left), \n self.getHeight(z.right)) \n y.height = 1 + max(self.getHeight(y.left), \n self.getHeight(y.right)) \n\n return y \n\n def rightRotate(self, z): \n\n y = z.left \n T3 = y.right \n\n y.right = z \n z.left = T3 \n\n z.height = 1 + max(self.getHeight(z.left), \n self.getHeight(z.right)) \n y.height = 1 + max(self.getHeight(y.left), \n self.getHeight(y.right)) \n\n return y \n\n def getHeight(self, root): \n if not root: \n return 0\n\n return root.height \n\n def getBalance(self, root): \n if not root: \n return 0\n\n return self.getHeight(root.left) - self.getHeight(root.right) \n\n def getMinValueNode(self, root): \n if root is None or root.left is None: \n return root \n\n return self.getMinValueNode(root.left) \n\n def preOrder(self, root): \n\n if not root: \n return\n\n print(\"{0} \".format(root.key), end=\"\") \n self.preOrder(root.left) \n self.preOrder(root.right) \n \n def printHelper(self, currPtr, indent, last):\n if currPtr != None:\n sys.stdout.write(indent)\n if last:\n sys.stdout.write(\"R----\")\n indent += \" \"\n else:\n sys.stdout.write(\"L----\")\n indent += \"| \"\n\n print(currPtr.key)\n\n self.printHelper(currPtr.left, indent, False)\n self.printHelper(currPtr.right, indent, True)\n\n\nmyTree = AVL_Tree() \nroot = None\nnums = [33, 13, 52, 9, 21, 61, 8, 11] \n\nfor num in nums: \n root = myTree.insertNode(root, num) \n\nmyTree.printHelper(root, \"\", True)\n\nkey = 13\nroot = myTree.delete(root, key) \n\nprint(\"After Deletion: \")\nmyTree.printHelper(root, \"\", True)\n",
"_____no_output_____"
],
[
"from collections import OrderedDict\n\n#input:\ncol = []\nresult_col = []\nedges = {}\ntrees = []\nn = int(input(\"Enter size of matrix: \"))\nprint(\"\\nplease enter the elements row by row separated by spaces\")\nfor i in range(0, n):\n while(True):\n row = list(map(int,input(\"\\nEnter the \" + str(i+1) + \"th row : \").strip().split()))[:n] \n print(row)\n if (len(row) == n):\n break;\n else:\n print(\"Insufficient n of elements. Please enter \" + str(n) + \" elements\")\n #save row\n col.append(row)\n for idx, val in enumerate(row):\n if idx > i:\n #included negative values\n #print(i, idx, val)\n #save edges in format: (row, col): val\n edges[(i, idx)] = val\n\nprint(\"\\n\")\nprint(\"Input matrix: \")\nfor row in col:\n print(row)\n\nsortedEdges = OrderedDict(sorted(edges.items(), key=lambda x: x[1]))\ntoBeDeleted = []\nfor key, val in sortedEdges.items():\n\n if val > 0:\n \n #print(\"\\tkeys \"+ str(key))\n #add into tree:\n #if trees is empty:\n if not trees:\n smalltree = []\n smalltree.append(key[0])\n smalltree.append(key[1]) \n trees.append(smalltree)\n #this edge stays\n #if not empty\n else:\n #print(\"ongoing:\")\n #print(key)\n\n presence0 = 0\n presence1 = 0\n idx_0 = -1\n idx_1 = -1\n connects = 0\n for idx, smalltree in enumerate(trees):\n if (key[0] in smalltree and presence1 == 1) or (key[1] in smalltree and presence0 == 1):\n #combine\n nowidx = idx_0\n if presence1 == 1:\n nowidx = idx_1\n\n for x in trees[idx]:\n trees[nowidx].append(x)\n trees.pop(idx)\n presence1 = 1\n presence0 = 1\n connects = 1\n break;\n \n if key[0] in smalltree and presence0 == 0:\n #print(\"first element present.\")\n presence0 = 1\n idx_0 = idx\n if key[1] in smalltree and presence1 == 0:\n #print(\"second element present.\")\n presence1 = 1\n idx_1 = idx\n\n\n if presence0 == 0 and presence1 == 0:\n #print(\"not present\")\n smalltree = []\n smalltree.append(key[0])\n smalltree.append(key[1])\n trees.append(smalltree)\n #thhis edge stays\n elif presence0 == 0 and presence1 == 1:\n trees[idx_1].append(key[0])\n elif presence0 == 1 and presence1 == 0:\n trees[idx_0].append(key[1])\n else:\n if len(trees) == 1 and connects == 0:\n toBeDeleted.append(key)\n\n#print(toBeDeleted)\n#print(\"sorted edges:\")\n#print(sortedEdges)\nfor key in toBeDeleted:\n sortedEdges[key] = -1\n#print(\"sorted edges after delete:\")\n#print(sortedEdges)\n#print(\"trees:\")\n#print(trees)\nfor i in range(0, len(col)):\n row = []\n for j in range(0, len(col)):\n if i < j:\n row.append(sortedEdges[(i, j)])\n if i == j:\n row.append(0)\n if i > j:\n #inverted\n row.append(sortedEdges[(j, i)])\n result_col.append(row)\nprint(\"\\n\")\nprint(\"Output matrix: \")\nfor row in result_col:\n print(row)\n\n#print(sortedEdges\n#sort edges:",
"Enter size of matrix: 3\n\nplease enter the elements row by row separated by spaces\n\nEnter the 1th row : 1 2 3\n[1, 2, 3]\n\nEnter the 2th row : 2 3 4\n[2, 3, 4]\n\nEnter the 3th row : 3 4 5\n[3, 4, 5]\n\n\nInput matrix: \n[1, 2, 3]\n[2, 3, 4]\n[3, 4, 5]\n\n\nOutput matrix: \n[0, 2, 3]\n[2, 0, -1]\n[3, -1, 0]\n"
],
[
"# Python program to find the shortest \n# path between a given source cell \n# to a destination cell. \n \nfrom collections import deque \nROW = 9\nCOL = 10\n \n# To store matrix cell cordinates \nclass Point: \n def __init__(self,x: int, y: int): \n self.x = x \n self.y = y \n \n# A data structure for queue used in BFS \nclass queueNode: \n def __init__(self,pt: Point, dist: int): \n self.pt = pt # The cordinates of the cell \n self.dist = dist # Cell's distance from the source \n \n# Check whether given cell(row,col) \n# is a valid cell or not \ndef isValid(row: int, col: int): \n return (row >= 0) and (row < ROW) and (col >= 0) and (col < COL) \n \n# These arrays are used to get row and column \n# numbers of 4 neighbours of a given cell \nrowNum = [-1, 0, 0, 1] \ncolNum = [0, -1, 1, 0] \n \n# Function to find the shortest path between \n# a given source cell to a destination cell. \ndef BFS(mat, src: Point, dest: Point): \n \n # check source and destination cell \n # of the matrix have value 1 \n if mat[src.x][src.y]!=1 or mat[dest.x][dest.y]!=1: \n return -1\n \n visited = [[False for i in range(COL)] for j in range(ROW)] \n \n # Mark the source cell as visited \n visited[src.x][src.y] = True\n \n # Create a queue for BFS \n q = deque() \n \n # Distance of source cell is 0 \n s = queueNode(src,0) \n q.append(s) # Enqueue source cell \n \n # Do a BFS starting from source cell \n while q: \n \n curr = q.popleft() # Dequeue the front cell \n \n # If we have reached the destination cell, \n # we are done \n pt = curr.pt \n if pt.x == dest.x and pt.y == dest.y: \n return curr.dist \n \n # Otherwise enqueue its adjacent cells \n for i in range(4): \n row = pt.x + rowNum[i] \n col = pt.y + colNum[i] \n \n # if adjacent cell is valid, has path \n # and not visited yet, enqueue it. \n if (isValid(row,col) and mat[row][col] == 1 and not visited[row][col]): \n visited[row][col] = True\n Adjcell = queueNode(Point(row,col),curr.dist+1) \n q.append(Adjcell) \n \n # Return -1 if destination cannot be reached \n return -1\n \n# Driver code \ndef main(): \n mat = [[1, 1, 0, 0, 0],\n [0, 1, 1, 0, 0],\n [0, 0, 1, 0, 0],\n [0, 0, 1, 0, 0],\n [0, 0, 1, 1, 1]] \n source = Point(0,0) \n dest = Point(0,1) \n \n dist = BFS(mat,source,dest) \n \n if dist!=-1: \n print(\"Shortest Path is\",dist) \n else: \n print(\"Shortest Path doesn't exist\") \nmain() ",
"Shortest Path is 1\n"
],
[
"from collections import deque \nFINAL_ROW = 9\nFINAL_COL = 10\n# Storing matrix cell cordinates \nclass Node:\n def __init__(self, x:int, y:int): \n self.x = x \n self.y = y \n# Implementing queue used in BFS\nclass Queue: \n def __init__(self, node:Node, dist:int): \n self.node = node\n self.dist = dist\nrowNum = [-1, 0, 0, 1] \ncolNum = [0, -1, 1, 0]\n# Check if a given cell(row,col) is a valid\ndef check_valid(row: int, col: int): \n return (row >= 0) and (row < FINAL_ROW) and (col >= 0) and (col < FINAL_COL) \n# Function to find the shortest path from the start point to the end point \ndef shortest_path(matrix, start: Node, end: Node): \n # check start and end points of the matrix have value 1 \n if matrix[start.x][start.y] !=1 or matrix[end.x][end.y] !=1: \n return -1\n visited = [[False for i in range(FINAL_COL)] for j in range(FINAL_ROW)] \n # Mark if visited\n visited[start.x][start.y] = True\n # Create a queue for breadth-first search\n queue = deque() \n s = Queue(start,0) \n queue.append(s)\n while queue: \n curr = queue.popleft()\n node = curr.node \n if node.x == end.x and node.y == end.y: \n return curr.dist \n for i in range(4): \n row = node.x + rowNum[i] \n col = node.y + colNum[i] \n if (check_valid(row,col) and matrix[row][col] == 1 and not visited[row][col]): \n visited[row][col] = True\n x = Queue(Node(row,col),curr.dist+1) \n queue.append(x) \n # If destination is not reachable, return -1\n return -1\n# Driver code \ndef main(): \n mat = [[1, 1, 0, 0, 0],\n [0, 1, 1, 0, 0],\n [0, 0, 1, 0, 0],\n [0, 0, 1, 0, 0],\n [0, 0, 1, 1, 1]] \n source = Node(0,0) \n dest = Node(3,2) \n \n dist = shortest_path(mat,source,dest) \n \n if dist!=-1: \n print(\"Shortest Path is\",dist) \n else: \n print(\"Shortest Path doesn't exist\") \nmain() ",
"Shortest Path is 5\n"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecac3f85b2c158d67cf8a2c3290ae8b98908ad99 | 28,750 | ipynb | Jupyter Notebook | research_code_notebooks/3_buggy_notebook.ipynb | gkaradzhov/research_code_jupyter | 7cc5d4a134f7facbccdbc0e74e4270f001acb3bd | [
"Apache-2.0"
] | null | null | null | research_code_notebooks/3_buggy_notebook.ipynb | gkaradzhov/research_code_jupyter | 7cc5d4a134f7facbccdbc0e74e4270f001acb3bd | [
"Apache-2.0"
] | 3 | 2020-03-24T16:47:03.000Z | 2021-03-20T00:42:02.000Z | research_code_notebooks/3_buggy_notebook.ipynb | gkaradzhov/research_code_jupyter | 7cc5d4a134f7facbccdbc0e74e4270f001acb3bd | [
"Apache-2.0"
] | null | null | null | 29.456967 | 98 | 0.245948 | [
[
[
"import pandas as pd",
"_____no_output_____"
],
[
"df = pd.read_csv('zoo.data', header=None)",
"_____no_output_____"
],
[
"df.columns",
"_____no_output_____"
],
[
"df1 = df.drop(17, axis=1)",
"_____no_output_____"
],
[
"df1[13] = df1[13] == 4",
"_____no_output_____"
],
[
"df1 = df1[df1[13] == True]",
"_____no_output_____"
],
[
"print(len(df1))",
"38\n"
],
[
"df1",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecac451cfa95fa909ebb15ab14137d411ce59a71 | 4,328 | ipynb | Jupyter Notebook | solutions/monty_soln.ipynb | chwebster/ThinkBayes2 | 49af0e36c38c2656d7b91117cfa2b019ead81988 | [
"MIT"
] | 1,337 | 2015-01-06T06:23:55.000Z | 2022-03-31T21:06:21.000Z | solutions/monty_soln.ipynb | chwebster/ThinkBayes2 | 49af0e36c38c2656d7b91117cfa2b019ead81988 | [
"MIT"
] | 43 | 2015-04-23T13:14:15.000Z | 2022-01-04T12:55:59.000Z | solutions/monty_soln.ipynb | chwebster/ThinkBayes2 | 49af0e36c38c2656d7b91117cfa2b019ead81988 | [
"MIT"
] | 1,497 | 2015-01-13T22:05:32.000Z | 2022-03-30T09:19:53.000Z | 22.194872 | 456 | 0.518484 | [
[
[
"# Think Bayes\n\nThis notebook presents example code and exercise solutions for Think Bayes.\n\nCopyright 2018 Allen B. Downey\n\nMIT License: https://opensource.org/licenses/MIT",
"_____no_output_____"
]
],
[
[
"# Configure Jupyter so figures appear in the notebook\n%matplotlib inline\n\n# Configure Jupyter to display the assigned value after an assignment\n%config InteractiveShell.ast_node_interactivity='last_expr_or_assign'\n\n# import classes from thinkbayes2\nfrom thinkbayes2 import Hist, Pmf, Suite",
"_____no_output_____"
]
],
[
[
"**Exercise:** Let's consider [a more general version of the Monty Hall problem](https://en.wikipedia.org/wiki/Monty_Hall_problem#Other_host_behaviors) where Monty is more unpredictable. As before, Monty never opens the door you chose (let's call it A) and never opens the door with the prize. So if you choose the door with the prize, Monty has to decide which door to open. Suppose he opens B with probability `p` and C with probability `1-p`.\n\n1. If you choose A and Monty opens B, what is the probability that the car is behind A, in terms of `p`?\n\n2. What if Monty opens C?\n\nHint: you might want to use SymPy to do the algebra for you. ",
"_____no_output_____"
]
],
[
[
"from sympy import symbols\np = symbols('p')",
"_____no_output_____"
],
[
"# Solution\n\n# Here's the solution if Monty opens B.\n\npmf = Pmf('ABC')\npmf['A'] *= p\npmf['B'] *= 0\npmf['C'] *= 1\npmf.Normalize()\npmf['A'].simplify()",
"_____no_output_____"
],
[
"# Solution\n\n# When p=0.5, the result is what we saw before\n\npmf['A'].evalf(subs={p:0.5})",
"_____no_output_____"
],
[
"# Solution\n\n# When p=0.0, we know for sure that the prize is behind C\n\npmf['C'].evalf(subs={p:0.0})",
"_____no_output_____"
],
[
"# Solution\n\n# And here's the solution if Monty opens C.\n\npmf = Pmf('ABC')\npmf['A'] *= 1-p\npmf['B'] *= 1\npmf['C'] *= 0\npmf.Normalize()\npmf['A'].simplify()",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
]
] |
ecac526842082c3b217fde0764cd84244797b7cc | 292,568 | ipynb | Jupyter Notebook | Covid.ipynb | JeanRintoul/Covid-19 | 3f9e60dccb665a9a890a8487ba8cb2db0f04af3f | [
"Apache-2.0"
] | null | null | null | Covid.ipynb | JeanRintoul/Covid-19 | 3f9e60dccb665a9a890a8487ba8cb2db0f04af3f | [
"Apache-2.0"
] | null | null | null | Covid.ipynb | JeanRintoul/Covid-19 | 3f9e60dccb665a9a890a8487ba8cb2db0f04af3f | [
"Apache-2.0"
] | null | null | null | 608.24948 | 68,660 | 0.928642 | [
[
[
"<a href=\"https://colab.research.google.com/github/JeanRintoul/Covid-19/blob/master/Covid.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
],
[
"Covid-19 is showing how ill-prepared we are to be a connected world. Following the [Kaiser Nurse in California who couldn't get testing despite being symptomatic](https://thehill.com/policy/healthcare/486235-quarantined-nurse-in-california-warns-not-enough-is-being-done-to-combat?fbclid=IwAR3K17BUFBHYIOgvxqYJ_2HaCm3xKsqwls6jHLAn1hDBWkY0K684HoM0yNM) who suggested testing is not available, I realised that testing is woefully broken in the US. In the UK testing has been more extensive due to the NHS, and their daily case rate seems to be increasing more slowly than the US. I assumed that anyone could be tested in the UK, though today(mon 9th March) I talked to a Nurse at my local GP. She told me how some sick patients from Northern Italy came in and spoke with a GP who later tested positive for Coronavirus. The GP was not eligible for testing for Coronavirus because they had no symptoms, and they have continued to see hundreds of patients since. This is a clear risk factor, and suggests not enough is being done to contain the virus. \n\nWe have failed to contains the virus, but we are also failing to act decisively to curb the outbreak. This is due to the equal in magnitude problem of how to shut down the worlds economy? What happens to the have nots, will they riot or starve or be evicted by their landlords when they can't pay the rent? How can we afford to effectively isolate? Many are incentivized to put others at risk due to economic necessity. \n\n",
"_____no_output_____"
],
[
"# Time Series Comparisons. ",
"_____no_output_____"
],
[
"Data is taken from John Hopkins data set which is updated nightly on github. ",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom datetime import datetime\n\nconfirmed_csv = \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Confirmed.csv\"\ndead_csv = \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Deaths.csv\"\nrecovered_csv = \"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_19-covid-Recovered.csv\"\nconfirmed = pd.read_csv(confirmed_csv).drop(['Lat','Long','Province/State'], axis=1).groupby('Country/Region').sum().T \ndead = pd.read_csv(dead_csv).drop(['Lat','Long','Province/State'], axis=1).groupby('Country/Region').sum().T \nrecovered = pd.read_csv(recovered_csv).drop(['Lat','Long','Province/State'], axis=1).groupby('Country/Region').sum().T \n# toggle these thresholds to select countries to display in the time series. \nmin_threshold_confirmed_cases = 200\nmax_threshold_confirmed_cases = 20000 # let's remove china for now. \nmin2_threshold_confirmed_cases = 100\nmax2_threshold_confirmed_cases = 100000 # let's remove china for now. \ncolumns = list(confirmed)\nselected = []\ndeaths = []\nmortality_rate = []\nall_mortality_rate = []\ncounts = []\nfor i in columns: \n if min_threshold_confirmed_cases < confirmed[i][-1] < max_threshold_confirmed_cases and i != 'Others': \n selected.append(i)\n deaths.append(dead[i][-1])\n mortality_rate.append(100*(dead[i][-1])/confirmed[i][-1])\n\n if min2_threshold_confirmed_cases < confirmed[i][-1] < max2_threshold_confirmed_cases and i != 'Others': \n counts.append(i)\n all_mortality_rate.append(100*(dead[i][-1])/(recovered[i][-1] + (dead[i][-1]) ))\n#print(len(confirmed))\n\nsubset = confirmed.loc[:,selected]\nUSvsUK = confirmed.loc[:,['US','UK','Singapore']]\n#top6 = confirmed.loc[:,['South Korea','Italy','Iran','France','Germany','Spain']]\n\ntop6 = confirmed.loc[:,['France','Germany','Spain']]\n\n\nfig, (ax1, ax2) = plt.subplots(2,figsize=(12, 10))\ntop6[28:].plot(ax=ax1, grid='on')\nax1.legend(loc='upper left')\nax1.set_title('Coronavirus-19 cases over time')\nax1.set_ylabel('Confirmed cases')\n# second plot is US and UK curves\nUSvsUK[28:].plot(ax=ax2, grid='on')\nax2.set_ylabel('Confirmed cases')\nax2.set_title('US, UK and Singapore');\n\n\n# fig, (ax1, ax2) = plt.subplots(2,figsize=(15, 10))\n# subset[28:].plot(ax=ax1, grid='on')\n# ax1.legend(loc='upper left')\n# ax1.set_title('Coronavirus-19 cases over time')\n# ax1.set_ylabel('Confirmed cases')\n# # second plot is US and UK curves\n# USvsUK[28:].plot(ax=ax2, grid='on')\n# ax2.set_ylabel('Confirmed cases')\n# ax2.set_title('US, UK and Singapore');\n",
"/usr/local/lib/python3.6/dist-packages/ipykernel_launcher.py:31: RuntimeWarning: invalid value encountered in long_scalars\n"
]
],
[
[
"# Prediction of growth rates per country",
"_____no_output_____"
],
[
"The countries closest to China appear to have the most linear trends. Those in other parts of the world are rising exponentially. Why?",
"_____no_output_____"
],
[
"Now plot the daily rise for a given country as a bar chart. ",
"_____no_output_____"
]
],
[
[
"# compare country rates per day.\ncountry = 'US'\ncountry2 = 'UK'\ncountry3 = 'Mainland China'\ncountry4 = 'Singapore'\ncountry5 = 'Italy'\ncountry6 = 'Australia'\ndaily = confirmed.diff(periods=1,axis=0).copy()\n\nc1 = daily[country]\nc2 = daily[country2]\nc3 = daily[country3]\nc4 = daily[country4]\nc5 = daily[country5]\nc6 = daily[country6]\ndf = pd.DataFrame({country:c1,country2:c2,country4:c4})\n\ndt = pd.DataFrame({country3:c3})\n#fig, (ax1) = plt.subplots(1,figsize=(14, 5))\nfig, (ax1,ax2) = plt.subplots(2,figsize=(14, 10))\ndf.plot.bar(ax=ax1,rot=60,grid='on')\nax1.set_ylabel('Daily Confirmed Cases')\nax1.set_title('Daily Cases')\nax1.legend(loc='upper left')\ndt.plot.bar(ax=ax2,rot=60,grid='on')\nax2.set_ylabel('Daily Confirmed Cases')\n#ax2.set_title('Mainland China');\nax2.legend(loc='upper left');",
"_____no_output_____"
]
],
[
[
"# Growth rate and doubling time. ",
"_____no_output_____"
],
[
"Looking at the percentage rate of growth over time, estimated based on the last 5 days. The plots accuracy is absolutely limited by the number of confirmed cases reported, but you can fairly clearly see that community transmission is occuring once the growth rate gets off the ground.\n\nGrowth Rate = 100*((Present-Past)/Past\n\nQuestions: Why would Italy's growth rate be declining? I expect this is a reporting error in that they cannot do more tests than they are already doing. \n\nSecond plot is the estimated doubling time for a range of countries. \n\n",
"_____no_output_____"
]
],
[
[
"multidaydiffs = confirmed.diff(periods=1,axis=0).copy() # change period to select how many days growth rate is calculate over. \ngrowth = 100*multidaydiffs/confirmed\ndoubling_time = 70/growth\n\ndt_median_per_country = doubling_time.apply(lambda s: s[np.isfinite(s)].dropna()).median()\n\n#fig, (ax1) = plt.subplots(1,figsize=(10, 5))\nfig, (ax1, ax2) = plt.subplots(2,figsize=(10, 5));\ngrowth['UK'].plot(ax=ax1, grid='on')\ngrowth['US'].plot(ax=ax1, grid='on')\n#growth['Australia'].plot(ax=ax1, grid='on')\n#growth['Italy'].plot(ax=ax1, grid='on')\ngrowth['Mainland China'].plot(ax=ax1, grid='on')\nax1.legend(loc='upper left')\nax1.set_title('Coronavirus-19 growth rates over time')\nax1.set_ylabel('Percentage Growth(%)');\n\ndoubling_time['US'].plot.bar(ax=ax2,rot=60,grid='on')\nax2.set_ylabel('Days it takes to double')\n#print(doubling_time[:][-1])\n###\nd2_per_country = []\ncounts =[]\nfor i in columns: \n if min_threshold_confirmed_cases < confirmed[i][-1] < max_threshold_confirmed_cases and i != 'Others': \n d2_per_country.append(dt_median_per_country[i])\n counts.append(i)\n\n#print(d2_per_country,counts)\nfig, (ax1) = plt.subplots(1,figsize=(10, 5))\nax1.grid(zorder=0)\nax1.bar(counts,d2_per_country, width=0.5, color='b', align='center',zorder = 3)\nax1.set_ylabel('Doubling Rate(days)')\nax1.set_title('Doubling rate per country')\nax1.set_xticklabels(counts,rotation=60);",
"_____no_output_____"
]
],
[
[
"# Hypothesis, countries above a certain number of cases are reporting inaccurately.\n\nHow to prove?\nThe number of new cases per day is decreasing for some countries that are known to not be implementing very good measures. It seems more likely that they are not testing enough, or that the bulk of the populace is becoming scared and isolating effectively to keep the transmission rate from rising exponentially. \n",
"_____no_output_____"
],
[
"# Identifying the mortality rate\n",
"_____no_output_____"
],
[
"How should we estimate the mortality rate? \nThe proportion of closed cases was my initial guess, although the WHO thinks otherwise and gets a 3.4% mortality rate. It's difficult to estimate as many people never become confirmed cases as they are never tested. \n\n",
"_____no_output_____"
]
],
[
[
"fig, (ax1) = plt.subplots(1,figsize=(20, 5))\nax1.grid(zorder=0)\nax1.bar(counts,all_mortality_rate, width=0.5, color='b', align='center',zorder = 3)\n#threshold = 3.4 # this is the WHO mortality estimation on March 3. \n#ax1.plot([0., 18.0], [threshold, threshold], \"k--\")\nax1.set_ylabel('Deaths/(Death+Recovered)')\nax1.set_title('Deaths as proportion of closed cases')\nax1.set_xticklabels(counts,rotation=60);",
"_____no_output_____"
]
],
[
[
"# China vs the rest of the world.\n",
"_____no_output_____"
],
[
"China cases vs the rest of the world. \nConfirmed cases in two bins, one China, one rest of world. \n\n",
"_____no_output_____"
]
],
[
[
"df = confirmed.copy()\ndf['everywhere_else'] = df.drop(['Mainland China'],axis=1).sum(axis=1)\ndf['china'] = confirmed['Mainland China']\ndf['ratios'] = df['china']/(df['everywhere_else']+df['china'])\n# print (df['ratios'])\nfig, (ax1) = plt.subplots(1,figsize=(20, 5))\ndf['ratios'].plot(ax=ax1, grid='on')\nax1.set_title('Ratio of confirmed cases in China compared to the rest of world')\nax1.set_ylabel('ratio of cases in China')\nax1.set_xlabel('Date');\n",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
]
] |
ecac65a72dcdf704c1671e958a8099d97a2ed6f0 | 32,998 | ipynb | Jupyter Notebook | s1_getting_started/exercise_files/5_Inference_and_Validation.ipynb | victor-flindt/MLO_02476_assignment_repo | eeae1901b3b1fbff89a4641ae50288892b6abb9e | [
"Apache-2.0"
] | null | null | null | s1_getting_started/exercise_files/5_Inference_and_Validation.ipynb | victor-flindt/MLO_02476_assignment_repo | eeae1901b3b1fbff89a4641ae50288892b6abb9e | [
"Apache-2.0"
] | null | null | null | s1_getting_started/exercise_files/5_Inference_and_Validation.ipynb | victor-flindt/MLO_02476_assignment_repo | eeae1901b3b1fbff89a4641ae50288892b6abb9e | [
"Apache-2.0"
] | null | null | null | 58.611012 | 12,736 | 0.723468 | [
[
[
"# Inference and Validation\n\nNow that you have a trained network, you can use it for making predictions. This is typically called **inference**, a term borrowed from statistics. However, neural networks have a tendency to perform *too well* on the training data and aren't able to generalize to data that hasn't been seen before. This is called **overfitting** and it impairs inference performance. To test for overfitting while training, we measure the performance on data not in the training set called the **validation** set. We avoid overfitting through regularization such as dropout while monitoring the validation performance during training. In this notebook, I'll show you how to do this in PyTorch. \n\nAs usual, let's start by loading the dataset through torchvision. You'll learn more about torchvision and loading data in a later part. This time we'll be taking advantage of the test set which you can get by setting `train=False` here:\n\n```python\ntestset = datasets.FashionMNIST('~/.pytorch/F_MNIST_data/', download=True, train=False, transform=transform)\n```\n\nThe test set contains images just like the training set. Typically you'll see 10-20% of the original dataset held out for testing and validation with the rest being used for training.",
"_____no_output_____"
]
],
[
[
"import torch\nfrom torchvision import datasets, transforms\n\n# Define a transform to normalize the data\ntransform = transforms.Compose([transforms.ToTensor(),\n transforms.Normalize((0.5,), (0.5,))])\n# Download and load the training data\ntrainset = datasets.FashionMNIST('~/.pytorch/F_MNIST_data/', download=True, train=True, transform=transform)\ntrainloader = torch.utils.data.DataLoader(trainset, batch_size=64, shuffle=True)\n\n# Download and load the test data\ntestset = datasets.FashionMNIST('~/.pytorch/F_MNIST_data/', download=True, train=False, transform=transform)\ntestloader = torch.utils.data.DataLoader(testset, batch_size=64, shuffle=True)",
"_____no_output_____"
]
],
[
[
"Here I'll create a model like normal, using the same one from my solution for part 4.",
"_____no_output_____"
]
],
[
[
"from torch import nn, optim\nimport torch.nn.functional as F\n\nclass Classifier(nn.Module):\n def __init__(self):\n super().__init__()\n self.fc1 = nn.Linear(784, 256)\n self.fc2 = nn.Linear(256, 128)\n self.fc3 = nn.Linear(128, 64)\n self.fc4 = nn.Linear(64, 10)\n \n def forward(self, x):\n # make sure input tensor is flattened\n x = x.view(x.shape[0], -1)\n \n x = F.relu(self.fc1(x))\n x = F.relu(self.fc2(x))\n x = F.relu(self.fc3(x))\n x = F.log_softmax(self.fc4(x), dim=1)\n \n return x",
"_____no_output_____"
]
],
[
[
"The goal of validation is to measure the model's performance on data that isn't part of the training set. Performance here is up to the developer to define though. Typically this is just accuracy, the percentage of classes the network predicted correctly. Other options are [precision and recall](https://en.wikipedia.org/wiki/Precision_and_recall#Definition_(classification_context)) and top-5 error rate. We'll focus on accuracy here. First I'll do a forward pass with one batch from the test set.",
"_____no_output_____"
]
],
[
[
"model = Classifier()\n\nimages, labels = next(iter(testloader))\n# Get the class probabilities\nps = torch.exp(model(images))\n# Make sure the shape is appropriate, we should get 10 class probabilities for 64 examples\nprint(ps.shape)",
"torch.Size([64, 10])\n"
]
],
[
[
"With the probabilities, we can get the most likely class using the `ps.topk` method. This returns the $k$ highest values. Since we just want the most likely class, we can use `ps.topk(1)`. This returns a tuple of the top-$k$ values and the top-$k$ indices. If the highest value is the fifth element, we'll get back 4 as the index.",
"_____no_output_____"
]
],
[
[
"top_p, top_class = ps.topk(1, dim=1)\n# Look at the most likely classes for the first 10 examples\nprint(top_class[:10,:])",
"tensor([[8],\n [0],\n [8],\n [0],\n [8],\n [8],\n [8],\n [8],\n [8],\n [8]])\n"
]
],
[
[
"Now we can check if the predicted classes match the labels. This is simple to do by equating `top_class` and `labels`, but we have to be careful of the shapes. Here `top_class` is a 2D tensor with shape `(64, 1)` while `labels` is 1D with shape `(64)`. To get the equality to work out the way we want, `top_class` and `labels` must have the same shape.\n\nIf we do\n\n```python\nequals = top_class == labels\n```\n\n`equals` will have shape `(64, 64)`, try it yourself. What it's doing is comparing the one element in each row of `top_class` with each element in `labels` which returns 64 True/False boolean values for each row.",
"_____no_output_____"
]
],
[
[
"equals = top_class == labels.view(*top_class.shape)",
"_____no_output_____"
]
],
[
[
"Now we need to calculate the percentage of correct predictions. `equals` has binary values, either 0 or 1. This means that if we just sum up all the values and divide by the number of values, we get the percentage of correct predictions. This is the same operation as taking the mean, so we can get the accuracy with a call to `torch.mean`. If only it was that simple. If you try `torch.mean(equals)`, you'll get an error\n\n```\nRuntimeError: mean is not implemented for type torch.ByteTensor\n```\n\nThis happens because `equals` has type `torch.ByteTensor` but `torch.mean` isn't implemented for tensors with that type. So we'll need to convert `equals` to a float tensor. Note that when we take `torch.mean` it returns a scalar tensor, to get the actual value as a float we'll need to do `accuracy.item()`.",
"_____no_output_____"
]
],
[
[
"accuracy = torch.mean(equals.type(torch.FloatTensor))\nprint(f'Accuracy: {accuracy.item()*100}%')",
"Accuracy: 10.9375%\n"
]
],
[
[
"The network is untrained so it's making random guesses and we should see an accuracy around 10%. Now let's train our network and include our validation pass so we can measure how well the network is performing on the test set. Since we're not updating our parameters in the validation pass, we can speed up our code by turning off gradients using `torch.no_grad()`:\n\n```python\n# turn off gradients\nwith torch.no_grad():\n # validation pass here\n for images, labels in testloader:\n ...\n```\n\n>**Exercise:** Implement the validation loop below and print out the total accuracy after the loop. You can largely copy and paste the code from above, but I suggest typing it in because writing it out yourself is essential for building the skill. In general you'll always learn more by typing it rather than copy-pasting. You should be able to get an accuracy above 80%.",
"_____no_output_____"
]
],
[
[
"import torch\nimport torchmetrics\nfrom torchmetrics.classification import Accuracy\n\nmodel = Classifier()\ncriterion = nn.NLLLoss()\noptimizer = optim.Adam(model.parameters(), lr=0.003)\n\nepochs = 5\nsteps = 0\ntrain_accuracy = Accuracy()\nvalid_accuracy = Accuracy(compute_on_step=False)\n\n\n\ntrain_losses, test_losses = [], []\nfor e in range(epochs):\n running_loss = 0\n for images, labels in trainloader:\n \n optimizer.zero_grad()\n \n y_hat = model(images)\n loss = criterion(y_hat, labels)\n loss.backward()\n optimizer.step()\n \n \n train_acc = train_accuracy(y_hat,labels)\n running_loss += loss.item()\n \n for images, labels in testloader:\n y_hat = model(images)\n valid_acc = valid_accuracy(y_hat, labels)\n \n else:\n print(f'train acc: {train_acc}')\n print(f'vali acc: {valid_acc}')\n \ntotal_valid_accuracy = valid_accuracy.compute()\ntotal_train_accuracy = train_accuracy.compute()\n\nprint(total_valid_accuracy)\nprint(total_train_accuracy)",
"train acc: 0.6875\nvali acc: None\ntrain acc: 0.84375\nvali acc: None\ntrain acc: 0.84375\nvali acc: None\ntrain acc: 0.90625\nvali acc: None\ntrain acc: 0.84375\nvali acc: None\ntensor(0.8549)\ntensor(0.8604)\n"
]
],
[
[
"## Overfitting\n\nIf we look at the training and validation losses as we train the network, we can see a phenomenon known as overfitting.\n\n<img src='assets/overfitting.png' width=450px>\n\nThe network learns the training set better and better, resulting in lower training losses. However, it starts having problems generalizing to data outside the training set leading to the validation loss increasing. The ultimate goal of any deep learning model is to make predictions on new data, so we should strive to get the lowest validation loss possible. One option is to use the version of the model with the lowest validation loss, here the one around 8-10 training epochs. This strategy is called *early-stopping*. In practice, you'd save the model frequently as you're training then later choose the model with the lowest validation loss.\n\nThe most common method to reduce overfitting (outside of early-stopping) is *dropout*, where we randomly drop input units. This forces the network to share information between weights, increasing it's ability to generalize to new data. Adding dropout in PyTorch is straightforward using the [`nn.Dropout`](https://pytorch.org/docs/stable/nn.html#torch.nn.Dropout) module.\n\n```python\nclass Classifier(nn.Module):\n def __init__(self):\n super().__init__()\n self.fc1 = nn.Linear(784, 256)\n self.fc2 = nn.Linear(256, 128)\n self.fc3 = nn.Linear(128, 64)\n self.fc4 = nn.Linear(64, 10)\n \n # Dropout module with 0.2 drop probability\n self.dropout = nn.Dropout(p=0.2)\n \n def forward(self, x):\n # make sure input tensor is flattened\n x = x.view(x.shape[0], -1)\n \n # Now with dropout\n x = self.dropout(F.relu(self.fc1(x)))\n x = self.dropout(F.relu(self.fc2(x)))\n x = self.dropout(F.relu(self.fc3(x)))\n \n # output so no dropout here\n x = F.log_softmax(self.fc4(x), dim=1)\n \n return x\n```\n\nDuring training we want to use dropout to prevent overfitting, but during inference we want to use the entire network. So, we need to turn off dropout during validation, testing, and whenever we're using the network to make predictions. To do this, you use `model.eval()`. This sets the model to evaluation mode where the dropout probability is 0. You can turn dropout back on by setting the model to train mode with `model.train()`. In general, the pattern for the validation loop will look like this, where you turn off gradients, set the model to evaluation mode, calculate the validation loss and metric, then set the model back to train mode.\n\n```python\n# turn off gradients\nwith torch.no_grad():\n \n # set model to evaluation mode\n model.eval()\n \n # validation pass here\n for images, labels in testloader:\n ...\n\n# set model back to train mode\nmodel.train()\n```",
"_____no_output_____"
],
[
"> **Exercise:** Add dropout to your model and train it on Fashion-MNIST again. See if you can get a lower validation loss or higher accuracy.",
"_____no_output_____"
]
],
[
[
"class Classifier(nn.Module):\n def __init__(self):\n super().__init__()\n self.fc1 = nn.Linear(784, 256)\n self.fc2 = nn.Linear(256, 128)\n self.fc3 = nn.Linear(128, 64)\n self.fc4 = nn.Linear(64, 10)\n\n # Dropout module with 0.2 drop probability\n self.dropout = nn.Dropout(p=0.2)\n\n def forward(self, x):\n # make sure input tensor is flattened\n x = x.view(x.shape[0], -1)\n\n # Now with dropout\n x = self.dropout(F.relu(self.fc1(x)))\n x = self.dropout(F.relu(self.fc2(x)))\n x = self.dropout(F.relu(self.fc3(x)))\n\n # output so no dropout here\n x = F.log_softmax(self.fc4(x), dim=1)\n\n return x",
"_____no_output_____"
],
[
"model = Classifier()\nmodel",
"_____no_output_____"
],
[
"import torch\nimport torchmetrics\nfrom torchmetrics.classification import Accuracy\n\nmodel = Classifier()\ncriterion = nn.NLLLoss()\noptimizer = optim.Adam(model.parameters(), lr=0.003)\n\nepochs = 5\nsteps = 0\ntrain_accuracy = Accuracy()\nvalid_accuracy = Accuracy(compute_on_step=False)\n\n\ntrain_losses, test_losses = [], []\nfor e in range(epochs):\n running_loss = 0\n for images, labels in trainloader:\n \n optimizer.zero_grad()\n \n y_hat = model(images)\n loss = criterion(y_hat, labels)\n loss.backward()\n optimizer.step()\n \n \n train_acc = train_accuracy(y_hat,labels)\n running_loss += loss.item()\n \n for images, labels in testloader:\n y_hat = model(images)\n valid_acc = valid_accuracy(y_hat, labels)\n \n else:\n print(f'train acc: {train_acc}')\n print(f'vali acc: {valid_acc}')\n \ntotal_valid_accuracy = valid_accuracy.compute()\ntotal_train_accuracy = train_accuracy.compute()\n\nprint(total_valid_accuracy)\nprint(total_train_accuracy)",
"train acc: 0.78125\nvali acc: None\ntrain acc: 0.8125\nvali acc: None\ntrain acc: 0.8125\nvali acc: None\ntrain acc: 0.84375\nvali acc: None\ntrain acc: 0.78125\nvali acc: None\ntensor(0.8250)\ntensor(0.8316)\n"
]
],
[
[
"## Inference\n\nNow that the model is trained, we can use it for inference. We've done this before, but now we need to remember to set the model in inference mode with `model.eval()`. You'll also want to turn off autograd with the `torch.no_grad()` context.",
"_____no_output_____"
]
],
[
[
"# Import helper module (should be in the repo)\nimport helper\n\n# Test out your network!\n\nmodel.eval()\n\ndataiter = iter(testloader)\nimages, labels = dataiter.next()\nimg = images[0]\n# Convert 2D image to 1D vector\nimg = img.view(1, 784)\n\n# Calculate the class probabilities (softmax) for img\nwith torch.no_grad():\n output = model.forward(img)\n\nps = torch.exp(output)\n\n# Plot the image and probabilities\nhelper.view_classify(img.view(1, 28, 28), ps, version='Fashion')",
"_____no_output_____"
]
],
[
[
"## Next Up!\n\nIn the next part, I'll show you how to save your trained models. In general, you won't want to train a model everytime you need it. Instead, you'll train once, save it, then load the model when you want to train more or use if for inference.",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecac6aee89d9b2b12522290743558e14a3eb8a18 | 5,208 | ipynb | Jupyter Notebook | Excel/Excel_Save_file.ipynb | srini047/awesome-notebooks | 2a5b771b37b62090de5311d61dce8495fae7b59f | [
"BSD-3-Clause"
] | null | null | null | Excel/Excel_Save_file.ipynb | srini047/awesome-notebooks | 2a5b771b37b62090de5311d61dce8495fae7b59f | [
"BSD-3-Clause"
] | null | null | null | Excel/Excel_Save_file.ipynb | srini047/awesome-notebooks | 2a5b771b37b62090de5311d61dce8495fae7b59f | [
"BSD-3-Clause"
] | null | null | null | 21.882353 | 275 | 0.523618 | [
[
[
"<img width=\"10%\" alt=\"Naas\" src=\"https://landen.imgix.net/jtci2pxwjczr/assets/5ice39g4.png?w=160\"/>",
"_____no_output_____"
],
[
"# Excel - Save file\n<a href=\"https://app.naas.ai/user-redirect/naas/downloader?url=https://raw.githubusercontent.com/jupyter-naas/awesome-notebooks/master/Excel/Excel_Save_file.ipynb\" target=\"_parent\"><img src=\"https://naasai-public.s3.eu-west-3.amazonaws.com/open_in_naas.svg\"/></a>",
"_____no_output_____"
],
[
"**Tags:** #excel #pandas #save #opendata #yahoofinance #naas_drivers",
"_____no_output_____"
],
[
"**Author:** [Florent Ravenel](https://www.linkedin.com/in/ACoAABCNSioBW3YZHc2lBHVG0E_TXYWitQkmwog/)",
"_____no_output_____"
],
[
"## Input",
"_____no_output_____"
],
[
"### Import libraries",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nfrom naas_drivers import yahoofinance",
"_____no_output_____"
]
],
[
[
"### Variables",
"_____no_output_____"
]
],
[
[
"# Input yahoo\nticker = \"TSLA\"\ndate_from = -100\ndate_to = 'today'\ninterval = '1d'\nmoving_averages = [20, 50]\n\n# Output\nexcel_file_path = f\"{ticker}.xlsx\"",
"_____no_output_____"
]
],
[
[
"## Model",
"_____no_output_____"
],
[
"### Read excel",
"_____no_output_____"
]
],
[
[
"df_yahoo = yahoofinance.get(ticker,\n date_from=date_from,\n date_to=date_to,\n interval=interval,\n moving_averages=moving_averages)",
"_____no_output_____"
]
],
[
[
"## Output",
"_____no_output_____"
],
[
"### Display result",
"_____no_output_____"
],
[
"You want to add more parameters ?<br>\n👉 Check out the pandas documentation <a href=\"https://pandas.pydata.org/docs/reference/api/pandas.read_excel.html\">here</a>.",
"_____no_output_____"
]
],
[
[
"df_yahoo.to_excel(excel_file_path)\nprint(f'💾 Excel '{excel_file_path}' successfully saved in Naas.')",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
]
] |
ecac7cc245f06d934346591cf78b72d5146250c5 | 19,430 | ipynb | Jupyter Notebook | dew_depl.ipynb | Dew-bench/docs | 1dfbdcac7fce3c2039f2d9672779db33c0c70bba | [
"Unlicense"
] | null | null | null | dew_depl.ipynb | Dew-bench/docs | 1dfbdcac7fce3c2039f2d9672779db33c0c70bba | [
"Unlicense"
] | null | null | null | dew_depl.ipynb | Dew-bench/docs | 1dfbdcac7fce3c2039f2d9672779db33c0c70bba | [
"Unlicense"
] | null | null | null | 131.283784 | 15,914 | 0.668863 | [
[
[
"import plantuml\nfrom IPython.display import SVG, display\nimport requests\n\n\ndef show_plant(txt):\n plnt_txt = plantuml.deflate_and_encode(txt)\n uri = \"http://www.plantuml.com/plantuml/svg/\" + plnt_txt\n htmldata = requests.get(uri)\n svg_txt = htmldata.text\n style_idx = svg_txt.find(\"style=\") + len(\"style=\") + 1\n svg_txt = svg_txt[:style_idx]+\"background-color: white;\"+svg_txt[style_idx:]\n display(SVG(svg_txt))",
"_____no_output_____"
],
[
"\ntxt = \"\"\"\ntitle ...\n' skinparam handwritten true\ntop to bottom direction\n'skinparam monochrome true\n'skinparam shadowing<<no_shadow>> false\nskinparam shadowing false\n\nhide stereotype\n\nskinparam rectangle<<desc>> {\n backgroundColor Transparent\n borderColor Transparent\n titleFontColor Transparent\n stereotypeFontColor Transparent\n ArtifactStereotypeFontColor Transparent\n ArtifactStereotypeFontSize 10\n}\n\nnode vIoT_Manager\nnote left\n Each drone has\n ClusterIP and\n NodePort\nend note\n\nnode vIoT_1\nnode vIoT_2\nnode vIoT_n\nrectangle multiple<<desc>> #White/White [\n...]\n\n\nvIoT_Manager -d-> vIoT_1\nvIoT_Manager -d-> vIoT_2\nvIoT_Manager -[hidden]d-> multiple\nvIoT_Manager -d-> vIoT_n\nvIoT_n -[hidden]l-> multiple\nmultiple -[hidden]l-> vIoT_2\nvIoT_2 -[hidden]l-> vIoT_1\n\n\nnode kafka {\n queue vDrone_1_in\n queue vDrone_1_out\n queue vDrone_2_in\n queue vDrone_2_out\n rectangle kafka_multiple<<desc>> #White/White [\n...]\n}\n\nkafka_multiple -[hidden]l-> vDrone_2_out\nvDrone_2_out -[hidden]l-> vDrone_2_in\nvDrone_2_in -[hidden]l-> vDrone_1_out\nvDrone_1_out -[hidden]l-> vDrone_1_in\n\nvIoT_1 ----d-> vDrone_1_in : Sensor Data\nvDrone_1_out ----d-> vIoT_1 : Position & Speed cmds\n\n\nnode Controller\n\nvDrone_1_in --[hidden]d-> Controller\nkafka --d-> Controller\n\n \"\"\"\n\n\nshow_plant(txt)\n\n\n\n\n\n",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code"
]
] |
ecac83918ba935808845357a7994630f61549ef4 | 21,173 | ipynb | Jupyter Notebook | review/notebooks/interfacte_example.ipynb | Cyberface/nrutils_dev | 4dc4e684c3f9bce0ff594fe924198e62a3edfe44 | [
"MIT"
] | 5 | 2016-04-04T05:37:49.000Z | 2021-11-21T16:06:15.000Z | review/notebooks/interfacte_example.ipynb | Cyberface/nrutils_dev | 4dc4e684c3f9bce0ff594fe924198e62a3edfe44 | [
"MIT"
] | 36 | 2016-04-10T08:28:41.000Z | 2021-12-13T15:17:47.000Z | review/notebooks/interfacte_example.ipynb | Cyberface/nrutils_dev | 4dc4e684c3f9bce0ff594fe924198e62a3edfe44 | [
"MIT"
] | 6 | 2016-04-04T05:27:33.000Z | 2021-12-13T14:29:27.000Z | 320.80303 | 19,934 | 0.929769 | [
[
[
"%matplotlib inline\nfrom IPython.html.widgets import *\nfrom numpy import linspace,array,sin,pi\nfrom matplotlib.pyplot import plot,show\nt = linspace(0,1,120)\ndef pltsin(p):\n plot( t,sin(t*2*pi*p) )\n show()\n \ninteract( pltsin,p=(0.1,10,0.05) )",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code"
]
] |
ecac9272fd229702a46cb65b0bb034082c8167b5 | 5,583 | ipynb | Jupyter Notebook | tests/post.ipynb | DatenkrakeWasTaken/twitter_bot_popularity_evaluation | d64797878c137306f964f05f85e0c1c92153d104 | [
"MIT"
] | null | null | null | tests/post.ipynb | DatenkrakeWasTaken/twitter_bot_popularity_evaluation | d64797878c137306f964f05f85e0c1c92153d104 | [
"MIT"
] | null | null | null | tests/post.ipynb | DatenkrakeWasTaken/twitter_bot_popularity_evaluation | d64797878c137306f964f05f85e0c1c92153d104 | [
"MIT"
] | null | null | null | 33.836364 | 1,735 | 0.604514 | [
[
[
"import tweepy\nimport keyring",
"_____no_output_____"
],
[
"client = tweepy.Client(keyring.get_password('twitter','bearer_token'), keyring.get_password('twitter','api_key'), keyring.get_password('twitter','api_key_secret'), keyring.get_password('twitter','access_token'), keyring.get_password('twitter','access_token_secret')) ",
"_____no_output_____"
],
[
"client.create_tweet(text='this is a test')",
"_____no_output_____"
],
[
"auth = tweepy.OAuthHandler(keyring.get_password('twitter','api_key'), keyring.get_password('twitter','api_key_secret'))\nauth.set_access_token(keyring.get_password('twitter','access_token'), keyring.get_password('twitter','access_token_secret'))\napi = tweepy.API(auth)",
"_____no_output_____"
],
[
"media = api.media_upload('1.jpg')",
"_____no_output_____"
],
[
"media.media_id",
"_____no_output_____"
],
[
"client.create_tweet(text='look at this picture!', media_ids=[media.media_id])",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecacbb5296803da9df535b2ea7b5d6007af0aae8 | 8,571 | ipynb | Jupyter Notebook | Week8/Week 8 - Quiz Assignment.ipynb | gymk/ANLP | 3052b12d307e4b2c8e192f3ac3b6e393932a0d77 | [
"MIT"
] | 7 | 2020-08-25T23:10:34.000Z | 2022-01-11T16:43:37.000Z | Week8/Week 8 - Quiz Assignment.ipynb | gymk/ANLP | 3052b12d307e4b2c8e192f3ac3b6e393932a0d77 | [
"MIT"
] | null | null | null | Week8/Week 8 - Quiz Assignment.ipynb | gymk/ANLP | 3052b12d307e4b2c8e192f3ac3b6e393932a0d77 | [
"MIT"
] | 11 | 2020-09-28T09:08:01.000Z | 2022-03-29T18:06:22.000Z | 21.374065 | 198 | 0.514876 | [
[
[
"# Week 8 - Quiz Assignment",
"_____no_output_____"
],
[
"1) What are the different types of translations discussed in the Vauquois diagram?\n- [ ] Word for word translation\n- [ ] Syntax-tree based translation\n- [ ] Semantics based translation\n- [ ] Phrase-based translation",
"_____no_output_____"
],
[
"__Answer__: \n\n- [x] Word for word translation\n- [x] Syntax-tree based translation\n- [x] Semantics based translation",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"2) Check all that is true about Interlingua\n- [ ] Increases computational complexity\n- [ ] Difficult to design such a representation\n- [ ] meta-language representing knowledge about a source language\n- [ ] It is a bridge language",
"_____no_output_____"
],
[
"__Answer__: \n\n- [x] Difficult to design such a representation\n- [x] meta-language representing knowledge about a source language",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"3) The statement \"The argmax function finds the most likely English sentence $e$ given the Spanish sentence $s$ and maximizes the probability $P(s|e)$\" is\n- False\n- True",
"_____no_output_____"
],
[
"__Answer__: False\n\n- Refer [v1] Lecture @ 20:29",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"4) Bayes rule for translation is $P(e|f) = \\displaystyle \\frac{P(e|f)P(e)}{P(f)}$\n- True\n- False",
"_____no_output_____"
],
[
"__Answer__: False",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"For questions 6-10, consider the translation which maximizes the probability $P (T L|SL)$ where __TL__ is the target language and __SL__ is the source Language",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"5) The index of the alignment variable refers to\n- The location of the word in the source language\n- The location of the word in the target language\n- The value of the source language\n- None of the above",
"_____no_output_____"
],
[
"__Answer__: The location of the word in the target language\n\n\n Refer [v1] Lecture 66 @ 13:19",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"6) The value of the alignment variable refers to the location of the word in the target language\n- True\n- False",
"_____no_output_____"
],
[
"__Answer__: False\n\n Refer [v1] Lecture 66 @ 13:19",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"7) Consider the alignments $a = \\lbrace 1,3,3,4,7\\rbrace$. How many words are there in the source and the target languages ($\\lbrace \\# of SL words,\\# of TL words\\rbrace$)?\n__Note: * in the options refers to any number ≥7__\n- $\\lbrace *,7 \\rbrace$\n- $\\lbrace 5,* \\rbrace$\n- $\\lbrace 7,* \\rbrace$\n- $\\lbrace *,5 \\rbrace$",
"_____no_output_____"
],
[
"__Answer__: $\\lbrace *,5 \\rbrace$",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"8) The alignment variables for the source language using the following figure is $\\lbrace 1,2,3,3,3,4,4,5,5 \\rbrace$\n\n- True\n- False",
"_____no_output_____"
],
[
"__Answer__: False",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"9) Find the alignment variables using the following alignment diagram:\n\n- $\\lbrace 1,2,4,5,6,7,7\\rbrace$\n- $\\lbrace 1,3,3,5,6,7,8\\rbrace$\n- $\\lbrace 1,1,4,5,6,7,8\\rbrace$\n- $\\lbrace 1,2,4,5,6,7,8\\rbrace$\n- None of the above",
"_____no_output_____"
],
[
"__Answer__: None of the above\n\n- For word __am__, there is no alignment exist in source language. In such case, it should point to NULL, which is index 0",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"10) Find the alighment variables for the source language using the following alignment diagram\n\n- $\\lbrace 1,2,2,3,4,5,6,7\\rbrace$\n- $\\lbrace 1,1,2,3,4,5,6,7\\rbrace$\n- $\\lbrace 1,1,3,2,4,5,6,7\\rbrace$\n- $\\lbrace 1,2,3,4,5,6,7,8\\rbrace$\n- None of the above",
"_____no_output_____"
],
[
"__Answer__: None of the above\n\n- Refer Question 5",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"11) IBM Model 1 is\n- [ ] Alignment decisions are based on the context words\n- [ ] Word2Word translation\n- [ ] Lexical translation\n- [ ] The length of the target language sentence is fixed",
"_____no_output_____"
],
[
"__Answer__: \n\n- From [v1] Lecture 68\n - [x] Word2Word translation\n - [x] Lexical translation\n- <https://www.aclweb.org/anthology/J93-2003>\n - _4.1 Model 1_",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"12) It is possible to have NULL alignment in IBM Model 1\n- True\n- False",
"_____no_output_____"
],
[
"__Answer__: True",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
],
[
"13) The total number of possible alignments is given by ${\\left(\\frac{1}{n+1}\\right)}^m$, where $m\\, and\\, n$ are the number of words in the source and the target language respectively\n- Ture\n- False",
"_____no_output_____"
],
[
"__Answer__: False\n\n- From [v1] Lecture 68 @ 05:01 and 10:04\n - $n$ - number of words in source language/ length of the source language\n - $m$ - number of words in target language/ length of the target language",
"_____no_output_____"
],
[
"****",
"_____no_output_____"
]
]
] | [
"markdown"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
]
] |
ecacd7ffabf171d4d59a7b64646fe4bd48765a2b | 7,417 | ipynb | Jupyter Notebook | tutorials/Pyqubo_demo.ipynb | QForestCommunity/launchpad | 07f3e62b84e2c64fe5281c5e5c7f46ab5c1a9793 | [
"MIT"
] | 27 | 2020-06-03T13:47:34.000Z | 2021-11-30T12:37:37.000Z | tutorials/Pyqubo_demo.ipynb | SashwatAnagolum/launchpad | f6f84b155368b7b6b3e1649b6e7c3a94386882ce | [
"MIT"
] | 12 | 2020-06-03T15:13:37.000Z | 2020-06-30T12:31:31.000Z | tutorials/Pyqubo_demo.ipynb | QForestCommunity/launchpad | 07f3e62b84e2c64fe5281c5e5c7f46ab5c1a9793 | [
"MIT"
] | 16 | 2020-06-03T11:59:01.000Z | 2021-03-23T21:41:46.000Z | 34.821596 | 475 | 0.615073 | [
[
[
"# **Ising model solving process using the Light Switch game with Pyqubo**\n\nThe Ising model is a standard physics model used to solve complicated physics oriented tasks. It is the main solving process used by the python module pyqubo, which we will be using today.\n\nThe light switch game is a simple game, click [here](https://www.dwavesys.com/tutorials/background-reading-series/quantum-computing-primer#h2-2) for full details on the game, which consists of a set of light switches which have values corresponding to them (weights). If the switch is turned on, the corresponding value is added to the total sum. Hence the goal is to find the minimum value of this sum, by finding an optimal combination of the switches (on or off).\n\n\n**Prerequisites**\n* Basics of python programming\n\n\n**Dependencies**\n\n* pyqubo : simply run ```pip install pyqubo``` on your command line/terminal to install pyqubo.\n\n\n\nNow we're good to go! Let's begin by importing the 2 required functions from pyqubo.",
"_____no_output_____"
]
],
[
[
"from pyqubo import Spin, solve_ising",
"_____no_output_____"
]
],
[
[
"### Ising model:\n\nMathematically, the objective function of the Ising model is defined as:\n\n$$\\sum_{i}H_i s_i + \\sum_{i<j}J_i s_i s_j$$\n\nwhere $s_i, s_j$ represent the spin variables(-1 or 1), and $H_i$ and $J_i$ represent the Ising coefficients. Let's understand what they represent and what their significance is.\n\nThe spin variables decide on whether the ith item in a certain set of items (which are part of the task) belong to the task or not. For example, if $s_1$ was -1, it would mean the 1st item(in this case, the first switch) would belong to the set, which is saying that it should be turned on.\n\nThe Ising coefficients are the respective weights attached to each item and the corresponding degree in the objective function. For now we are working with a linear objective function. We'll see more of this in detail further on.\n\nThe problem now lies in converting the light switch task, into the objective function form. We have seen what the objective function looks like, and it's actually not hard at all to convert the light switch problem to this form. \n\nWe ignore the second half of the objective function, as we are only dealing with linear terms here. Now, if we see, all the weights attached to the switches become the $H_i$ coefficients, and the switches become the $s_i$ variables.\n\nLet us assume we are dealing with 3 switches (x1, x2, x3) having weights 2,1,-3 respectively.\n\nThe following code sets the switch variables as spin variables (which collapse to either -1 or 1).\n\nIf you want to work with binary variables(0 or 1), use Binary() instead of Spin() to define the quadratic.",
"_____no_output_____"
]
],
[
[
"x1, x2, x3 = Spin(\"x1\"), Spin(\"x2\"), Spin(\"x3\")\nQuad_form = 2*(x1) + x2 - 3*(x3)",
"_____no_output_____"
]
],
[
[
"Now the variable quad_form holds the objective function. This needs to be compiled and converted to an Ising form. We do that with the following set of code.",
"_____no_output_____"
]
],
[
[
"model = Quad_form.compile()\ndeg1, deg2, off = model.to_ising()",
"_____no_output_____"
]
],
[
[
"model.to_ising returns the Ising coefficients, which can be used to solve the optimisation task at hand. deg1 holds the coefficients of all the 1st degree terms in the equation, and deg2 holds the 2nd degree terms. off holds the value of any constant that is present in the equation.\n\nSince our function is linear, deg2 will be empty, and off will hold no value as there are no constant terms. You can verify this by printing the values of all the coefficients. ",
"_____no_output_____"
]
],
[
[
"print('Degree1:',deg1,' Degree2:',deg2,' Offset:',off)",
"Degree1: {'x1': 2.0, 'x2': 1.0, 'x3': -3.0} Degree2: {} Offset: 0.0\n"
]
],
[
[
"Now we finally solve the Ising model by using the solve_ising function, and passing our coefficients to it. Even though deg2 is empty, the function still expects it as an arguement.",
"_____no_output_____"
]
],
[
[
"res = solve_ising(deg1,deg2)\nprint(res) ",
"{'x1': -1, 'x2': -1, 'x3': 1}\n"
]
],
[
[
"As we see, we get the expected output. \nExperiment with the weights and the number of switches.\n\nIn case sometimes on running the same code multiple times, different outputs are observed, solve the ising model multiple times and extract the most frequently occuring solution. You can use the following code",
"_____no_output_____"
]
],
[
[
"shots = 10 #variable used to specify number of times you want to solve the model\nans = []\nfor i in range(shots):\n res = solve_ising(deg1, deg2)\n ans.append(res)\n \nresult = ans[0]\nmaxim = 0\nfor i in ans:\n freq = ans.count(i)\n if freq>maxim:\n maxim = freq\n result = i\n\nprint(str(result))",
"{'x1': -1, 'x2': -1, 'x3': 1}\n"
]
],
[
[
"Now that we have seen how to formulate a simple Ising model and solve it using pyqubo, you can see how simple it is to solve optimisation tasks using similar principles.\nTry to solve other optimisation tasks which do not involve constraints, such as the number partitioning problem. Also explore incorporating constraints into the Ising model, for which another tutorial will be available soon! ",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecaceeb45f2ba9e06b4078d3cb2d11d584d763c7 | 20,616 | ipynb | Jupyter Notebook | functions/functions_cams.ipynb | stewartchrisecmwf/adc-toolbox | 55b995fb8ee758a732e0748743aa0fbfe520d491 | [
"MIT"
] | null | null | null | functions/functions_cams.ipynb | stewartchrisecmwf/adc-toolbox | 55b995fb8ee758a732e0748743aa0fbfe520d491 | [
"MIT"
] | null | null | null | functions/functions_cams.ipynb | stewartchrisecmwf/adc-toolbox | 55b995fb8ee758a732e0748743aa0fbfe520d491 | [
"MIT"
] | null | null | null | 41.902439 | 126 | 0.472158 | [
[
[
"# CAMS functions",
"_____no_output_____"
]
],
[
[
"def CAMS_download(dates, start_date, end_date, component, component_nom, model_full_name, model_level):\n\n \"\"\" Query and download the CAMS levels dataset from CDS API\n\n Args:\n dates (arr): Query dates\n start_date (str): Query start date\n end_date (str): Query end date\n component (str): Component name\n component_nom (str): Component chemical nomenclature\n model_full_name (str): Full name of the CAMS model among:\n - 'cams-global-atmospheric-composition-forecasts' \n - 'cams-global-reanalysis-eac4-monthly'\n model_level (str): Model levels:\n - 'Simple' for total columns\n - 'Multiple' for levels\n\n Returns:\n CAMS_product_name (str): Product name of CAMS product\n CAMS_type (str): Model type:\n - 'Forecast'\n - 'Reanalysis'\n \"\"\"\n\n c = cdsapi.Client()\n\n if model_full_name == 'cams-global-atmospheric-composition-forecasts':\n\n CAMS_type = 'Forecast'\n\n if model_level == 'Multiple':\n \n CAMS_product_name = component_nom + '-hourly-levels-' + start_date + '-' + end_date + '.grib'\n\n if os.path.isfile(os.path.join(os.path.abspath(''), 'data/cams/' + component_nom + \n '/' + CAMS_product_name)):\n\n print('The file exists, it will not be downloaded again.')\n \n else:\n\n print('The file does not exist, it will be downloaded.')\n c.retrieve(\n model_full_name,\n {\n 'date': start_date + '/' + end_date,\n 'type': 'forecast',\n 'format': 'grib',\n 'variable': component,\n 'model_level': [str(x + 1) for x in range(137)],\n 'time': '00:00',\n 'leadtime_hour': [str(x) for x in range(0, 24, 3)],\n },\n 'data/cams/' + component_nom + '/' + CAMS_product_name)\n \n elif model_level == 'Single':\n\n CAMS_product_name = component_nom + '-hourly-tc-' + start_date + '-' + end_date + '.grib'\n\n if os.path.isfile(os.path.join(os.path.abspath(''), 'data/cams/' + component_nom +\n '/' + CAMS_product_name)):\n \n print('The file exists, it will not be downloaded again.')\n \n else:\n print('The file does not exist, it will be downloaded.')\n\n c = cdsapi.Client()\n c.retrieve(\n 'cams-global-atmospheric-composition-forecasts',\n {\n 'date': start_date + '/' + end_date,\n 'type': 'forecast',\n 'format': 'grib',\n 'variable': 'total_column_' + component,\n 'time': '00:00',\n 'leadtime_hour': [str(x) for x in range(0, 24, 3)],\n },\n 'data/cams/' + component_nom + '/' + CAMS_product_name)\n\n elif model_full_name == 'cams-global-reanalysis-eac4-monthly':\n \n CAMS_product_name = component_nom + '-monthly-tc-' + start_date + '-' + end_date + '.grib'\n CAMS_type = 'Reanalysis'\n\n if os.path.isfile(os.path.join(os.path.abspath(''), 'data/cams/' + component_nom + \n '/' + CAMS_product_name)):\n\n print('The file exists, it will not be downloaded again.')\n \n else:\n\n print('The file does not exist, it will be downloaded.') \n months = []\n years = []\n \n for date in dates:\n\n year = date.split('-')[0]\n month = date.split('-')[1]\n\n if year not in years:\n years.append(year)\n \n if month not in months:\n months.append(month)\n\n c.retrieve(\n model_full_name,\n {\n 'format': 'grib',\n 'variable': 'total_column_' + component,\n 'year': years,\n 'month': months,\n 'product_type': 'monthly_mean',\n },\n 'data/cams/' + component_nom + '/' + CAMS_product_name)\n\n return CAMS_product_name, CAMS_type",
"_____no_output_____"
],
[
"def CAMS_read(CAMS_product_name, component, component_nom, dates):\n\n \"\"\" Read CAMS levels dataset as xarray dataset object\n\n Args:\n CAMS_product_name (str): Product name of CAMS product\n component (str): Component name\n component_nom (str): Component chemical nomenclature\n dates (arr): Query dates\n \n Returns:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n \"\"\"\n\n # Read as xarray dataset object\n CAMS_ds = xr.open_dataset('data/cams/' + component_nom + '/' + CAMS_product_name)\n\n # Change name to component\n if 'levels' in CAMS_product_name:\n\n if component == 'ozone':\n CAMS_ds = CAMS_ds.rename({'go3': 'component'})\n\n else:\n CAMS_ds = CAMS_ds.rename({component_nom.lower(): 'component'})\n\n elif 'tc' in CAMS_product_name:\n \n if component == 'ozone':\n CAMS_ds = CAMS_ds.rename({'gtco3': 'component'})\n\n else:\n CAMS_ds = CAMS_ds.rename({'tc' + component_nom.lower(): 'component'})\n\n # Remove data for dates that have been downloaded but not asked for (error of the CAMS API!)\n if 'monthly' in CAMS_product_name:\n \n all_datetimes = []\n\n for date in dates:\n\n year = int(date.split('-')[0])\n month = int(date.split('-')[1])\n time_str = np.datetime64(dt.datetime(year, month, 1, 0, 0, 0, 0))\n all_datetimes.append(time_str)\n\n # Drop datetimes\n datetimes_to_delete = np.setdiff1d(CAMS_ds.time.values, np.array(all_datetimes))\n if datetimes_to_delete.size != 0:\n CAMS_ds = CAMS_ds.drop_sel(time = datetimes_to_delete) \n\n # Available dates\n dates_to_keep = np.intersect1d(CAMS_ds.time.values, np.array(all_datetimes))\n dates = tuple(dates_to_keep.astype('datetime64[M]').astype(str))\n \n # Change longitude coordinates\n CAMS_ds = CAMS_ds.assign_coords(longitude = (((CAMS_ds.longitude + 180) % 360) - 180)).sortby('longitude')\n CAMS_ds = CAMS_ds.sortby('latitude')\n\n # Assign time as coordinates (when there is only one time)\n if CAMS_ds.time.values.size == 1:\n CAMS_ds = CAMS_ds.expand_dims(dim = ['time'])\n\n return CAMS_ds, dates",
"_____no_output_____"
],
[
"def CAMS_137_levels():\n\n \"\"\" Create table with information about the 137 CAMS levels\n \n Returns:\n CAMS_levels_df (dataframe): Table with 137 CAMS levels data\n \"\"\"\n\n # Read csv table with 137 levels\n CAMS_levels_df = pd.read_csv('data/cams/137-levels.csv')\n\n # Drop first row and set n as index hybrid\n CAMS_levels_df = CAMS_levels_df.drop(0).reset_index(drop = True)\n CAMS_levels_df = CAMS_levels_df.set_index('n')\n CAMS_levels_df.index.names = ['hybrid']\n\n # Change important columns to numeric\n CAMS_levels_df['ph [Pa]'] = pd.to_numeric(CAMS_levels_df['ph [hPa]']) * 100\n CAMS_levels_df['Geopotential Altitude [m]'] = pd.to_numeric(CAMS_levels_df['Geopotential Altitude [m]'])\n CAMS_levels_df['Density [kg/m^3]'] = pd.to_numeric(CAMS_levels_df['Density [kg/m^3]'])\n\n # Calculate half pressures\n CAMS_levels_df['ph-diff [Pa]'] = CAMS_levels_df['ph [Pa]'].diff(1)\n CAMS_levels_df['ph-diff [Pa]'].iloc[0] = CAMS_levels_df['ph [Pa]'].iloc[0]\n\n # Calculate difference from geopotential altitude\n CAMS_levels_df['Depth [m]'] = CAMS_levels_df['Geopotential Altitude [m]'].diff(-1)\n CAMS_levels_df['Depth [m]'].iloc[-1] = CAMS_levels_df['Geopotential Altitude [m]'].iloc[-1]\n\n return CAMS_levels_df",
"_____no_output_____"
],
[
"def CAMS_pressure(CAMS_ds, CAMS_levels_df, start_date, end_date, component_nom):\n\n \"\"\" Download surface pressure and calculate levels pressure following the instructions given at:\n https://confluence.ecmwf.int/display/OIFS/4.4+OpenIFS%3A+Vertical+Resolution+and+Configurations\n\n Args:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n CAMS_levels_df (dataframe): Table with 137 CAMS levels data\n start_date (str): Query start date\n end_date (str): Query end date\n component_nom (str): Component chemical nomenclature\n \n Returns:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n \"\"\"\n\n c = cdsapi.Client()\n\n CAMS_pressure_product_name = 'surface-pressure-' + start_date + '-' + end_date + '.grib'\n\n if os.path.isfile(os.path.join(os.path.abspath(''), 'data/cams/' + component_nom + \n '/' + CAMS_pressure_product_name)):\n pass\n\n else:\n\n c.retrieve(\n 'cams-global-atmospheric-composition-forecasts',\n {\n 'date': start_date + '/' + end_date,\n 'type': 'forecast',\n 'format': 'grib',\n 'variable': 'surface_pressure',\n 'leadtime_hour': [str(x) for x in range(0, 24, 3)],\n 'time': '00:00',\n },\n 'data/cams/' + component_nom + '/' + CAMS_pressure_product_name)\n \n hybrid = CAMS_ds['hybrid']\n time = CAMS_ds['time']\n step = CAMS_ds['step']\n latitude = CAMS_ds['latitude']\n longitude = CAMS_ds['longitude']\n\n model_pressure_ds = xr.open_dataarray('data/cams/' + component_nom + '/' + CAMS_pressure_product_name)\n\n if model_pressure_ds.time.values.size == 1:\n model_pressure_ds = model_pressure_ds.expand_dims(dim = ['time'])\n\n sp_array = xr.DataArray(\n model_pressure_ds.values,\n dims = ('time', 'step', 'latitude', 'longitude'),\n coords = {\n 'time': ('time', time[:]),\n 'step': ('step', step[:]),\n 'latitude': ('latitude', latitude[:]),\n 'longitude': ('longitude', longitude[:]),\n },\n name = 'surface_pressure'\n )\n\n a_array = xr.DataArray(\n CAMS_levels_df['a [Pa]'],\n dims = ('hybrid'),\n coords = {'hybrid': ('hybrid', hybrid[:]),},\n name = 'a'\n )\n\n b_array = xr.DataArray(\n CAMS_levels_df['b'],\n dims = ('hybrid'),\n coords = {'hybrid': ('hybrid', hybrid[:]),},\n name = 'b'\n )\n\n CAMS_ds['surface_pressure'] = sp_array\n CAMS_ds['a'] = a_array\n CAMS_ds['b'] = b_array\n\n CAMS_ds['pressure_1/2'] = CAMS_ds['a'] + CAMS_ds['surface_pressure'] * CAMS_ds['b']\n CAMS_ds['pressure_-1/2'] = CAMS_ds['pressure_1/2'].shift(hybrid = 1)\n CAMS_ds['pressure_-1/2'] = CAMS_ds['pressure_-1/2'].where(~np.isnan(CAMS_ds['pressure_-1/2']), 0, drop = False)\n CAMS_ds['pressure'] = 0.5 * (CAMS_ds['pressure_-1/2'] + CAMS_ds['pressure_1/2'])\n CAMS_ds = CAMS_ds.drop_vars(['a', 'b', 'surface_pressure', 'pressure_1/2', 'pressure_-1/2'])\n \n return CAMS_ds",
"_____no_output_____"
],
[
"def CAMS_kg_kg_to_kg_m2(CAMS_ds, CAMS_levels_df, sensor, start_date, end_date, \n component_nom, apply_kernels = False):\n\n \"\"\" Convert the units of the CAMS partial columns for any component from kg/kg to kg/m2\n\n Args:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n CAMS_levels_df (dataframe): Table with 137 CAMS levels data\n sensor (str): Name of the sensor\n start_date (str): Query start date\n end_date (str): Query end date\n component_nom (str): Component chemical nomenclature\n apply_kernels (bool): Apply (True) or not (False) the averaging kernels\n \n Returns:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n \"\"\"\n\n if sensor == 'tropomi' and apply_kernels == True:\n \n CAMS_ds_all = []\n\n # Calculate level pressures\n CAMS_ds = CAMS_pressure(CAMS_ds, CAMS_levels_df, start_date, end_date, component_nom)\n\n for time in CAMS_ds.time:\n\n PC_hybrid = []\n\n CAMS_ds_time_old = CAMS_ds.sel(time = time)\n CAMS_ds_time_old = subset(CAMS_ds_time_old, bbox)\n\n # Initialize partial columns at the top of the atmosphere as 0\n PC_hybrid_0 = CAMS_ds_time_old.sel(hybrid = 1)\n PC_hybrid_0['component'] = PC_hybrid_0['component'].where(PC_hybrid_0['component'] <= 0, 0, drop = False)\n PC_hybrid_0 = PC_hybrid_0.expand_dims(dim = ['hybrid'])\n PC_hybrid.append(PC_hybrid_0)\n CAMS_ds_time_new = PC_hybrid_0\n \n for hybrid in range(1, 136):\n\n # Calculate partial columns above each CAMS level\n PC_last = CAMS_ds_time_new.component.sel(hybrid = hybrid)\n PC_current = CAMS_ds_time_old.component.sel(hybrid = hybrid + 1)\n pressure_last = CAMS_ds_time_old.pressure.sel(hybrid = hybrid)\n pressure_current = CAMS_ds_time_old.pressure.sel(hybrid = hybrid + 1)\n pressure_diff = pressure_current - pressure_last\n\n # Units: Component(kg/kg) * ph-diff(Pa = kg/m*s2)) * s2/m -> To kg/m2\n PC_above = CAMS_ds_time_old.sel(hybrid = hybrid + 1)\n PC_above['component'] = PC_last + PC_current * pressure_diff * (1/9.81)\n PC_hybrid.append(PC_above)\n CAMS_ds_time_new = xr.concat(PC_hybrid, pd.Index(range(1, hybrid + 2), name = 'hybrid'))\n\n CAMS_ds_all.append(CAMS_ds_time_new)\n\n CAMS_ds = xr.concat(CAMS_ds_all, dim = 'time')\n\n else:\n\n # Create xarray object from levels df\n CAMS_levels_df_ds = CAMS_levels_df.to_xarray()\n\n # From kg/kg to kg/m3\n CAMS_ds = CAMS_ds * CAMS_levels_df_ds['Density [kg/m^3]']\n\n # From kg/m3 to kg/m2\n CAMS_ds = CAMS_ds * CAMS_levels_df_ds['Depth [m]']\n\n return CAMS_ds",
"_____no_output_____"
],
[
"def CAMS_kg_m2_to_molecules_cm2(CAMS_ds, component_mol_weight):\n\n \"\"\" Convert the units of the CAMS dataset for any component from kg/m2 to molecules/cm2\n\n Args:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n component_mol_weight (float): Component molecular weight\n\n Returns:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n \"\"\"\n\n NA = 6.022*10**23\n CAMS_ds['component'] = (CAMS_ds['component'] * NA * 1000) / (10000 * component_mol_weight)\n \n return CAMS_ds",
"_____no_output_____"
],
[
"def CAMS_molecules_cm2_to_DU(CAMS_ds):\n\n \"\"\" Convert the units of the CAMS dataset for any component from molecules/cm2 to DU for ozone\n\n Args:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n\n Returns:\n CAMS_ds (xarray): CAMS levels dataset in xarray format\n \"\"\"\n\n CAMS_ds = CAMS_ds / (2.69*10**16)\n \n return CAMS_ds",
"_____no_output_____"
]
]
] | [
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecad0076bda818e41d51cafd0b0232c29012e224 | 12,734 | ipynb | Jupyter Notebook | Memory Management/Dynamic Memory Allocation (The Heap)/workspace/using malloc and free/Guide.ipynb | EarthMan123/Cpp-Notes | 92b129649f494485e40cbbb5d346a9422056667d | [
"MIT"
] | null | null | null | Memory Management/Dynamic Memory Allocation (The Heap)/workspace/using malloc and free/Guide.ipynb | EarthMan123/Cpp-Notes | 92b129649f494485e40cbbb5d346a9422056667d | [
"MIT"
] | null | null | null | Memory Management/Dynamic Memory Allocation (The Heap)/workspace/using malloc and free/Guide.ipynb | EarthMan123/Cpp-Notes | 92b129649f494485e40cbbb5d346a9422056667d | [
"MIT"
] | null | null | null | 40.044025 | 506 | 0.633736 | [
[
[
"## Allocating Dynamic Memory\nTo allocate dynamic memory on the heap means to make a contiguous memory area accessible to the program at runtime and to mark this memory as occupied so that no one else can write there by mistake. \n\nTo reserve memory on the heap, one of the two functions `malloc` (stands for *Memory Allocation*) or `calloc` (stands for *Cleared Memory Allocation*) is used. The header file `stdlib.h` or `malloc.h` must be included to use the functions. \n\nHere is the syntax of `malloc` and `calloc` in C/C++:\n\n```\npointer_name = (cast-type*) malloc(size);\npointer_name = (cast-type*) calloc(num_elems, size_elem);\n```\n\n`malloc` is used to dynamically allocate a single large block of memory with the specified size. It returns a pointer of type `void` which can be cast into a pointer of any form.\n\n\n`calloc` is used to dynamically allocate the specified number of blocks of memory of the specified type. It initializes each block with a default value '0'.\n\nBoth functions return a pointer of type `void` which can be cast into a pointer of any form. If the space for the allocation is insufficient, a NULL pointer is returned.",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"In the code example on the right, a block of memory the size of an integer is allocated using `malloc`.\n\nThe `sizeof` command is a convenient way of specifying the amount of memory (in bytes) needed to store a certain data type. For an `int`, `sizeof` returns 4. However, when compiling this code, the following warning is generated on my machine:\n\n```\nwarning: ISO C++ does not allow indirection on operand of type 'void *' [-Wvoid-ptr-dereference] \n\nprintf(\"address=%p, value=%d\", p, *p);\n```\n\nIn the virtual workspace, when compiling with `g++`, an error is thrown instead of a warning.\n\nThe problem with `void` pointers is that there is no way of knowing the offset to the end of the allocated memory block. For an int, this would be 4 bytes but for a double, the offset would be 8 bytes. So in order to retrieve the entire block of memory that has been reserved, we need to know the data type and the way to achieve this with `malloc` is by casting the return pointer: \n\n`int *p = (int*)malloc(sizeof(int));`\n\nThis code now produces the following output without compiler warnings: \n`address=0x1003001f0, value=0`\n\nObviously, the memory has been initialized with 0 in this case. However, you should not rely on pre-initialization as this depends on the data type as well as on the compiler you are using. \n\nAt compile time, only the space for the pointer is reserved (on the stack). When the pointer is initialized, a block of memory of `sizeof(int)` bytes is allocated (on the heap) at program runtime. The pointer on the stack then points to this memory location on the heap.",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"### Quiz\n\nModify the example in a way that memory for 3 integers is reserved. ",
"_____no_output_____"
],
[
"```cpp\n // reserve memory for several integers\n int *p2 = (int*)malloc(3*sizeof(int));\n printf(\"address=%p, value=%d\\n\", p2, *p2);\n```",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"## Memory for Arrays and Structs\n\nSince arrays and pointers are displayed and processed identically internally, individual blocks of data can also be accessed using array syntax: \n\n```cpp\n int *p = (int*)malloc(3*sizeof(int));\n p[0] = 1; p[1] = 2; p[2] = 3;\n printf(\"address=%p, second value=%d\\n\", p, p[1]);\n```\n\nUntil now, we have only allocated memory for a C/C++ data primitive (i.e. `int`). However, we can also define a proprietary structure which consists of several primitive data types and use `malloc` or `calloc` in the same manner as before: \n\n```cpp\nstruct MyStruct {\n int i; \n double d; \n char a[5];\n};\n \nMyStruct *p = (MyStruct*)calloc(4,sizeof(MyStruct));\np[0].i = 1; p[0].d = 3.14159; p[0].a[0] = 'a';\n```\n\nAfter defining the struct `MyStruct` which contains a number of data primitives, a block of memory four times the size of `MyStruct` is created using the `calloc` command. As can be seen, the various data elements can be accessed very conveniently.",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"## Changing the Size of Memory Blocks",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"The size of the memory area reserved with `malloc` or `calloc` can be increased or decreased with the `realloc` function. \n\n`pointer_name = (cast-type*) realloc( (cast-type*)old_memblock, new_size );`\n\nTo do this, the function must be given a pointer to the previous memory area and the new size in bytes. Depending on the compiler, the reserved memory area is either (a) expanded or reduced internally (if there is still enough free heap after the previously reserved memory area) or (b) a new memory area is reserved in the desired size and the old memory area is released afterwards. \n\nThe data from the old memory area is retained, i.e. if the new memory area is larger, the data will be available within new memory area as well. If the new memory area is smaller, the data from the old area will be available only up until the site of the new area - the rest is lost.\n\nIn the example on the right, a block of memory of initially 8 bytes (two integers) is resized to 16 bytes (four integers) using `realloc`.\n\nNote that realloc has been used to increase the memory size and then decrease it immediately after assigning the values 3 and 4 to the new blocks. The output looks like the following: \n\n```\naddress=0x100300060, value=1\naddress=0x100300064, value=2\naddress=0x100300068, value=3\naddress=0x10030006c, value=4\n```\n\nInterestingly, the pointers `p+2` and `p+3` can still access the memory location they point to. Also, the original data (numbers 3 and 4) is still there. So `realloc` will not erase memory but merely mark it as \"available\" for future allocations. It should be noted however that accessing a memory location _after_ such an operation must be avoided as it could cause a segmentation fault. We will encounter segmentation faults soon when we discuss \"dangling pointers\" in one of the next lessons. ",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"## Freeing up Memory\nIf memory has been reserved, it should also be released as soon as it is no longer needed. If memory is reserved regularly without releasing it again, the memory capacity may be exhausted at some point. If the RAM memory is completely used up, the data is swapped out to the hard disk, which slows down the computer significantly.\n\nThe `free` function releases the reserved memory area so that it can be used again or made available to other programs. To do this, the pointer pointing to the memory area to be freed is specified as a parameter for the function. In the `free_example.cpp`, a memory area is reserved and immediately released again.",
"_____no_output_____"
],
[
"<!--\n%%ulab_page_divider\n--><hr/>",
"_____no_output_____"
],
[
"Some things should be considered with dynamic memory management, whose neglect in some cases might result in unpredictable program behavior or a system crash - in some cases unfortunately without error messages from the compiler or the operating system:\n\n1. `free` can only free memory that was reserved with `malloc` or `calloc`.\n\n2. `free` can only release memory that has not been released before. Releasing the same block of memory twice will result in an error. \n\nIn the example on the right, a pointer `p` is copied into a new variable `p2`, which is then passed to `free` AFTER the original pointer has been already released.\n\n`free(41143,0x1000a55c0) malloc: *** error for object 0x1003001f0: pointer being freed was not allocated.`\n\nIn the workspace, you will see this error:\n\n`*** Error in './a.out': double free or corruption (fasttop): 0x0000000000755010 ***`\n\nThe pointer `p2` in the example is invalid as soon as `free(p)` is called. It still holds the address to the memory location which has been freed, but may not access it anymore. Such a pointer is called a \"dangling pointer\".\n\n3. Memory allocated with `malloc` or `calloc` is not subject to the familiar rules of variables in their respective scopes. This means that they exist independently of block limits until they are released again or the program is terminated. However, the pointers which refer to such heap-allocated memory are created on the stack and thus only exist within a limited scope. As soon as the scope is left, the pointer variable will be lost - but not the heap memory it refers to.",
"_____no_output_____"
]
]
] | [
"markdown"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
]
] |
ecad0bb099ea28dd83123649c788b51021334750 | 5,203 | ipynb | Jupyter Notebook | module4-makefeatures/Make_Features_Assignment.ipynb | cardstud/DS-Unit-1-Sprint-1-Dealing-With-Data | 1138e8c65adac16e55764bf3739be6a9dab60668 | [
"MIT"
] | null | null | null | module4-makefeatures/Make_Features_Assignment.ipynb | cardstud/DS-Unit-1-Sprint-1-Dealing-With-Data | 1138e8c65adac16e55764bf3739be6a9dab60668 | [
"MIT"
] | null | null | null | module4-makefeatures/Make_Features_Assignment.ipynb | cardstud/DS-Unit-1-Sprint-1-Dealing-With-Data | 1138e8c65adac16e55764bf3739be6a9dab60668 | [
"MIT"
] | null | null | null | 33.567742 | 357 | 0.560062 | [
[
[
"<a href=\"https://colab.research.google.com/github/cardstud/DS-Unit-1-Sprint-1-Dealing-With-Data/blob/master/module4-makefeatures/Make_Features_Assignment.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
],
[
"<img align=\"left\" src=\"https://lever-client-logos.s3.amazonaws.com/864372b1-534c-480e-acd5-9711f850815c-1524247202159.png\" width=200> ",
"_____no_output_____"
],
[
"# ASSIGNMENT\n\n- Replicate the lesson code.\n\n - This means that if you haven't followed along already, type out the things that we did in class. Forcing your fingers to hit each key will help you internalize the syntax of what we're doing.\n - [Lambda Learning Method for DS - By Ryan Herr](https://docs.google.com/document/d/1ubOw9B3Hfip27hF2ZFnW3a3z9xAgrUDRReOEo-FHCVs/edit?usp=sharing)\n- Convert the `term` column from string to integer.\n- Make a column named `loan_status_is_great`. It should contain the integer 1 if `loan_status` is \"Current\" or \"Fully Paid.\" Else it should contain the integer 0.\n\n- Make `last_pymnt_d_month` and `last_pymnt_d_year` columns.",
"_____no_output_____"
]
],
[
[
"##### Begin Working Here #####",
"_____no_output_____"
]
],
[
[
"# STRETCH OPTIONS\n\nYou can do more with the LendingClub or Instacart datasets.\n\nLendingClub options:\n- There's one other column in the dataframe with percent signs. Remove them and convert to floats. You'll need to handle missing values.\n- Modify the `emp_title` column to replace titles with 'Other' if the title is not in the top 20. \n- Take initiatve and work on your own ideas!\n\nInstacart options:\n- Read [Instacart Market Basket Analysis, Winner's Interview: 2nd place, Kazuki Onodera](http://blog.kaggle.com/2017/09/21/instacart-market-basket-analysis-winners-interview-2nd-place-kazuki-onodera/), especially the **Feature Engineering** section. (Can you choose one feature from his bulleted lists, and try to engineer it with pandas code?)\n- Read and replicate parts of [Simple Exploration Notebook - Instacart](https://www.kaggle.com/sudalairajkumar/simple-exploration-notebook-instacart). (It's the Python Notebook with the most upvotes for this Kaggle competition.)\n- Take initiative and work on your own ideas!",
"_____no_output_____"
],
[
"You can uncomment and run the cells below to re-download and extract the Instacart data",
"_____no_output_____"
]
],
[
[
"# !wget https://s3.amazonaws.com/instacart-datasets/instacart_online_grocery_shopping_2017_05_01.tar.gz",
"_____no_output_____"
],
[
"# !tar --gunzip --extract --verbose --file=instacart_online_grocery_shopping_2017_05_01.tar.gz",
"_____no_output_____"
],
[
"# %cd instacart_2017_05_01",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code"
]
] |
ecad0d93d9a80d104ed7af64a9ef47ec989bea39 | 9,639 | ipynb | Jupyter Notebook | mini_book/multi_model_comparison.ipynb | DHI/book-learn-mikeio-fmskill | 595b95e341379f647e1dfd428a72516f699877c6 | [
"MIT"
] | 1 | 2021-09-21T15:21:37.000Z | 2021-09-21T15:21:37.000Z | mini_book/multi_model_comparison.ipynb | DHI/book-learn-mikeio-fmskill | 595b95e341379f647e1dfd428a72516f699877c6 | [
"MIT"
] | null | null | null | mini_book/multi_model_comparison.ipynb | DHI/book-learn-mikeio-fmskill | 595b95e341379f647e1dfd428a72516f699877c6 | [
"MIT"
] | null | null | null | 21.325221 | 161 | 0.528789 | [
[
[
"# Multi model comparison\n\nWe often want to compare the result of multiple models. \n\n**Calibration**. We have several \"runs\" of the same model with different settings. We would like to find the best. \n\n**Validation**. We would like to compare our model with alternative models, e.g. a regional DHI model or an external model. \n\nIn this notebook, we will consider several wave models for the Southern North Sea and compare to both point measurements and satellite altimetry data. \n",
"_____no_output_____"
]
],
[
[
"import numpy as np\nfrom fmskill import ModelResult\nfrom fmskill import PointObservation, TrackObservation, Connector",
"_____no_output_____"
]
],
[
[
"## Define observations",
"_____no_output_____"
]
],
[
[
"o1 = PointObservation('data/SW/HKNA_Hm0.dfs0', item=0, x=4.2420, y=52.6887, name=\"HKNA\")\no2 = PointObservation(\"data/SW/eur_Hm0.dfs0\", item=0, x=3.2760, y=51.9990, name=\"EPL\")\no3 = TrackObservation(\"data/SW/Alti_c2_Dutch.dfs0\", item=3, name=\"c2\")",
"_____no_output_____"
]
],
[
[
"## Define models",
"_____no_output_____"
]
],
[
[
"mr1 = ModelResult('data/SW/HKZN_local_2017_DutchCoast.dfsu', name='SW_1', item=0)\nmr2 = ModelResult('data/SW/HKZN_local_2017_DutchCoast_v2.dfsu', name='SW_2', item=0)\nmr3 = ModelResult('data/SW/ERA5_DutchCoast.nc', name='ERA5', item=\"swh\")",
"_____no_output_____"
]
],
[
[
"## Connect observations and model results",
"_____no_output_____"
]
],
[
[
"con = Connector([o1, o2, o3], [mr1, mr2, mr3])\ncon",
"_____no_output_____"
],
[
"con.modelresults",
"_____no_output_____"
],
[
"con.plot_observation_positions();",
"_____no_output_____"
],
[
"con.plot_temporal_coverage();",
"_____no_output_____"
],
[
"cc = con.extract() # returns a collection of comparisons",
"_____no_output_____"
],
[
"cc[\"EPL\"] # select a single comparer from the collection like this",
"_____no_output_____"
]
],
[
[
"## Perform analysis\nYou can perform simple filtering on specific `observation` or specific `model`. You can refer to observations and models using their _name_ or _index_. \n\nThe main analysis methods are:\n* skill()\n* mean_skill()\n* scatter()\n* taylor()",
"_____no_output_____"
]
],
[
[
"cc.skill()",
"_____no_output_____"
],
[
"cc.skill(observation=\"c2\")",
"_____no_output_____"
],
[
"cc.mean_skill(model=0, observation=[0,\"c2\"])",
"_____no_output_____"
],
[
"cc.scatter(model='SW_1', cmap='OrRd')",
"_____no_output_____"
],
[
"cc.taylor(normalize_std=True, aggregate_observations=False)",
"_____no_output_____"
]
],
[
[
"### Time series plot (specifically for point comparisons)\nIf you select an comparison from the collection which is a PointComparer, you can do a time series plot",
"_____no_output_____"
]
],
[
[
"cc['EPL'].plot_timeseries(figsize=(12,4));",
"_____no_output_____"
]
],
[
[
"## Filtering on time\nUse the `start` and `end` arguments to do your analysis on part of the time series",
"_____no_output_____"
]
],
[
[
"cc.skill(model=\"SW_1\", end='2017-10-28')",
"_____no_output_____"
],
[
"cc.scatter(model='SW_2', start='2017-10-28', cmap='OrRd', figsize=(6,7))",
"_____no_output_____"
]
],
[
[
"## Filtering on area\nYou can do you analysis in a specific `area` by providing a bounding box or a closed polygon",
"_____no_output_____"
]
],
[
[
"bbox = np.array([0.5,52.5,5,54])\npolygon = np.array([[6,51],[0,55],[0,51],[6,51]])",
"_____no_output_____"
],
[
"ax = con.plot_observation_positions();\nax.plot([bbox[0],bbox[2],bbox[2],bbox[0],bbox[0]],[bbox[1],bbox[1],bbox[3],bbox[3],bbox[1]]);\nax.plot(polygon[:,0],polygon[:,1]);",
"_____no_output_____"
],
[
"cc.skill(model=\"SW_1\", area=bbox)",
"_____no_output_____"
],
[
"cc.scatter(model=\"SW_2\", area=polygon) # , backend='plotly'",
"_____no_output_____"
]
],
[
[
"## Skill object\n\nThe skill() and mean_skill() methods return a skill object that can visualize results in various ways. The primary methods of the skill object are:\n\n* style()\n* plot_bar()\n* plot_barh()\n* plot_line()\n* plot_grid()\n* sel()",
"_____no_output_____"
]
],
[
[
"s = cc.skill()",
"_____no_output_____"
],
[
"s.style()",
"_____no_output_____"
],
[
"s.style(columns='rmse')",
"_____no_output_____"
],
[
"s.plot_bar('rmse');\ns.plot_barh('rmse'); # horizontal version",
"_____no_output_____"
],
[
"s = cc.skill(by=['model','freq:12H'], metrics=['bias','rmse','si'])",
"_____no_output_____"
],
[
"s.style()",
"_____no_output_____"
],
[
"s.plot_line('rmse', title='Hm0 rmse [m]');",
"_____no_output_____"
],
[
"s.plot_grid('si', fmt='0.1%', title='Hm0 Scatter index');",
"_____no_output_____"
]
],
[
[
"### The sel() method can subset the skill object \n\nA new skill object will be returned",
"_____no_output_____"
]
],
[
[
"s = cc.skill()\ns.style()",
"_____no_output_____"
],
[
"s.sel(model='SW_1').style()",
"_____no_output_____"
],
[
"s.sel(observation='HKNA').style()",
"_____no_output_____"
],
[
"s.sel('rmse>0.25').style()",
"_____no_output_____"
],
[
"s.sel('rmse>0.3', columns=['rmse','mae']).style()",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
]
] |
ecad2a75c056df88c41a6c12090d474e15e9c225 | 36,372 | ipynb | Jupyter Notebook | C2.kNN_Classification/kNN_Classification_professor.ipynb | naxvm/ML4all | 8a604560362e12e78fd4698a3109b81ae426d9b2 | [
"MIT"
] | null | null | null | C2.kNN_Classification/kNN_Classification_professor.ipynb | naxvm/ML4all | 8a604560362e12e78fd4698a3109b81ae426d9b2 | [
"MIT"
] | null | null | null | C2.kNN_Classification/kNN_Classification_professor.ipynb | naxvm/ML4all | 8a604560362e12e78fd4698a3109b81ae426d9b2 | [
"MIT"
] | null | null | null | 35.278371 | 808 | 0.569696 | [
[
[
"\n# The $k$-Nearest Neighbor Classification Algorithm\n\n Notebook version: 2.1 (Oct 19, 2018)\n\n Author: Jesús Cid Sueiro ([email protected])\n Jerónimo Arenas García ([email protected])\n \n Changes: v.1.0 - First version\n v.1.1 - Function loadDataset updated to work with any number of dimensions\n v.2.0 - Compatible with Python 3 (backcompatible with Python 2.7)\n Added solution to Exercise 3\n v.2.1 - Minor corrections regarding notation",
"_____no_output_____"
]
],
[
[
"from __future__ import print_function\n# To visualize plots in the notebook\n%matplotlib inline \n\n# Import some libraries that will be necessary for working with data and displaying plots\nimport csv # To read csv files\nimport random\nimport matplotlib.pyplot as plt\nimport numpy as np\nfrom scipy import spatial\nfrom sklearn import neighbors, datasets",
"_____no_output_____"
]
],
[
[
"\n## 1. The binary classification problem.\n\nIn a binary classification problem, we are given an observation vector ${\\bf x}\\in \\mathbb{R}^N$ which is known to belong to one and only one *category* or *class*, $y$, in the set ${\\mathcal Y} = \\{0, 1\\}$. The goal of a classifier system is to predict the value of $y$ based on ${\\bf x}$.\n\nTo design the classifier, we are given a collection of labelled observations ${\\mathcal D} = \\{({\\bf x}^{(k)}, y^{(k)})\\}_{k=0}^{K-1}$ where, for each observation ${\\bf x}^{(k)}$, the value of its true category, $y^{(k)}$, is known. All samples are outcomes of an unknown distribution $p_{{\\bf X},Y}({\\bf x}, y)$.",
"_____no_output_____"
],
[
"## 2. The Iris dataset\n\n(Iris dataset presentation is based on this <a href=http://machinelearningmastery.com/tutorial-to-implement-k-nearest-neighbors-in-python-from-scratch/> Tutorial </a> by <a href=http://machinelearningmastery.com/about/> Jason Brownlee</a>) \n\nTo illustrate the algorithms, we will consider the <a href = http://archive.ics.uci.edu/ml/datasets/Iris> Iris dataset </a>, taken from the <a href=http://archive.ics.uci.edu/ml/> UCI Machine Learning repository </a>. Quoted from the dataset description:\n\n> This is perhaps the best known database to be found in the pattern recognition literature. The data set contains 3 classes of 50 instances each, where each class refers to a type of iris plant. [...] One class is linearly separable from the other 2; the latter are NOT linearly separable from each other. \n\nThe *class* is the species, which is one of *setosa*, *versicolor* or *virginica*. Each instance contains 4 measurements of given flowers: sepal length, sepal width, petal length and petal width, all in centimeters. \n",
"_____no_output_____"
]
],
[
[
"# Taken from Jason Brownlee notebook.\nwith open('datasets/iris.data', 'r') as csvfile:\n\tlines = csv.reader(csvfile)\n\tfor row in lines:\n\t\tprint(', '.join(row))",
"_____no_output_____"
]
],
[
[
"### 2.1. Train/test split\n\nNext, we will split the data into a training dataset, that will be used to learn the classification model, and a test dataset that we can use to evaluate its the accuracy.\n\nWe first need to convert the flower measures that were loaded as strings into numbers that we can work with. Next we need to split the data set **randomly** into train and datasets. A ratio of 67/33 for train/test will be used.\n\nThe code fragment below defines a function `loadDataset` that loads the data in a CSV with the provided filename and splits it randomly into train and test datasets using the provided split ratio.",
"_____no_output_____"
]
],
[
[
"# Adapted from a notebook by Jason Brownlee\ndef loadDataset(filename, split):\n xTrain = []\n cTrain = []\n xTest = []\n cTest = []\n\n with open(filename, 'r') as csvfile:\n lines = csv.reader(csvfile)\n dataset = list(lines)\n for i in range(len(dataset)-1):\n for y in range(4):\n dataset[i][y] = float(dataset[i][y])\n item = dataset[i]\n if random.random() < split:\n xTrain.append(item[0:-1])\n cTrain.append(item[-1])\n else:\n xTest.append(item[0:-1])\n cTest.append(item[-1])\n return xTrain, cTrain, xTest, cTest",
"_____no_output_____"
]
],
[
[
"We can use this function to get a data split. Note that, because of the way samples are assigned to the train or test datasets, the number of samples in each partition will differ if you run the code several times.",
"_____no_output_____"
]
],
[
[
"xTrain_all, cTrain_all, xTest_all, cTest_all = loadDataset('datasets/iris.data', 0.67)\nnTrain_all = len(xTrain_all)\nnTest_all = len(xTest_all)\nprint('Train:', nTrain_all)\nprint('Test:', nTest_all)\n",
"_____no_output_____"
]
],
[
[
"### 2.2. Versicolor vs Virginica\n\nIn the following, we will design a classifier to separate classes \"Versicolor\" and \"Virginica\" using $x_0$ and $x_1$ only. To do so, we build a training set with samples from these categories, and a bynary label $y^{(k)} = 1$ for samples in class \"Virginica\", and $0$ for \"Versicolor\" data.",
"_____no_output_____"
]
],
[
[
"# Select two classes\nc0 = 'Iris-versicolor' \nc1 = 'Iris-virginica'\n\n# Select two coordinates\nind = [0, 1]\n\n# Take training test\nX_tr = np.array([[xTrain_all[n][i] for i in ind] for n in range(nTrain_all) \n if cTrain_all[n]==c0 or cTrain_all[n]==c1])\nC_tr = [cTrain_all[n] for n in range(nTrain_all) \n if cTrain_all[n]==c0 or cTrain_all[n]==c1]\nY_tr = np.array([int(c==c1) for c in C_tr])\nn_tr = len(X_tr)\n\n# Take test set\nX_tst = np.array([[xTest_all[n][i] for i in ind] for n in range(nTest_all) \n if cTest_all[n]==c0 or cTest_all[n]==c1])\nC_tst = [cTest_all[n] for n in range(nTest_all) \n if cTest_all[n]==c0 or cTest_all[n]==c1]\nY_tst = np.array([int(c==c1) for c in C_tst])\nn_tst = len(X_tst)\n\n# Separate components of x into different arrays (just for the plots)\nx0c0 = [X_tr[n][0] for n in range(n_tr) if Y_tr[n]==0]\nx1c0 = [X_tr[n][1] for n in range(n_tr) if Y_tr[n]==0]\nx0c1 = [X_tr[n][0] for n in range(n_tr) if Y_tr[n]==1]\nx1c1 = [X_tr[n][1] for n in range(n_tr) if Y_tr[n]==1]\n\n# Scatterplot.\nlabels = {'Iris-setosa': 'Setosa', \n 'Iris-versicolor': 'Versicolor',\n 'Iris-virginica': 'Virginica'}\nplt.plot(x0c0, x1c0,'r.', label=labels[c0])\nplt.plot(x0c1, x1c1,'g+', label=labels[c1])\nplt.xlabel('$x_' + str(ind[0]) + '$')\nplt.ylabel('$x_' + str(ind[1]) + '$')\nplt.legend(loc='best')\nplt.show()\n",
"_____no_output_____"
]
],
[
[
"## 3. Baseline Classifier: Maximum A Priori.\n\nFor the selected data set, we have two clases and a dataset with the following class proportions:",
"_____no_output_____"
]
],
[
[
"print('Class 0 (' + c0 + '): ' + str(n_tr - sum(Y_tr)) + ' samples')\nprint('Class 1 (' + c1 + '): ' + str(sum(Y_tr)) + ' samples')",
"_____no_output_____"
]
],
[
[
"The maximum a priori classifier assigns any sample ${\\bf x}$ to the most frequent class in the training set. Therefore, the class prediction $y$ for any sample ${\\bf x}$ is",
"_____no_output_____"
]
],
[
[
"y = int(2*sum(Y_tr) > n_tr)\nprint('y = ' + str(y) + ' (' + (c1 if y==1 else c0) + ')')",
"_____no_output_____"
]
],
[
[
"The error rate for this baseline classifier is:",
"_____no_output_____"
]
],
[
[
"# Training and test error arrays\nE_tr = (Y_tr != y)\nE_tst = (Y_tst != y)\n\n# Error rates\npe_tr = float(sum(E_tr)) / n_tr\npe_tst = float(sum(E_tst)) / n_tst\nprint('Pe(train):', pe_tr)\nprint('Pe(test):', pe_tst)",
"_____no_output_____"
]
],
[
[
"The error rate of the baseline classifier is a simple benchmark for classification. Since the maximum a priori decision is independent on the observation, ${\\bf x}$, any classifier based on ${\\bf x}$ should have a better (or, at least, not worse) performance than the baseline classifier.",
"_____no_output_____"
],
[
"## 4. The Nearest-Neighbour Classifier (1-NN).\n\n\nThe 1-NN classifier assigns any instance ${\\bf x}$ to the category of the nearest neighbor in the training set.\n$$\nd = f({\\bf x}) = y^{(n)}, {\\rm~where} \\\\\nn = \\arg \\min_k \\|{\\bf x}-{\\bf x}^{(k)}\\|\n$$\nIn case of ties (i.e. if there is more than one instance at minimum distance) the class of one of them, taken arbitrarily, is assigned to ${\\bf x}$.",
"_____no_output_____"
]
],
[
[
"def nn_classifier(X1,Y1,X2):\n \"\"\" Compute the 1-NN classification for the observations contained in\n the rows of X2, for the training set given by the rows in X1 and the\n class labels contained in Y1.\n \"\"\"\n if X1.ndim == 1:\n X1 = np.asmatrix(X1).T\n if X2.ndim == 1:\n X2 = np.asmatrix(X2).T\n distances = spatial.distance.cdist(X1,X2,'euclidean')\n neighbors = np.argsort(distances, axis=0, kind='quicksort', order=None)\n closest = neighbors[0,:]\n y_values = np.zeros([X2.shape[0],1])\n for idx in range(X2.shape[0]):\n y_values[idx] = Y1[closest[idx]]\n \n return y_values",
"_____no_output_____"
]
],
[
[
"Let us apply the 1-NN classifier to the given dataset. First, we will show the decision regions of the classifier. To do so, we compute the classifier output for all points in a rectangular grid from the sample space.",
"_____no_output_____"
]
],
[
[
"# Create a regtangular grid.\nn_points = 200\nx_min, x_max = X_tr[:, 0].min(), X_tr[:, 0].max() \ny_min, y_max = X_tr[:, 1].min(), X_tr[:, 1].max()\ndx = x_max - x_min\ndy = y_max - y_min\nh = dy / n_points\nxx, yy = np.meshgrid(np.arange(x_min - 0.1 * dx, x_max + 0.1 * dx, h),\n np.arange(y_min - 0.1 * dx, y_max + 0.1 * dy, h))\nX_grid = np.array([xx.ravel(), yy.ravel()]).T\n\n# Compute the classifier output for all samples in the grid.\nZ = nn_classifier(X_tr, Y_tr, X_grid)\n\n# Put the result into a color plot\nplt.plot(x0c0, x1c0,'r.', label=labels[c0])\nplt.plot(x0c1, x1c1,'g+', label=labels[c1])\nplt.xlabel('$x_' + str(ind[0]) + '$')\nplt.ylabel('$x_' + str(ind[1]) + '$')\nplt.legend(loc='best')\n\nZ = Z.reshape(xx.shape)\nplt.contourf(xx, yy, Z)\nplt.show()",
"_____no_output_____"
]
],
[
[
"We can observe that the decision boudary of the 1-NN classifier is rather intricate, and it may contain small *islands* covering one or few samples from one class. Actually, the extension of these small regions usually reduces as we have more training samples, though the number of them may increase.\n\nNow we compute the error rates over the training and test sets.",
"_____no_output_____"
]
],
[
[
"# Training errors\nZ_tr = nn_classifier(X_tr, Y_tr, X_tr)\nE_tr = Z_tr.flatten()!=Y_tr\n\n# Test errors\nZ_tst = nn_classifier(X_tr, Y_tr, X_tst)\nE_tst = Z_tst.flatten()!=Y_tst\n\n# Error rates\npe_tr = float(sum(E_tr)) / n_tr\npe_tst = float(sum(E_tst)) / n_tst\nprint('Pe(train):', pe_tr)\nprint('Pe(test):', pe_tst)",
"_____no_output_____"
]
],
[
[
"The training and test error rates of the 1-NN may be significantly different. In fact, the training error may go down to zero if samples do not overlap. In the selected problem, this is not the case, because samples from different classes coincide at the same point, causing some classification errors.",
"_____no_output_____"
],
[
"**Consistency of the 1-NN classifier**\n\nDespite the 1-NN usually reduces the error rate with respect to the baseline classifier, the number of errors may be too large. Errors may be attributed to diferent causes:\n\n 1. The class distributions are overlapped, because the selected features have no complete information for discriminating between the classes: this would imply that, even the best possible classifier would be prone to errors.\n 2. The training sample is small, and it is not enough to obtaing a good estimate of the optimal classifiers.\n 3. The classifier has intrinsic limitations: even though we had an infinite number of samples, the classifier performance does not approach the optimal classifiers.\n\nIn general, a classifier is said to be consistent if it makes nearly optimal decisions as the number of training samples increases. Actually, it can be shown that this is the case of the 1-NN classifier if the classification problem is separable, i.e. if there exist a decision boundary with zero error probability. Unfortunately, in a non-separable case, the 1-NN classifier is not consistent. It can be shown that the error rate of the 1-NN classifier converges to an error rate which is not worse than twice the minimum attainable error rate (Bayes error rate) as the number of training samples goes to infinity.",
"_____no_output_____"
],
[
"**Exercise 1**: In this exercise we test the non-consistency of the 1-NN classifier for overlapping distributions. Generate an artificial dataset for classification as follows:\n\n- Generate $N$ binary labels at random with values '0' and '1'. Store them in vector ${\\bf y}$\n- For every label $y^{(k)}$ in ${\\bf y}$:\n - If the label is 0, take sample $x^{(k)}$ at random from a uniform distribution $U(0,2)$.\n - If the label is 1, take sample $x^{(k)}$ at random from a uniform distribution $U(1,5)$.\n\nTake $N=1000$ for the test set. This is a large sample to get accurate error rate estimates. Also, take $N=10$, $20$, $40$, $80$,... for the training set. Compute the 1-NN classifier, and observe the test error rate as a function of $N$. \n\nNow, compute the test error rate of the classifier making decision $1$ if $x^{(k)}>1.5$, and $0$ otherwise. \n",
"_____no_output_____"
]
],
[
[
"# <SOL>\nfrom sklearn.neighbors import KNeighborsClassifier\n\nNtest = 10000\nNtr = [10, 20, 40, 80, 200, 1000]\nnruns = 100\n\nxtest = []\nytest = []\n\nfor k in range(Ntest):\n if k<Ntest/2:\n ytest.append(0)\n xtest.append([2*np.random.random()])\n else:\n ytest.append(1)\n xtest.append([1+4*np.random.random()])\n\n#print(np.mean(np.array(ytest)))\n#print(xtest)\n\nEtest = np.zeros((len(Ntr),))\n\nfor k in range(nruns):\n for kk,Ntrain in enumerate(Ntr):\n xtrain = []\n ytrain = []\n for k in range(Ntrain):\n if k<Ntrain/2:\n ytrain.append(0)\n xtrain.append([2*np.random.random()])\n else:\n ytrain.append(1)\n xtrain.append([1+4*np.random.random()])\n\n #Entreno el clasificador y obtengo predicciones para ytest\n neigh = KNeighborsClassifier(n_neighbors=1)\n ytest_pred = neigh.fit(xtrain,ytrain).predict(xtest)\n tasa_error = np.mean(np.array(ytest)!=ytest_pred)\n \n Etest[kk] += tasa_error/nruns\n\nprint(Etest)\n# </SOL>",
"_____no_output_____"
]
],
[
[
"## 5. $k$-NN classifier\n\nA simple extension of the 1-NN classifier is the $k$-NN classifier, which, for any input sample ${\\bf x}$, computes the $k$ closest neighbors in the training set, and takes the majority class in the subset. To avoid ties, in the binary classification case $k$ is usually taken as an odd number.",
"_____no_output_____"
]
],
[
[
"def knn_classifier(X1,Y1,X2,k):\n \"\"\" Compute the k-NN classification for the observations contained in\n the rows of X2, for the training set given by the rows in X1 and the\n components of S1. k is the number of neighbours.\n \"\"\"\n if X1.ndim == 1:\n X1 = np.asmatrix(X1).T\n if X2.ndim == 1:\n X2 = np.asmatrix(X2).T\n distances = spatial.distance.cdist(X1,X2,'euclidean')\n neighbors = np.argsort(distances, axis=0, kind='quicksort', order=None)\n closest = neighbors[range(k),:]\n \n y_values = np.zeros([X2.shape[0],1])\n for idx in range(X2.shape[0]):\n y_values[idx] = np.median(Y1[closest[:,idx]])\n \n return y_values",
"_____no_output_____"
],
[
"k = 7\n\n# Plot the decision boundary. For that, we will assign a color to each\n# point in the mesh [x_min, m_max]x[y_min, y_max].\nZ = knn_classifier(X_tr, Y_tr, X_grid, k)\n\n# Put the result into a color plot\nplt.plot(x0c0, x1c0,'r.', label=labels[c0])\nplt.plot(x0c1, x1c1,'g+', label=labels[c1])\nplt.xlabel('$x_' + str(ind[0]) + '$')\nplt.ylabel('$x_' + str(ind[1]) + '$')\nplt.legend(loc='best')\n\nZ = Z.reshape(xx.shape)\nplt.contourf(xx, yy, Z)\nplt.show()",
"_____no_output_____"
],
[
"# Plot training and test error as a function of parameter k.\npe_tr = []\npe_tst = []\nk_list = [2*n+1 for n in range(int(np.floor(n_tr/2)))]\n\nfor k in k_list:\n\n # Training errors\n Z_tr = knn_classifier(X_tr, Y_tr, X_tr, k)\n E_tr = Z_tr.flatten()!=Y_tr\n\n # Test errors\n Z_tst = knn_classifier(X_tr, Y_tr, X_tst, k)\n E_tst = Z_tst.flatten()!=Y_tst\n\n # Error rates\n pe_tr.append(float(sum(E_tr)) / n_tr)\n pe_tst.append(float(sum(E_tst)) / n_tst)\n\n# Put the result into a color plot\nmarkerline, stemlines, baseline = plt.stem(k_list, pe_tr,'r', markerfmt='s', label='Training')\nplt.plot(k_list, pe_tr,'r:')\nplt.setp(markerline, 'markerfacecolor', 'r', )\nplt.setp(baseline, 'color','r', 'linewidth', 2)\nmarkerline, stemlines, baseline = plt.stem(k_list, pe_tst, label='Test')\nplt.plot(k_list, pe_tst,'b:')\nplt.xlabel('$k$')\nplt.ylabel('Error rate')\nplt.legend(loc='best')\nplt.show()",
"_____no_output_____"
]
],
[
[
"We can analyze the influence of parameter $k$ by observing both traning and test errors.",
"_____no_output_____"
],
[
"**Exercise 2**: Observe the train and test error for large $k$. Could you relate the error rate of the baseline classifier with that to the $k$-NN for certain value of $k$? ",
"_____no_output_____"
],
[
"The figure above suggests that the optimal value of $k$ is",
"_____no_output_____"
]
],
[
[
"i = np.argmin(pe_tst)\nk_opt = k_list[i]\nprint('k_opt:', k_opt)",
"_____no_output_____"
]
],
[
[
"However, using the test set to select the optimal value of the hyperparameter $k$ is not allowed. Instead, we should recur to cross validation.",
"_____no_output_____"
],
[
"## 2.3 Hyperparameter selection via cross-validation\n\nAn inconvenient of the application of the $k$-nn method is that the selection of $k$ influences the final error of the algorithm. In the previous experiments, we noticed that the location of the minimum is not necessarily the same from the perspective of the test and training data. Ideally, we would like that the designed classification model works as well as possible on future unlabeled patterns that are not available during the training phase. This property is known as <i>generalization</i>. Fitting the training data is only pursued in the hope that we are also indirectly obtaining a model that generalizes well. In order to achieve this goal, there are some strategies that try to guarantee a correct generalization of the model. One of such approaches is known as <b>cross-validation</b>.\n\nSince using the test labels during the training phase is not allowed (they should be kept aside to simultate the future application of the classification model on unseen patterns), we need to figure out some way to improve our estimation of the hyperparameter that requires only training data. Cross-validation allows us to do so by following the following steps:\n\n - Split the training data into several (generally non-overlapping) subsets. If we use $M$ subsets, the method is referred to as $M$-fold cross-validation. If we consider each pattern a different subset, the method is usually referred to as leave-one-out (LOO) cross-validation.\n - Carry out the training of the system $M$ times. For each run, use a different partition as a <i>validation</i> set, and use the restating partitions as the training set. Evaluate the performance for different choices of the hyperparameter (i.e., for different values of $k$ for the $k$-NN method).\n - Average the validation error over all partitions, and pick the hyperparameter that provided the minimum validation error.\n - Rerun the algorithm using all the training data, keeping the value of the parameter that came out of the cross-validation process.",
"_____no_output_____"
]
],
[
[
"## This fragment of code runs k-nn with M-fold cross validation\n\n# Obtain the indices for the different folds\nn_tr = X_tr.shape[0]\nM = n_tr\npermutation = np.random.permutation(n_tr)\n\n# Initialize sets of indices\nset_indices = {n: [] for n in range(M)}\n\n# Distribute data amont M partitions\nn = 0\nfor pos in range(n_tr):\n set_indices[n].append(permutation[pos])\n n = (n+1) % M\n\n# Now, we run the cross-validation process using the k-nn method\nk_max = 30\nk_list = [2*j+1 for j in range(int(k_max))]\n\n# Obtain the validation errors\npe_val = 0\nfor n in range(M):\n i_val = set_indices[n]\n i_tr = []\n for kk in range(M):\n if not n==kk:\n i_tr += set_indices[kk]\n \n pe_val_iter = []\n for k in k_list:\n y_tr_iter = knn_classifier(X_tr[i_tr], Y_tr[i_tr], X_tr[i_val], k)\n pe_val_iter.append(np.mean(Y_tr[i_val] != y_tr_iter))\n\n pe_val = pe_val + np.asarray(pe_val_iter).T\n\npe_val = pe_val / M\n\n# We compute now the train and test errors curves\npe_tr = [np.mean(Y_tr != knn_classifier(X_tr, Y_tr, X_tr, k).T) for k in k_list]\n\nk_opt = k_list[np.argmin(pe_val)]\npe_tst = np.mean(Y_tst != knn_classifier(X_tr, Y_tr, X_tst, k_opt).T)\n\nplt.plot(k_list, pe_tr,'b--o',label='Training error')\nplt.plot(k_list, pe_val.T,'g--o',label='Validation error')\nplt.stem([k_opt], [pe_tst],'r-o',label='Test error')\nplt.legend(loc='best')\nplt.title('The optimal value of $k$ is ' + str(k_opt))\nplt.xlabel('$k$')\nplt.ylabel('Error rate')\nplt.show()",
"_____no_output_____"
]
],
[
[
"## 6. Scikit-learn implementation\n\nIn practice, most well-known machine learning methods are implemented and available for python. Probably, the most complete library for machine learning is <a href=http://scikit-learn.org/stable/>Scikit-learn</a>. The following piece of code uses the method\n\n KNeighborsClassifier\n \navailable in Scikit-learn, to compute the $k$-NN classifier using the four components of the observations in the original dataset. This routine allows us to classify a particular point using a weighted average of the targets of the neighbors:\n\n To classify point ${\\bf x}$:\n \n - Find $k$ closest points to ${\\bf x}$ in the training set\n - Average the corresponding targets, weighting each value according to the distance of each point to ${\\bf x}$, so that closer points have a larger influence in the estimation.\n",
"_____no_output_____"
]
],
[
[
"\nk = 5\n\n# import some data to play with\niris = datasets.load_iris()\n\n# Take training test\nX_tr = np.array([xTrain_all[n] for n in range(nTrain_all) \n if cTrain_all[n]==c0 or cTrain_all[n]==c1])\nC_tr = [cTrain_all[n] for n in range(nTrain_all) \n if cTrain_all[n]==c0 or cTrain_all[n]==c1]\nY_tr = np.array([int(c==c1) for c in C_tr])\nn_tr = len(X_tr)\n\n# Take test set\nX_tst = np.array([xTest_all[n] for n in range(nTest_all) \n if cTest_all[n]==c0 or cTest_all[n]==c1])\nC_tst = [cTest_all[n] for n in range(nTest_all) \n if cTest_all[n]==c0 or cTest_all[n]==c1]\nY_tst = np.array([int(c==c1) for c in C_tst])\nn_tst = len(X_tst)\n\nfor weights in ['uniform', 'distance']:\n # we create an instance of Neighbours Classifier and fit the data.\n clf = neighbors.KNeighborsClassifier(k, weights=weights)\n clf.fit(X_tr, Y_tr)\n Z = clf.predict(X_tst)\n pe_tst = np.mean(Y_tst != Z)\n print('Test error rate with ' + weights + ' weights = ' + str(pe_tst))\n",
"_____no_output_____"
]
],
[
[
"<a href = http://scikit-learn.org/stable/auto_examples/neighbors/plot_classification.html> Here</a> you can find an example of the application of `KNeighborsClassifier` to the complete 3-class Iris flower classification problem.",
"_____no_output_____"
],
[
"## $k$-NN Classification and Probability Estimation.\n\nIf a sample ${\\bf x}$ has $m$ neighbors from class 1 and $k-m$ neighbors from class $0$, we can estimate the posterior probability that an observation ${\\bf x}$ belongs to class 1 as\n$$\n\\hat P(\\{y=1\\}) = \\frac{m}{k}\n$$\nTherefore, besides computing a decision about the class of the data, we can modify the $k$-NN algorithm to obtain posterior probability estimates.\n\nNote that the above equation is equivalent\n$$\n\\hat P(\\{y=1\\}) = \\frac{\\sum_{n \\in {\\mathcal N}({\\bf x})} y^{(n)}}{k}\n$$\nwhere ${\\mathcal N}({\\bf x})$ is the set of indices for the samples in the neighborhood of $\\bf x$.\n\nIn other words, $\\hat P(\\{y=1\\})$ is the *average* of the neighbors labels. Averages can be computed using `KNeighborsRegressor`, which is useful for regression applications.\n",
"_____no_output_____"
],
[
"**Exercise 3**: Plot a $k$-NN posterior probability map for the Iris flower data, for $k=15$.",
"_____no_output_____"
]
],
[
[
"# Select two classes\nc0 = 'Iris-versicolor' \nc1 = 'Iris-virginica'\n\n# Select two coordinates\nind = [0, 1]\n\n# Take training test\nX_tr = np.array([[xTrain_all[n][i] for i in ind] for n in range(nTrain_all) \n if cTrain_all[n]==c0 or cTrain_all[n]==c1])\nC_tr = [cTrain_all[n] for n in range(nTrain_all) \n if cTrain_all[n]==c0 or cTrain_all[n]==c1]\nY_tr = np.array([int(c==c1) for c in C_tr])\nn_tr = len(X_tr)\n\n# Take test set\nX_tst = np.array([[xTest_all[n][i] for i in ind] for n in range(nTest_all) \n if cTest_all[n]==c0 or cTest_all[n]==c1])\nC_tst = [cTest_all[n] for n in range(nTest_all) \n if cTest_all[n]==c0 or cTest_all[n]==c1]\nY_tst = np.array([int(c==c1) for c in C_tst])\nn_tst = len(X_tst)\n\n# Separate components of x into different arrays (just for the plots)\nx0c0 = [X_tr[n][0] for n in range(n_tr) if Y_tr[n]==0]\nx1c0 = [X_tr[n][1] for n in range(n_tr) if Y_tr[n]==0]\nx0c1 = [X_tr[n][0] for n in range(n_tr) if Y_tr[n]==1]\nx1c1 = [X_tr[n][1] for n in range(n_tr) if Y_tr[n]==1]\n",
"_____no_output_____"
],
[
"#<SOL>\nk = 15\n\nfrom sklearn import neighbors\n\nneigh = neighbors.KNeighborsRegressor(n_neighbors=k)\nZ = neigh.fit(X_tr,Y_tr).predict(X_grid)\n\n# Put the result into a color plot\nplt.plot(x0c0, x1c0,'r.', label=labels[c0])\nplt.plot(x0c1, x1c1,'g+', label=labels[c1])\nplt.xlabel('$x_' + str(ind[0]) + '$')\nplt.ylabel('$x_' + str(ind[1]) + '$')\nplt.legend(loc='best')\n\nZ = Z.reshape(xx.shape)\nCS = plt.contourf(xx, yy, Z)\nCS2 = plt.contour(CS, levels=[0.5],\n colors='m', linewidths=(3,))\nplt.show()\n#</SOL>",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
]
] |
ecad2e0073bd596f298d2720d7842f96353d942d | 257,427 | ipynb | Jupyter Notebook | examples/tutorials/colabs/ECCV_2020_Advanced_Features.ipynb | naokiyokoyama/habitat-sim | c6f25ada5d9805987f0395bfdde0e7f8bd3ec285 | [
"MIT"
] | 1 | 2021-03-03T22:17:53.000Z | 2021-03-03T22:17:53.000Z | examples/tutorials/colabs/ECCV_2020_Advanced_Features.ipynb | zhangtianjia/habitat-sim | c6f25ada5d9805987f0395bfdde0e7f8bd3ec285 | [
"MIT"
] | null | null | null | examples/tutorials/colabs/ECCV_2020_Advanced_Features.ipynb | zhangtianjia/habitat-sim | c6f25ada5d9805987f0395bfdde0e7f8bd3ec285 | [
"MIT"
] | null | null | null | 126.999013 | 167,231 | 0.835246 | [
[
[
"<a href=\"https://colab.research.google.com/github/facebookresearch/habitat-sim/blob/master/examples/tutorials/colabs/ECCV_2020_Advanced_Features.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
],
[
"#Habitat-sim Advanced Features\n\nThis tutorial presents a number of advanced feature examples for using Habitat-sim, including:\n\n- Tracking object motion with a camera\n- Projecting 3D points into 2D\n- Configuring semantic ids for objects\n- Object/Asset configuration via template libraries",
"_____no_output_____"
]
],
[
[
"# @title Installation { display-mode: \"form\" }\n# @markdown (double click to show code).\n\n!curl -L https://raw.githubusercontent.com/facebookresearch/habitat-sim/master/examples/colab_utils/colab_install.sh | NIGHTLY=true bash -s\n!wget -c http://dl.fbaipublicfiles.com/habitat/mp3d_example.zip && unzip -o mp3d_example.zip -d /content/habitat-sim/data/scene_datasets/mp3d/",
"_____no_output_____"
],
[
"# @title Path Setup and Imports { display-mode: \"form\" }\n# @markdown (double click to show code).\n\n%cd /content/habitat-sim\n## [setup]\nimport math\nimport os\nimport random\nimport sys\n\nimport git\nimport magnum as mn\nimport numpy as np\n\n%matplotlib inline\nfrom matplotlib import pyplot as plt\nfrom PIL import Image\n\nimport habitat_sim\nfrom habitat_sim.utils import common as ut\nfrom habitat_sim.utils import viz_utils as vut\n\ntry:\n import ipywidgets as widgets\n from IPython.display import display as ipydisplay\n\n # For using jupyter/ipywidget IO components\n\n HAS_WIDGETS = True\nexcept ImportError:\n HAS_WIDGETS = False\n\n\nif \"google.colab\" in sys.modules:\n os.environ[\"IMAGEIO_FFMPEG_EXE\"] = \"/usr/bin/ffmpeg\"\n\nrepo = git.Repo(\".\", search_parent_directories=True)\ndir_path = repo.working_tree_dir\n%cd $dir_path\ndata_path = os.path.join(dir_path, \"data\")\n# fmt: off\noutput_directory = \"examples/tutorials/advanced_features_output/\" # @param {type:\"string\"}\n# fmt: on\noutput_path = os.path.join(dir_path, output_directory)\nif not os.path.exists(output_path):\n os.mkdir(output_path)\n\n# define some globals the first time we run.\nif \"sim\" not in globals():\n global sim\n sim = None\n global obj_attr_mgr\n obj_attr_mgr = None\n global prim_attr_mgr\n obj_attr_mgr = None\n global stage_attr_mgr\n stage_attr_mgr = None",
"_____no_output_____"
],
[
"# @title Define Template Dictionary Utility Functions { display-mode: \"form\" }\n# @markdown (double click to show code)\n\n# @markdown This cell defines utility functions that expose Attribute template object properties.\n\n# This method builds a dictionary of k-v pairs of attribute property names and\n# values shared by all attribute template types. The values are tuples with the\n# first entry being the value and the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_Default_attrs(template):\n res_dict = {}\n res_dict[\"handle\"] = (template.handle, True, \"string\")\n # Read-only values\n res_dict[\"ID\"] = (template.ID, False, \"int\")\n res_dict[\"template_class\"] = (template.template_class, False, \"string\")\n res_dict[\"file_directory\"] = (template.file_directory, False, \"string\")\n return res_dict\n\n\n# This method builds a dictionary of k-v pairs of attribute property names and\n# values shared by templates of physically modeled constructs (scenes and\n# objects). The values are tuples with the first entry being the value and the\n# second being whether the property is editable and the third being the type.\ndef build_dict_of_PhyObj_attrs(phys_obj_template):\n res_dict = build_dict_of_Default_attrs(phys_obj_template)\n res_dict[\"scale\"] = (phys_obj_template.scale, True, \"vector\")\n res_dict[\"margin\"] = (phys_obj_template.margin, True, \"double\")\n res_dict[\"friction_coefficient\"] = (\n phys_obj_template.friction_coefficient,\n True,\n \"double\",\n )\n res_dict[\"restitution_coefficient\"] = (\n phys_obj_template.restitution_coefficient,\n True,\n \"double\",\n )\n res_dict[\"render_asset_handle\"] = (\n phys_obj_template.render_asset_handle,\n True,\n \"string\",\n )\n res_dict[\"collision_asset_handle\"] = (\n phys_obj_template.collision_asset_handle,\n True,\n \"string\",\n )\n res_dict[\"requires_lighting\"] = (\n phys_obj_template.requires_lighting,\n True,\n \"boolean\",\n )\n # New fields, uncomment upon updating conda 8/4/20\n res_dict[\"orient_up\"] = (phys_obj_template.orient_up, True, \"vector\")\n res_dict[\"orient_front\"] = (phys_obj_template.orient_front, True, \"vector\")\n res_dict[\"units_to_meters\"] = (phys_obj_template.units_to_meters, True, \"double\")\n res_dict[\"render_asset_type\"] = (phys_obj_template.render_asset_type, True, \"int\")\n res_dict[\"collision_asset_type\"] = (\n phys_obj_template.collision_asset_type,\n True,\n \"int\",\n )\n # Read-only values\n res_dict[\"render_asset_is_primitive\"] = (\n phys_obj_template.render_asset_is_primitive,\n False,\n \"boolean\",\n )\n res_dict[\"collision_asset_is_primitive\"] = (\n phys_obj_template.collision_asset_is_primitive,\n False,\n \"boolean\",\n )\n res_dict[\"use_mesh_for_collision\"] = (\n phys_obj_template.use_mesh_for_collision,\n False,\n \"boolean\",\n )\n res_dict[\"is_dirty\"] = (phys_obj_template.is_dirty, False, \"boolean\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed object template. The values are tuples with the first\n# entry being the value,the second being whether the property is editable and\n# the third being the type.\ndef build_dict_of_Object_attrs(obj_template):\n res_dict = build_dict_of_PhyObj_attrs(obj_template)\n res_dict[\"com\"] = (obj_template.com, True, \"vector\")\n res_dict[\"compute_COM_from_shape\"] = (\n obj_template.compute_COM_from_shape,\n True,\n \"boolean\",\n )\n res_dict[\"mass\"] = (obj_template.mass, True, \"double\")\n res_dict[\"inertia\"] = (obj_template.inertia, True, \"vector\")\n res_dict[\"linear_damping\"] = (obj_template.linear_damping, True, \"double\")\n res_dict[\"angular_damping\"] = (obj_template.angular_damping, True, \"double\")\n res_dict[\"bounding_box_collisions\"] = (\n obj_template.bounding_box_collisions,\n True,\n \"boolean\",\n )\n res_dict[\"join_collision_meshes\"] = (\n obj_template.join_collision_meshes,\n True,\n \"boolean\",\n )\n # res_dict[\"is_visible\"] = (obj_template.is_visible, True, \"boolean\")\n # res_dict[\"is_collidable\"] = (obj_template.is_collidable, True, \"boolean\")\n res_dict[\"semantic_id\"] = (obj_template.semantic_id, True, \"int\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed scene template. The values are tuples with the first\n# entry being the value,the second being whether the property is editable and\n# the third being the type.\ndef build_dict_of_Stage_attrs(scene_template):\n res_dict = build_dict_of_PhyObj_attrs(scene_template)\n res_dict[\"gravity\"] = (scene_template.gravity, True, \"vector\")\n res_dict[\"origin\"] = (scene_template.origin, True, \"vector\")\n res_dict[\"semantic_asset_handle\"] = (\n scene_template.semantic_asset_handle,\n True,\n \"string\",\n )\n res_dict[\"semantic_asset_type\"] = (scene_template.semantic_asset_type, True, \"int\")\n res_dict[\"navmesh_asset_handle\"] = (\n scene_template.navmesh_asset_handle,\n True,\n \"string\",\n )\n res_dict[\"house_filename\"] = (scene_template.house_filename, True, \"string\")\n # res_dict[\"light_setup\"] = (scene_template.light_setup, True, \"string\")\n # res_dict[\"frustrum_culling\"] = (scene_template.frustrum_culling, True, \"boolean\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed physics manager template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_PhysicsSim_attrs(physics_template):\n res_dict = build_dict_of_Default_attrs(physics_template)\n res_dict[\"gravity\"] = (physics_template.gravity, True, \"vector\")\n res_dict[\"timestep\"] = (physics_template.timestep, True, \"double\")\n res_dict[\"max_substeps\"] = (physics_template.max_substeps, True, \"int\")\n res_dict[\"friction_coefficient\"] = (\n physics_template.friction_coefficient,\n True,\n \"double\",\n )\n res_dict[\"restitution_coefficient\"] = (\n physics_template.restitution_coefficient,\n True,\n \"double\",\n )\n # Read-only values\n res_dict[\"simulator\"] = (physics_template.simulator, False, \"string\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values that are shared among all primitive asset attributes templates.\n# The values are tuples with the first entry being the value,the second being\n# whether the property is editable and the third being the type.\ndef build_dict_of_prim_attrs(prim_template):\n res_dict = build_dict_of_Default_attrs(prim_template)\n res_dict[\"use_texture_coords\"] = (prim_template.use_texture_coords, True, \"boolean\")\n res_dict[\"use_tangents\"] = (prim_template.use_tangents, True, \"boolean\")\n res_dict[\"num_rings\"] = (prim_template.num_rings, True, \"int\")\n res_dict[\"num_segments\"] = (prim_template.num_segments, True, \"int\")\n res_dict[\"half_length\"] = (prim_template.half_length, True)\n # Read-only values\n res_dict[\"prim_obj_class_name\"] = (\n prim_template.prim_obj_class_name,\n False,\n \"string\",\n )\n res_dict[\"prim_obj_type\"] = (prim_template.prim_obj_type, False, \"int\")\n res_dict[\"is_valid_template\"] = (prim_template.is_valid_template, False, \"boolean\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed capsule primitive template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_Capsule_prim_attrs(capsule_template):\n res_dict = build_dict_of_prim_attrs(capsule_template)\n res_dict[\"hemisphere_rings\"] = (capsule_template.hemisphere_rings, True, \"int\")\n res_dict[\"cylinder_rings\"] = (capsule_template.cylinder_rings, True, \"int\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed cone primitive template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_Cone_prim_attrs(cone_template):\n res_dict = build_dict_of_prim_attrs(cone_template)\n res_dict[\"use_cap_end\"] = (cone_template.use_cap_end, True, \"boolean\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed cube primitive template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_Cube_prim_attrs(cube_template):\n res_dict = build_dict_of_prim_attrs(cube_template)\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed cylinder primitive template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_Cylinder_prim_attrs(cylinder_template):\n res_dict = build_dict_of_prim_attrs(cylinder_template)\n res_dict[\"use_cap_ends\"] = (cylinder_template.use_cap_ends, True, \"boolean\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed icosphere primitive template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_Icosphere_prim_attrs(icosphere_template):\n res_dict = build_dict_of_prim_attrs(icosphere_template)\n res_dict[\"subdivisions\"] = (icosphere_template.subdivisions, True, \"int\")\n return res_dict\n\n\n# This method will build a dict containing k-v pairs of attribute property names\n# and values for the passed UV-Sphere primitive template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_of_UVSphere_prim_attrs(uvsphere_template):\n res_dict = build_dict_of_prim_attrs(uvsphere_template)\n return res_dict\n\n\n# This method will deduce the appropriate template type and build the subsequent\n# dictionary containing containing k-v pairs of template property names\n# and values for the passed template. The values are tuples with\n# the first entry being the value,the second being whether the property is\n# editable and the third being the type.\ndef build_dict_from_template(template):\n template_class = template.template_class\n if \"ObjectAttributes\" in template_class:\n return build_dict_of_Object_attrs(template)\n if \"StageAttributes\" in template_class:\n return build_dict_of_Stage_attrs(template)\n if \"PhysicsManagerAttributes\" in template_class:\n return build_dict_of_PhysicsSim_attrs(template)\n if \"CapsulePrimitiveAttributes\" in template_class:\n return build_dict_of_Capsule_prim_attrs(template)\n if \"ConePrimitiveAttributes\" in template_class:\n return build_dict_of_Cone_prim_attrs(template)\n if \"CubePrimitiveAttributes\" in template_class:\n return build_dict_of_Cube_prim_attrs(template)\n if \"CylinderPrimitiveAttributes\" in template_class:\n return build_dict_of_Cylinder_prim_attrs(template)\n if \"IcospherePrimitiveAttributes\" in template_class:\n return build_dict_of_Icosphere_prim_attrs(template)\n if \"UVSpherePrimitiveAttributes\" in template_class:\n return build_dict_of_UVSphere_prim_attrs(template)\n print(\"Unknown template type : %s \" % template_class)\n return None\n\n\n# This will set a template's attributes from the passed dictionary\ndef set_template_properties_from_dict(template, template_dict):\n for k, v in template_dict.items():\n setattr(template, k, v[0])\n return template\n\n\n# This will display all the properties of an attributes template\ndef show_template_properties(template):\n template_dict = build_dict_from_template(template)\n print(\"Template {} has : \".format(template.handle))\n for k, v in template_dict.items():\n print(\n \"\\tProperty {} has value {} of type {} that is editable : {}\".format(\n k, v[0], v[2], v[1]\n )\n )",
"_____no_output_____"
],
[
"# @title Define Configuration Utility Functions { display-mode: \"form\" }\n# @markdown (double click to show code)\n\n# @markdown This cell defines a number of utility functions used throughout the tutorial to make simulator reconstruction easy:\n# @markdown - make_cfg\n# @markdown - make_default_settings\n# @markdown - make_simulator_from_settings\n\n\ndef make_cfg(settings):\n sim_cfg = habitat_sim.SimulatorConfiguration()\n sim_cfg.gpu_device_id = 0\n sim_cfg.scene_id = settings[\"scene\"]\n sim_cfg.enable_physics = settings[\"enable_physics\"]\n\n # Note: all sensors must have the same resolution\n sensors = {\n \"color_sensor_1st_person\": {\n \"sensor_type\": habitat_sim.SensorType.COLOR,\n \"resolution\": [settings[\"height\"], settings[\"width\"]],\n \"position\": [0.0, settings[\"sensor_height\"], 0.0],\n \"orientation\": [settings[\"sensor_pitch\"], 0.0, 0.0],\n },\n \"depth_sensor_1st_person\": {\n \"sensor_type\": habitat_sim.SensorType.DEPTH,\n \"resolution\": [settings[\"height\"], settings[\"width\"]],\n \"position\": [0.0, settings[\"sensor_height\"], 0.0],\n \"orientation\": [settings[\"sensor_pitch\"], 0.0, 0.0],\n },\n \"semantic_sensor_1st_person\": {\n \"sensor_type\": habitat_sim.SensorType.SEMANTIC,\n \"resolution\": [settings[\"height\"], settings[\"width\"]],\n \"position\": [0.0, settings[\"sensor_height\"], 0.0],\n \"orientation\": [settings[\"sensor_pitch\"], 0.0, 0.0],\n },\n # configure the 3rd person cam specifically:\n \"color_sensor_3rd_person\": {\n \"sensor_type\": habitat_sim.SensorType.COLOR,\n \"resolution\": [settings[\"height\"], settings[\"width\"]],\n \"position\": [0.0, settings[\"sensor_height\"] + 0.2, 0.2],\n \"orientation\": np.array([-math.pi / 4, 0, 0]),\n },\n }\n\n sensor_specs = []\n for sensor_uuid, sensor_params in sensors.items():\n if settings[sensor_uuid]:\n sensor_spec = habitat_sim.SensorSpec()\n sensor_spec.uuid = sensor_uuid\n sensor_spec.sensor_type = sensor_params[\"sensor_type\"]\n sensor_spec.resolution = sensor_params[\"resolution\"]\n sensor_spec.position = sensor_params[\"position\"]\n sensor_spec.orientation = sensor_params[\"orientation\"]\n\n sensor_specs.append(sensor_spec)\n\n # Here you can specify the amount of displacement in a forward action and the turn angle\n agent_cfg = habitat_sim.agent.AgentConfiguration()\n agent_cfg.sensor_specifications = sensor_specs\n\n return habitat_sim.Configuration(sim_cfg, [agent_cfg])\n\n\ndef make_default_settings():\n settings = {\n \"width\": 720, # Spatial resolution of the observations\n \"height\": 544,\n \"scene\": \"./data/scene_datasets/mp3d/17DRP5sb8fy/17DRP5sb8fy.glb\", # Scene path\n \"default_agent\": 0,\n \"sensor_height\": 1.5, # Height of sensors in meters\n \"sensor_pitch\": -math.pi / 8.0, # sensor pitch (x rotation in rads)\n \"color_sensor_1st_person\": True, # RGB sensor\n \"color_sensor_3rd_person\": False, # RGB sensor 3rd person\n \"depth_sensor_1st_person\": False, # Depth sensor\n \"semantic_sensor_1st_person\": False, # Semantic sensor\n \"seed\": 1,\n \"enable_physics\": True, # enable dynamics simulation\n }\n return settings\n\n\ndef make_simulator_from_settings(sim_settings):\n cfg = make_cfg(sim_settings)\n # clean-up the current simulator instance if it exists\n global sim\n global obj_attr_mgr\n global prim_attr_mgr\n global stage_attr_mgr\n if sim != None:\n sim.close()\n # initialize the simulator\n sim = habitat_sim.Simulator(cfg)\n # Managers of various Attributes templates\n obj_attr_mgr = sim.get_object_template_manager()\n obj_attr_mgr.load_configs(str(os.path.join(data_path, \"objects\")))\n prim_attr_mgr = sim.get_asset_template_manager()\n stage_attr_mgr = sim.get_stage_template_manager()\n # UI-populated handles used in various cells. Need to initialize to valid\n # value in case IPyWidgets are not available.\n # Holds the user's desired file-based object template handle\n global sel_file_obj_handle\n sel_file_obj_handle = obj_attr_mgr.get_file_template_handles()[0]\n # Holds the user's desired primitive-based object template handle\n global sel_prim_obj_handle\n sel_prim_obj_handle = obj_attr_mgr.get_synth_template_handles()[0]\n # Holds the user's desired primitive asset template handle\n global sel_asset_handle\n sel_asset_handle = prim_attr_mgr.get_template_handles()[0]",
"_____no_output_____"
],
[
"# @title Define Simulation Utility Functions { display-mode: \"form\" }\n# @markdown (double click to show code)\n\n# @markdown - remove_all_objects\n# @markdown - simulate\n# @markdown - init_camera_track_config\n# @markdown - restore_camera_track_config\n# @markdown - camera_track_simulate\n\n\ndef remove_all_objects(sim):\n for obj_id in sim.get_existing_object_ids():\n sim.remove_object(obj_id)\n\n\ndef simulate(sim, dt=1.0, get_frames=True):\n # simulate dt seconds at 60Hz to the nearest fixed timestep\n print(\"Simulating \" + str(dt) + \" world seconds.\")\n observations = []\n start_time = sim.get_world_time()\n while sim.get_world_time() < start_time + dt:\n sim.step_physics(1.0 / 60.0)\n if get_frames:\n observations.append(sim.get_sensor_observations())\n return observations\n\n\n# Save sensor and agent state to a dictionary, so that initial values can be reset\n# Used at beginning of cell that directly modifies camera (i.e. tracking an object)\ndef init_camera_track_config(sim, sensor_name=\"color_sensor_1st_person\", agent_ID=0):\n init_state = {}\n visual_sensor = sim._sensors[sensor_name]\n # save ref to sensor being used\n init_state[\"visual_sensor\"] = visual_sensor\n init_state[\"position\"] = np.array(visual_sensor._spec.position)\n init_state[\"orientation\"] = np.array(visual_sensor._spec.orientation)\n # set the color sensor transform to be the agent transform\n visual_sensor._spec.position = np.array([0, 0, 0])\n visual_sensor._spec.orientation = np.array([0, 0, 0])\n visual_sensor._sensor_object.set_transformation_from_spec()\n # save ID of agent being modified\n init_state[\"agent_ID\"] = agent_ID\n # save agent initial state\n init_state[\"agent_state\"] = sim.get_agent(agent_ID).get_state()\n # boost the agent off the floor\n sim.get_agent(agent_ID).scene_node.translation += np.array([0, 1.5, 0])\n return init_state\n\n\n# Reset sensor and agent state using dictionary built in init_camera_track_config\n# Used at end of cell that directly modifies camera (i.e. tracking an object)\ndef restore_camera_track_config(sim, init_state):\n visual_sensor = init_state[\"visual_sensor\"]\n agent_ID = init_state[\"agent_ID\"]\n # reset the sensor state for other examples\n visual_sensor._spec.position = init_state[\"position\"]\n visual_sensor._spec.orientation = init_state[\"orientation\"]\n visual_sensor._sensor_object.set_transformation_from_spec()\n # restore the agent's state to what was savedd in init_camera_track_config\n sim.get_agent(agent_ID).set_state(init_state[\"agent_state\"])\n\n\n# Simulate scene while having camera track COM of objects of interest\ndef camera_track_simulate(sim, obj_ids, dt=2.0, get_frames=True, agent_ID=0):\n start_time = sim.get_world_time()\n observations = []\n num_objs = len(obj_ids)\n if num_objs == 0:\n print(\"camera_track_simulate : Aborting, no objects sent to track\")\n return observations\n agent = sim.get_agent(agent_ID)\n # define up vector for tracking calc\n up_vec = np.array([0, 1.0, 0])\n # partition to speed up\n time_step = 1.0 / 60.0\n # process for multiple objects\n while sim.get_world_time() - start_time < dt:\n sim.step_physics(time_step)\n # set agent state to look at object\n camera_position = agent.scene_node.translation\n camera_look_at = sim.get_translation(obj_ids[0])\n for i in range(1, num_objs):\n camera_look_at += sim.get_translation(obj_ids[i])\n camera_look_at /= len(obj_ids)\n agent.scene_node.rotation = mn.Quaternion.from_matrix(\n mn.Matrix4.look_at(camera_position, camera_look_at, up_vec).rotation() # up\n )\n if get_frames:\n observations.append(sim.get_sensor_observations())\n\n return observations\n\n\n# Set an object transform relative to the agent state\ndef set_object_state_from_agent(\n sim,\n ob_id,\n offset=np.array([0, 2.0, -1.5]),\n orientation=mn.Quaternion(((0, 0, 0), 1)),\n):\n agent_transform = sim.agents[0].scene_node.transformation_matrix()\n ob_translation = agent_transform.transform_point(offset)\n sim.set_translation(ob_translation, ob_id)\n sim.set_rotation(orientation, ob_id)",
"_____no_output_____"
],
[
"# @title Define Visualization Utility Function { display-mode: \"form\" }\n# @markdown (double click to show code)\n# @markdown - display_sample\n\n# Change to do something like this maybe: https://stackoverflow.com/a/41432704\ndef display_sample(\n rgb_obs, semantic_obs=np.array([]), depth_obs=np.array([]), key_points=None\n):\n from habitat_sim.utils.common import d3_40_colors_rgb\n\n rgb_img = Image.fromarray(rgb_obs, mode=\"RGBA\")\n\n arr = [rgb_img]\n titles = [\"rgb\"]\n if semantic_obs.size != 0:\n semantic_img = Image.new(\"P\", (semantic_obs.shape[1], semantic_obs.shape[0]))\n semantic_img.putpalette(d3_40_colors_rgb.flatten())\n semantic_img.putdata((semantic_obs.flatten() % 40).astype(np.uint8))\n semantic_img = semantic_img.convert(\"RGBA\")\n arr.append(semantic_img)\n titles.append(\"semantic\")\n\n if depth_obs.size != 0:\n depth_img = Image.fromarray((depth_obs / 10 * 255).astype(np.uint8), mode=\"L\")\n arr.append(depth_img)\n titles.append(\"depth\")\n\n plt.figure(figsize=(12, 8))\n for i, data in enumerate(arr):\n ax = plt.subplot(1, 3, i + 1)\n ax.axis(\"off\")\n ax.set_title(titles[i])\n # plot points on images\n if key_points is not None:\n for point in key_points:\n plt.plot(point[0], point[1], marker=\"o\", markersize=10, alpha=0.8)\n plt.imshow(data)\n\n plt.show(block=False)\n\n\nif __name__ == \"__main__\":\n import argparse\n\n parser = argparse.ArgumentParser()\n parser.add_argument(\"--no-display\", dest=\"display\", action=\"store_false\")\n parser.add_argument(\"--no-make-video\", dest=\"make_video\", action=\"store_false\")\n parser.set_defaults(show_video=True, make_video=True)\n args, _ = parser.parse_known_args()\n show_video = args.display\n display = args.display\n make_video = args.make_video\nelse:\n show_video = False\n make_video = False\n display = False",
"_____no_output_____"
],
[
"# @title Define Colab GUI Utility Functions { display-mode: \"form\" }\n# @markdown (double click to show code)\n\n# @markdown This cell provides utility functions to build and manage IPyWidget interactive components.\n\n# Event handler for dropdowns displaying file-based object handles\ndef on_file_obj_ddl_change(ddl_values):\n global sel_file_obj_handle\n sel_file_obj_handle = ddl_values[\"new\"]\n return sel_file_obj_handle\n\n\n# Event handler for dropdowns displaying prim-based object handles\ndef on_prim_obj_ddl_change(ddl_values):\n global sel_prim_obj_handle\n sel_prim_obj_handle = ddl_values[\"new\"]\n return sel_prim_obj_handle\n\n\n# Event handler for dropdowns displaying asset handles\ndef on_prim_ddl_change(ddl_values):\n global sel_asset_handle\n sel_asset_handle = ddl_values[\"new\"]\n return sel_asset_handle\n\n\n# Build a dropdown list holding obj_handles and set its event handler\ndef set_handle_ddl_widget(obj_handles, handle_types, sel_handle, on_change):\n sel_handle = obj_handles[0]\n descStr = handle_types + \" Template Handles:\"\n style = {\"description_width\": \"300px\"}\n obj_ddl = widgets.Dropdown(\n options=obj_handles,\n value=sel_handle,\n description=descStr,\n style=style,\n disabled=False,\n layout={\"width\": \"max-content\"},\n )\n\n obj_ddl.observe(on_change, names=\"value\")\n return obj_ddl, sel_handle\n\n\ndef set_button_launcher(desc):\n button = widgets.Button(\n description=desc,\n layout={\"width\": \"max-content\"},\n )\n return button\n\n\ndef make_sim_and_vid_button(prefix, dt=1.0):\n if not HAS_WIDGETS:\n return\n\n def on_sim_click(b):\n observations = simulate(sim, dt=dt)\n vut.make_video(\n observations,\n \"color_sensor_1st_person\",\n \"color\",\n output_path + prefix,\n open_vid=show_video,\n )\n\n sim_and_vid_btn = set_button_launcher(\"Simulate and Make Video\")\n sim_and_vid_btn.on_click(on_sim_click)\n ipydisplay(sim_and_vid_btn)\n\n\ndef make_clear_all_objects_button():\n if not HAS_WIDGETS:\n return\n\n def on_clear_click(b):\n remove_all_objects(sim)\n\n clear_objs_button = set_button_launcher(\"Clear all objects\")\n clear_objs_button.on_click(on_clear_click)\n ipydisplay(clear_objs_button)\n\n\n# Builds widget-based UI components\ndef build_widget_ui(obj_attr_mgr, prim_attr_mgr):\n # Holds the user's desired file-based object template handle\n global sel_file_obj_handle\n sel_file_obj_handle = \"\"\n\n # Holds the user's desired primitive-based object template handle\n global sel_prim_obj_handle\n sel_prim_obj_handle = \"\"\n\n # Holds the user's desired primitive asset template handle\n global sel_asset_handle\n sel_asset_handle = \"\"\n\n # Construct DDLs and assign event handlers\n # All file-based object template handles\n file_obj_handles = obj_attr_mgr.get_file_template_handles()\n # All primitive asset-based object template handles\n prim_obj_handles = obj_attr_mgr.get_synth_template_handles()\n # All primitive asset handles template handles\n prim_asset_handles = prim_attr_mgr.get_template_handles()\n # If not using widgets, set as first available handle\n if not HAS_WIDGETS:\n sel_file_obj_handle = file_obj_handles[0]\n sel_prim_obj_handle = prim_obj_handles[0]\n sel_prim_obj_handle = prim_asset_handles[0]\n return\n\n # Build widgets\n file_obj_ddl, sel_file_obj_handle = set_handle_ddl_widget(\n file_obj_handles,\n \"File-based Object\",\n sel_file_obj_handle,\n on_file_obj_ddl_change,\n )\n prim_obj_ddl, sel_prim_obj_handle = set_handle_ddl_widget(\n prim_obj_handles,\n \"Primitive-based Object\",\n sel_prim_obj_handle,\n on_prim_obj_ddl_change,\n )\n prim_asset_ddl, sel_asset_handle = set_handle_ddl_widget(\n prim_asset_handles, \"Primitive Asset\", sel_asset_handle, on_prim_ddl_change\n )\n # Display DDLs\n ipydisplay(file_obj_ddl)\n ipydisplay(prim_obj_ddl)\n ipydisplay(prim_asset_ddl)",
"_____no_output_____"
]
],
[
[
"# Advanced Features\nThis section contains advanced examples/demos of Habitat-sim interactivity.",
"_____no_output_____"
]
],
[
[
"# @title Initialize Simulator and Load Scene { display-mode: \"form\" }\nsim_settings = make_default_settings()\nsim_settings[\"scene\"] = \"./data/scene_datasets/mp3d/17DRP5sb8fy/17DRP5sb8fy.glb\"\nsim_settings[\"sensor_pitch\"] = 0\n\nmake_simulator_from_settings(sim_settings)",
"_____no_output_____"
],
[
"# @title Select target object from the GUI: { display-mode: \"form\" }\n\nbuild_widget_ui(obj_attr_mgr, prim_attr_mgr)",
"_____no_output_____"
]
],
[
[
"## Advanced Topic : Motion Tracking Camera\n\nWhile agents in Habitat sim usually act to modify the environment around them, playing the role of active and often primary participants in simulation, there are cases where we may want agents to play the role of the passive observer. In this case we may want an agent to simply \"hold the camera\" and record the results of simulation.",
"_____no_output_____"
]
],
[
[
"# @markdown This example demonstrates updating the agent state to follow the motion of an object during simulation.\n\nremove_all_objects(sim)\nvisual_sensor = sim._sensors[\"color_sensor_1st_person\"]\ninitial_sensor_position = np.array(visual_sensor._spec.position)\ninitial_sensor_orientation = np.array(visual_sensor._spec.orientation)\n# set the color sensor transform to be the agent transform\nvisual_sensor._spec.position = np.array([0, 0, 0])\nvisual_sensor._spec.orientation = np.array([0, 0, 0])\nvisual_sensor._sensor_object.set_transformation_from_spec()\n\n# boost the agent off the floor\nsim.get_agent(0).scene_node.translation += np.array([0, 1.5, 0])\nobservations = []\n\n# @markdown ---\n# @markdown ### Set example parameters:\nseed = 23 # @param {type:\"integer\"}\nrandom.seed(seed)\nsim.seed(seed)\nnp.random.seed(seed)\n\n# add an object and position the agent\nobj_id_1 = sim.add_object_by_handle(sel_file_obj_handle)\nrand_position = np.random.uniform(\n np.array([-0.4, -0.3, -1.0]), np.array([0.4, 0.3, -0.5])\n)\nset_object_state_from_agent(sim, obj_id_1, rand_position, ut.random_quaternion())\n\n# simulate with updated camera at each frame\nstart_time = sim.get_world_time()\nwhile sim.get_world_time() - start_time < 2.0:\n sim.step_physics(1.0 / 60.0)\n # set agent state to look at object\n camera_position = sim.get_agent(0).scene_node.translation\n camera_look_at = sim.get_translation(obj_id_1)\n sim.get_agent(0).scene_node.rotation = mn.Quaternion.from_matrix(\n mn.Matrix4.look_at(\n camera_position, camera_look_at, np.array([0, 1.0, 0]) # up\n ).rotation()\n )\n observations.append(sim.get_sensor_observations())\n\n# video rendering with embedded 1st person view\nvideo_prefix = \"motion tracking\"\nif make_video:\n vut.make_video(\n observations,\n \"color_sensor_1st_person\",\n \"color\",\n output_path + video_prefix,\n open_vid=show_video,\n )\n\n# reset the sensor state for other examples\nvisual_sensor._spec.position = initial_sensor_position\nvisual_sensor._spec.orientation = initial_sensor_orientation\nvisual_sensor._sensor_object.set_transformation_from_spec()\n# put the agent back\nsim.reset()\nremove_all_objects(sim)",
"_____no_output_____"
]
],
[
[
"## Advanced Topic : 3D to 2D Key-point Projection\n\nThe Habitat-sim visual-sensor API makes it easy to project 3D points into 2D for use cases such as generating ground-truth for image space key-points.",
"_____no_output_____"
]
],
[
[
"# @markdown ###Display 2D Projection of Object COMs\n# fmt: off\n# @markdown First define the projection function using the current state of a chosen VisualSensor to set camera parameters and then projects the 3D point.\n# fmt: on\n# project a 3D point into 2D image space for a particular sensor\ndef get_2d_point(sim, sensor_name, point_3d):\n # get the scene render camera and sensor object\n render_camera = sim._sensors[sensor_name]._sensor_object.render_camera\n\n # use the camera and projection matrices to transform the point onto the near plane\n projected_point_3d = render_camera.projection_matrix.transform_point(\n render_camera.camera_matrix.transform_point(point_3d)\n )\n # convert the 3D near plane point to integer pixel space\n point_2d = mn.Vector2(projected_point_3d[0], -projected_point_3d[1])\n point_2d = point_2d / render_camera.projection_size()[0]\n point_2d += mn.Vector2(0.5)\n point_2d *= render_camera.viewport\n return mn.Vector2i(point_2d)\n\n\n# fmt: off\n# @markdown Use this function to compute the projected object center of mass (COM) 2D projection and display on the image.\n# fmt: on\n# @markdown ---\n# @markdown ### Set example parameters:\nseed = 27 # @param {type:\"integer\"}\nrandom.seed(seed)\nsim.seed(seed)\nnp.random.seed(seed)\n\nremove_all_objects(sim)\n\n# add an object and plot the COM on the image\nobj_id_1 = sim.add_object_by_handle(sel_file_obj_handle)\nrand_position = np.random.uniform(\n np.array([-0.4, 1.2, -1.0]), np.array([0.4, 1.8, -0.5])\n)\nset_object_state_from_agent(sim, obj_id_1, rand_position, ut.random_quaternion())\n\nobs = sim.get_sensor_observations()\n\ncom_2d = get_2d_point(\n sim, sensor_name=\"color_sensor_1st_person\", point_3d=sim.get_translation(obj_id_1)\n)\nif display:\n display_sample(obs[\"color_sensor_1st_person\"], key_points=[com_2d])\nremove_all_objects(sim)",
"_____no_output_____"
]
],
[
[
"## Advanced Topic: Configurable Semantic IDs\n\nSemantic information can be loaded into the Simulator for scenes directly. This can be provided to models and visualized with the SEMANTIC sensor.\n\nWhat if you want to add new objects to the scene with semantic ids or modify the semantic ids at runtime?\n\nHabitat-sim provides three methods for modifying semantic ids which are not provided via vertex colors:\n\n1. Configure the semantic id before object instancing via the object template (programmatically or in the json)\n2. Set the semantic_id of all SceneNodes used to render an object with **Simulator.set_object_semantic_id**.\n3. Set the **SceneNode.semantic_id** property directly.\n\n\n\n",
"_____no_output_____"
]
],
[
[
"# @markdown ###Configuring Object Semantic IDs:\n\nsim_settings = make_default_settings()\nsim_settings[\"scene\"] = \"./data/scene_datasets/mp3d/17DRP5sb8fy/17DRP5sb8fy.glb\"\nsim_settings[\"sensor_pitch\"] = 0\nsim_settings[\"semantic_sensor_1st_person\"] = True\n\nmake_simulator_from_settings(sim_settings)\n\n# fmt: off\n# @markdown In this example, we load a box asset with each face as a separate component with its own SceneNode. We demonstrate the result of modiyfing the associated semantic ids via object templates, the Simulator API, and the SceneNode property.\n# fmt: on\n\nremove_all_objects(sim)\nobservations = []\n\n# @markdown Set the initial object orientation via local Euler angle (degrees):\norientation_x = 45 # @param {type:\"slider\", min:-180, max:180, step:1}\norientation_y = 45 # @param {type:\"slider\", min:-180, max:180, step:1}\norientation_z = 45 # @param {type:\"slider\", min:-180, max:180, step:1}\n\n\n# compose the rotations\nrotation_x = mn.Quaternion.rotation(mn.Deg(orientation_x), mn.Vector3(1.0, 0, 0))\nrotation_y = mn.Quaternion.rotation(mn.Deg(orientation_y), mn.Vector3(0, 1.0, 0))\nrotation_z = mn.Quaternion.rotation(mn.Deg(orientation_z), mn.Vector3(0, 0, 1.0))\nobject_orientation = rotation_z * rotation_y * rotation_x\nprint(object_orientation)\n\n# fmt: off\n# @markdown We can configure the semantic id in the object template. This id will be applied to the object (instead of the default 0) upon instantiation:\n# fmt: on\n\n# add a box with default semanticId configured in the template\n# Note: each face of this box asset is a separate component\nbox_template = habitat_sim.attributes.ObjectAttributes()\nbox_template.render_asset_handle = str(\n os.path.join(data_path, \"test_assets/objects/transform_box.glb\")\n)\nbox_template.scale = np.array([0.2, 0.2, 0.2])\n# set the default semantic id for this object template\nbox_template.semantic_id = 10 # @param{type:\"integer\"}\nbox_template_id = obj_attr_mgr.register_template(box_template, \"box\")\n\nbox_id = sim.add_object(box_template_id)\nset_object_state_from_agent(\n sim, box_id, mn.Vector3(0.0, 1.5, -0.75), orientation=object_orientation\n)\nobservations.append(sim.get_sensor_observations())\n# fmt: off\n# @markdown We can set the semantic id for all components of the object via the Simulator API at any time:\n# fmt: on\n# override the configured id with a new id\nbox_semantic_id_override = 20 # @param{type:\"integer\"}\nsim.set_object_semantic_id(box_semantic_id_override, box_id)\nobservations.append(sim.get_sensor_observations())\n\n# @markdown We can also set the semantic id for any single SceneNode directly:\n# set semantic id for specific SceneNode components of the box object\nbox_visual_nodes = sim.get_object_visual_scene_nodes(box_id)\nbox_visual_nodes[6].semantic_id = 3 # @param{type:\"integer\"}\nbox_visual_nodes[7].semantic_id = 4 # @param{type:\"integer\"}\nobservations.append(sim.get_sensor_observations())\n\n# display the resulting observations:\nif display:\n for obs in observations:\n display_sample(\n obs[\"color_sensor_1st_person\"],\n semantic_obs=obs[\"semantic_sensor_1st_person\"],\n )\nremove_all_objects(sim)",
"_____no_output_____"
]
],
[
[
"## Advanced Topic : Object and Primitive Asset Customization\n\n\n\n",
"_____no_output_____"
],
[
"* Objects are defined by their attributes.\n* These attributes are collected in editable Attributes Templates that provide a recipe for object construction.\n* These templates are managed by an Attributes Manager, which is accessible from the simulator and is used to create, retrieve and delete templates.\n* The physics world, scenes, objects and primitive-based assets are all described by Attributes Templates tailored to their construction and managed by their own Attributes Managers.\n* This section of the tutorial focuses on Object and Primitive Asset Attributes.\n",
"_____no_output_____"
]
],
[
[
"# @title Initialize Simulator and Load Scene { display-mode: \"form\" }\n# @markdown (load the apartment_1 scene for object and primitive asset customization in an open space)\nsim_settings = make_default_settings()\nsim_settings[\"scene\"] = \"./data/scene_datasets/habitat-test-scenes/apartment_1.glb\"\nsim_settings[\"sensor_pitch\"] = 0\n\nmake_simulator_from_settings(sim_settings)\n\n# Object Attributes Manager\nobj_attr_mgr = sim.get_object_template_manager()",
"_____no_output_____"
],
[
"# @title Select target object from the GUI: { display-mode: \"form\" }\n\nbuild_widget_ui(obj_attr_mgr, prim_attr_mgr)",
"_____no_output_____"
]
],
[
[
"### File-based Object Template modification.\n",
"_____no_output_____"
]
],
[
[
"# @title 1 Simple File-based Object Template modification. { display-mode: \"form\" }\n# @markdown Running this will demonstrate how to create objects of varying size from a file-based template by iteratively modifying the template's scale value. This will also demonstrate how to delete unwanted templates from the library.\n\n# clear all objects and observations\nremove_all_objects(sim)\nobservations = []\n# save initial camera state\ninit_config = init_camera_track_config(sim)\n\n# Use selected handle as object handle\nobj_template_handle = sel_file_obj_handle\n# Get File-based template for object using its handle - retrieves\n# a copy of this object's attributes template.\nobj_template = obj_attr_mgr.get_template_by_handle(obj_template_handle)\n\n# Add object instantiated by desired template using template handle.\nobj_id = sim.add_object_by_handle(obj_template_handle)\n\n# Set desired offset from agent location to place object\noffset = np.array([-1.2, 0.1, -1.5])\n# Move object to be in front of the agent\nset_object_state_from_agent(sim, obj_id, offset=offset)\n\n# Templates have editable fields that will directly affect the instanced\n# objects built from them. Here we iteratively modify and re-register the\n# template, instancing a new object each time.\n# Bigger Bananas!\nobj_ids = [obj_id]\nfor i in range(5):\n # Increase the template scale value (object size)\n obj_template.scale *= 1.5\n # Make a new handle for the modified template, so we don't overwrite\n new_obj_template_handle = obj_template_handle + \"_new_\" + str(i)\n # Register modified template with new handle, returns template ID\n new_tmplt_ID = obj_attr_mgr.register_template(obj_template, new_obj_template_handle)\n # Object creation can occur using template ID or handle\n if i % 2 == 0:\n # Add another object instantiated by modified template using handle\n new_obj = sim.add_object(new_tmplt_ID)\n else:\n # Add another object instantiated by modified template using handle\n new_obj = sim.add_object_by_handle(new_obj_template_handle)\n # Move object to the right of previous object\n offset[0] += 0.4\n obj_ids.append(new_obj)\n set_object_state_from_agent(sim, new_obj, offset=offset)\n\n# Clean-up - remove modified templates from template library\n# Get all modified template handles through keyword search\nmod_template_handles = obj_attr_mgr.get_template_handles(\"_new_\")\n# Show number of modified templates\nprint(\n \"Before delete, there are {} modified templates.\".format(len(mod_template_handles))\n)\n# Display modified template handles\nprint(*mod_template_handles, sep=\"\\n\")\n# Remove modified templates\nfor handle in mod_template_handles:\n obj_attr_mgr.remove_template_by_handle(handle)\n# Verify removal - get template handles through keyword search\nmod_template_handles = obj_attr_mgr.get_template_handles(\"_new_\")\n# Show number of modified templates now\nprint(\n \"After deleting added templates, there are {} modified templates.\".format(\n len(mod_template_handles)\n )\n)\n# Display modified template handles after delete\nprint(*mod_template_handles, sep=\"\\n\")\n\n\nexample_type = \"Adding edited objects\"\n# Run camera-tracking simulation displaying modified objects\nobservations = camera_track_simulate(sim, obj_ids, dt=3.0)\n\nif make_video:\n vut.make_video(\n observations,\n \"color_sensor_1st_person\",\n \"color\",\n output_path + example_type,\n open_vid=show_video,\n )\n\n# restore camera tracking position for future cells\nrestore_camera_track_config(sim, init_config)\nmake_clear_all_objects_button()",
"_____no_output_____"
],
[
"# @title 2 Object Template Modification in Detail. { display-mode: \"form\" }\n# @markdown The following example lists all the fields available in an object template that can be modified, allows for them to be edited and enables creating an object with the newly modified template.\n# @markdown Two objects will be created in this cell, one to the left with the original template and one to the right with the edited configuration.\n\n# clear all objects and observations\nremove_all_objects(sim)\nobservations = []\n# save initial camera state for tracking\ninit_config = init_camera_track_config(sim)\n\n# @markdown ###Editable fields in Object Templates :\n# Get a new template\nnew_template = obj_attr_mgr.get_template_by_handle(sel_file_obj_handle)\n\n# These are all the available attributes and their values for this object\nshow_template_properties(new_template)\n\n# @markdown The desired mass of the object\nmass = 1.0 # @param {type:\"slider\", min:0.1, max:50, step:0.1}\nnew_template.mass = mass\n\n# @markdown The x,y,z components for the scale of the object.\nscale_X = 2 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\nscale_Y = 8 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\nscale_Z = 2 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\nnew_template.scale = mn.Vector3(scale_X, scale_Y, scale_Z)\n\n# @markdown The x,y,z components for the desired location of the center of mass.\ncom_X = 0 # @param {type:\"slider\", min:-1.0, max:1, step:0.1}\ncom_Y = 0 # @param {type:\"slider\", min:-1.0, max:1, step:0.1}\ncom_Z = 0 # @param {type:\"slider\", min:-1.0, max:1, step:0.1}\nnew_template.com = mn.Vector3(com_X, com_Y, com_Z)\n\n# @markdown If true, simulator sets COM as center of bounding box, and ignores any specified COM.\ncompute_COM_from_shape = False # @param {type:\"boolean\"}\nnew_template.compute_COM_from_shape = compute_COM_from_shape\n\n# @markdown Sets the collision margin\nmargin = 0.4 # @param {type:\"slider\", min:0.0, max:10, step:0.1}\nnew_template.margin = margin\n\n# @markdown Friction for object contact\nfriction_coefficient = 0.5 # @param {type:\"slider\", min:0.0, max:1.0, step:0.1}\nnew_template.friction_coefficient = friction_coefficient\n\n# @markdown Fraction of original relative velocity retained by an object after contact. 1 is perfectly elastic contact.\nrestitution_coefficient = 0.3 # @param {type:\"slider\", min:0.0, max:1.0, step:0.1}\nnew_template.restitution_coefficient = restitution_coefficient\n\n# @markdown Whether the object should be lit via Phong shading.\nrequires_lighting = False # @param {type:\"boolean\"}\nnew_template.requires_lighting = requires_lighting\n\n# @markdown The x,y,z components of the intertia matrix diagonal\n\ninertia_X = 1.0 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\ninertia_Y = 1 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\ninertia_Z = 1.0 # @param {type:\"slider\", min:0.1, max:10, step:0.1}\nnew_template.inertia = mn.Vector3(inertia_X, inertia_Y, inertia_Z)\n\n# @markdown Rate of linear momentum dissipation\nlinear_damping = 0.1 # @param {type:\"slider\", min:0.0, max:5.0, step:0.1}\nnew_template.linear_damping = linear_damping\n\n# @markdown Rate of angular momentum dissipation\nangular_damping = 0.2 # @param {type:\"slider\", min:0.0, max:5.0, step:0.1}\n\nnew_template.angular_damping = angular_damping\n\n# @markdown Use bounding box for collision instead of collision mesh.\nbounding_box_collisions = False # @param {type:\"boolean\"}\nnew_template.bounding_box_collisions = bounding_box_collisions\n\n# @markdown Whether compound collision meshes should be merged into a single convex hull.\njoin_collision_meshes = False # @param {type:\"boolean\"}\nnew_template.join_collision_meshes = join_collision_meshes\n\n# Construct a new handle to save this template with\nnew_template_handle = sel_file_obj_handle + \"_new\"\n\n\n# register new template and get its new id\nnew_template_ID = obj_attr_mgr.register_template(new_template, new_template_handle)\n\n\n# Add object instantiated by original template using template handle\noriginal_template = obj_attr_mgr.get_template_by_handle(sel_file_obj_handle)\norig_obj_id = sim.add_object_by_handle(original_template.handle)\n\n# Set desired offset from agent location to place object\noffset = np.array([-0.5, 0.3, -1.5])\n# Move object to be in front of the agent\nset_object_state_from_agent(sim, orig_obj_id, offset=offset)\n\n# Add new object instantiated by desired template using template handle\nobj_id = sim.add_object(new_template_ID)\n\n# Set desired offset from agent location to place object\noffset[0] += 1.0\n# Move object to be in front of the agent\nset_object_state_from_agent(sim, obj_id, offset=offset)\n\nexample_type = \"Adding customized objects\"\n# Run camera-tracking simulation displaying modified objects\nobservations = camera_track_simulate(sim, [orig_obj_id, obj_id], dt=2.5)\n\nif make_video:\n vut.make_video(\n observations,\n \"color_sensor_1st_person\",\n \"color\",\n output_path + example_type,\n open_vid=show_video,\n )\n\n# restore camera tracking position\nrestore_camera_track_config(sim, init_config)\nmake_clear_all_objects_button()",
"_____no_output_____"
]
],
[
[
"### Primitive Asset-based Templates For Object Customization",
"_____no_output_____"
]
],
[
[
"# @title Display available file-based and primitive-based object and asset attributes : { display-mode: \"form\" }\n\nbuild_widget_ui(obj_attr_mgr, prim_attr_mgr)",
"_____no_output_____"
],
[
"# @title ###1 Simple Primitive-based Object instantiation. { display-mode: \"form\" }\n# @markdown Habitat-Sim has 6 built-in primitives available (Capsule, Cone, Cube, Cylinder, Icosphere and UVSphere), which are available as both solid and wireframe meshes. Default objects are synthesized from these primitives automatically and are always available. Primitives are desirable due to being very fast to simulate.\n\n# @markdown This example shows the primitives that are available. One of each type is instanced with default values and simulated.\n\n# clear all objects and observations\nremove_all_objects(sim)\nobservations = []\n# save initial camera state for tracking\ninit_config = init_camera_track_config(sim)\n# Get Primitive-based solid object template handles\nprim_solid_obj_handles = obj_attr_mgr.get_synth_template_handles(\"solid\")\n# Get Primitive-based wireframe object template handles\nprim_wf_obj_handles = obj_attr_mgr.get_synth_template_handles(\"wireframe\")\n\n# Set desired offset from agent location to place object\noffset_solid = np.array([-1.1, 0.6, -1.8])\noffset_wf = np.array([-1.1, 0.6, -1.0])\nobjs_to_sim = []\nfor i in range(6):\n # Create object from template handle\n obj_solid_id = sim.add_object_by_handle(prim_solid_obj_handles[i])\n obj_wf_id = sim.add_object_by_handle(prim_wf_obj_handles[i])\n objs_to_sim.append(obj_solid_id)\n objs_to_sim.append(obj_wf_id)\n\n # Place object in scene relative to agent\n set_object_state_from_agent(sim, obj_solid_id, offset=offset_solid)\n set_object_state_from_agent(sim, obj_wf_id, offset=offset_wf)\n\n # Move offset for next object\n offset_solid[0] += 0.4\n offset_wf[0] += 0.4\n\n\nexample_type = \"Adding primitive-based objects\"\n# Run camera-tracking simulation displaying primitive-based objects\nobservations = camera_track_simulate(sim, objs_to_sim, dt=2.0)\nif make_video:\n vut.make_video(\n observations,\n \"color_sensor_1st_person\",\n \"color\",\n output_path + example_type,\n open_vid=show_video,\n )\n\n# restore camera tracking position\nrestore_camera_track_config(sim, init_config)\nmake_clear_all_objects_button()",
"_____no_output_____"
],
[
"# @title ###2 Primitive Asset Template Modifications in Detail\n# @markdown Many of the geometric properties of the available primitive meshes can be controlled by modifying the Primitive Asset Attributes templates that describe them. Any objects instantiated with these modified template will then exhibit these properties.\n# @markdown Note 1 : Solid and Wireframe Cubes and Wireframe Icospheres do not have any editable geometric properties.\n# @markdown Note 2 : Since many of the modifiable parameters controlling primitives are restricted in what values they can be, each Primitive Asset Template has a read-only boolean property, \"is_valid_template\", which describes whether or not the template is in a valid state. If it is invalid, it will not be able to be used to create primitives.\n# @markdown Note 3 : Primitive Asset Templates name themselves based on their settings, so an edited template does not have to be actively renamed by the user.\n# @markdown Note 4 : There often are different modifiable properties available for solid and wireframe versions of the same primitive.\n\n# @markdown ###Primitive Asset Template Properties\n# @markdown The flollowing examples will illustrate all the modifiable properties for each of the different types of primitives, and allow for their synthesis.\n\n\n# Primitive Asset Attributes Manager, provides access to AssetAttributesTemplates\nprim_attr_mgr = sim.get_asset_template_manager()\n\n# This will register a primitive template if valid, and add it to a passed\n# dictionary of handles; If not valid it will give a message\ndef register_prim_template_if_valid(\n make_modified, template, dict_of_handles, handle_key\n):\n if make_modified:\n if template.is_valid_template:\n prim_attr_mgr.register_template(template)\n dict_of_handles[handle_key] = template.handle\n print(\n \"Primitive Template named {} is registered for {}.\".format(\n template.handle, handle_key\n )\n )\n else:\n print(\n \"Primitive Template configuration is invalid for {}, so unable to register.\".format(\n handle_key\n )\n )\n else:\n dict_of_handles[handle_key] = prim_attr_mgr.get_template_handles(handle_key)[0]\n print(\"Default Primitive Template used at key {}.\".format(handle_key))\n\n\n# Build a dictionary of templates to use to construct objects\n# Configure dictionaries to hold handles of attributes to use to build objects\nsolid_handles_to_use = {}\n# Solid and Wireframe cube primitives lack customizable attributes, as does wireframe icosphere\nsolid_handles_to_use[\"cubeSolid\"] = prim_attr_mgr.get_template_handles(\"cubeSolid\")[0]\nwireframe_handles_to_use = {}\nwireframe_handles_to_use[\"cubeWireframe\"] = prim_attr_mgr.get_template_handles(\n \"cubeWireframe\"\n)[0]\nwireframe_handles_to_use[\"icosphereWireframe\"] = prim_attr_mgr.get_template_handles(\n \"icosphereWireframe\"\n)[0]",
"_____no_output_____"
]
],
[
[
"#### 2.1 Capsule Primitive : Cylinder with hemispherical caps of radius 1.0, oriented along y axis, centered at origin.\n",
"_____no_output_____"
]
],
[
[
"# @title ###2.1.1 Solid Capsule :{ display-mode: \"form\" }\n# Acquire default template\ncapsule_solid_template = prim_attr_mgr.get_default_capsule_template(False)\n\n\ndef edit_solid_capsule(edit_template):\n # @markdown Whether to build with texture coordinate support\n use_texture_coords = False # @param {type:\"boolean\"}\n edit_template.use_texture_coords = use_texture_coords\n # @markdown Whether to build tangents\n use_tangents = False # @param {type:\"boolean\"}\n edit_template.use_tangents = use_tangents\n # @markdown Number of (face) rings for each hemisphere. Must be larger or equal to 1\n hemisphere_rings = 6 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.hemisphere_rings = hemisphere_rings\n # @markdown Number of (face) rings for cylinder. Must be larger or equal to 1.\n cylinder_rings = 1 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.cylinder_rings = cylinder_rings\n # @markdown Number of (face) segments. Must be larger or equal to 3.\n num_segments = 16 # @param {type:\"slider\", min:3, max:30, step:1}\n edit_template.num_segments = num_segments\n # @markdown Half the length of cylinder part.\n half_length = 0.95 # @param {type:\"slider\", min:0.05, max:2.0, step:0.05}\n edit_template.half_length = half_length\n # @markdown Do you want to make a solid capsule using your above modifications?\n make_modified_solid_capsule = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_solid_capsule,\n edit_template,\n solid_handles_to_use,\n \"capsule3DSolid\",\n )\n\n\nedit_solid_capsule(capsule_solid_template)",
"_____no_output_____"
],
[
"# @title ####2.1.2 Wireframe Capsule :{ display-mode: \"form\" }\n# Acquire default template\ncapsule_wireframe_template = prim_attr_mgr.get_default_capsule_template(True)\n\n\ndef edit_wf_capsule(edit_template):\n # @markdown Number of (line) rings for each hemisphere. Must be larger or equal to 1\n hemisphere_rings = 7 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.hemisphere_rings = hemisphere_rings\n\n # @markdown Number of (line) rings for cylinder. Must be larger or equal to 1.\n cylinder_rings = 10 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.cylinder_rings = cylinder_rings\n\n # @markdown Number of line segments. Must be larger or equal to 4 and multiple of 4\n num_segments = 16 # @param {type:\"slider\", min:4, max:40, step:4}\n edit_template.num_segments = num_segments\n\n # @markdown Half the length of cylinder part.\n half_length = 0.85 # @param {type:\"slider\", min:0.05, max:2.0, step:0.05}\n edit_template.half_length = half_length\n\n # @markdown Do you want to make a wireframe capsule using your above modifications?\n make_modified_wireframe_capsule = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_wireframe_capsule,\n edit_template,\n wireframe_handles_to_use,\n \"capsule3DWireframe\",\n )\n\n\nedit_wf_capsule(capsule_wireframe_template)",
"_____no_output_____"
]
],
[
[
"####2.2 Cone Primitive : Cone of radius 1.0f along the Y axis, centered at origin.\n",
"_____no_output_____"
]
],
[
[
"# @title ####2.2.1 Solid Cone :{ display-mode: \"form\" }\n# Acquire default template\ncone_solid_template = prim_attr_mgr.get_default_cone_template(False)\n\n\ndef edit_solid_cone(edit_template):\n # @markdown Whether to build with texture coordinate support\n use_texture_coords = False # @param {type:\"boolean\"}\n edit_template.use_texture_coords = use_texture_coords\n # @markdown Whether to build tangents\n use_tangents = False # @param {type:\"boolean\"}\n edit_template.use_tangents = use_tangents\n # @markdown Number of (face) rings. Must be larger or equal to 1.\n num_rings = 6 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.num_rings = num_rings\n # @markdown Number of (face) segments. Must be larger or equal to 3.\n num_segments = 20 # @param {type:\"slider\", min:3, max:40, step:1}\n edit_template.num_segments = num_segments\n # @markdown Half the cone length\n half_length = 1.25 # @param {type:\"slider\", min:0.05, max:2.0, step:0.05}\n edit_template.half_length = half_length\n # @markdown Whether to cap the base of the cone\n use_cap_end = True # @param {type:\"boolean\"}\n edit_template.use_cap_end = use_cap_end\n # @markdown Do you want to make a solid cone using your above modifications?\n make_modified_solid_cone = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_solid_cone, edit_template, solid_handles_to_use, \"coneSolid\"\n )\n\n\nedit_solid_cone(cone_solid_template)",
"_____no_output_____"
],
[
"# @title ####2.2.2 Wireframe Cone :{ display-mode: \"form\" }\n# Acquire default template\ncone_wireframe_template = prim_attr_mgr.get_default_cone_template(True)\n\n\ndef edit_wireframe_cone(edit_template):\n # @markdown Number of (line) segments. Must be larger or equal to 4 and multiple of 4.\n num_segments = 32 # @param {type:\"slider\", min:4, max:40, step:4}\n edit_template.num_segments = num_segments\n # @markdown Half the cone length\n half_length = 1.25 # @param {type:\"slider\", min:0.05, max:2.0, step:0.05}\n edit_template.half_length = half_length\n # @markdown Do you want to make a wireframe cone using your above modifications?\n make_modified_wireframe_cone = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_wireframe_cone,\n edit_template,\n wireframe_handles_to_use,\n \"coneWireframe\",\n )\n\n\nedit_wireframe_cone(cone_wireframe_template)",
"_____no_output_____"
]
],
[
[
"####2.3 Cylinder Primitive : Cylinder of radius 1.0f along the Y axis, centered at origin.",
"_____no_output_____"
]
],
[
[
"# @title ####2.3.1 Solid Cylinder : { display-mode: \"form\" }\n# Acquire default template\ncylinder_solid_template = prim_attr_mgr.get_default_cylinder_template(False)\n\n\ndef edit_solid_cylinder(edit_template):\n # @markdown Whether to build with texture coordinate support\n use_texture_coords = False # @param {type:\"boolean\"}\n edit_template.use_texture_coords = use_texture_coords\n # @markdown Whether to build tangents\n use_tangents = False # @param {type:\"boolean\"}\n edit_template.use_tangents = use_tangents\n # @markdown Number of (face) rings. Must be larger or equal to 1.\n num_rings = 4 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.num_rings = num_rings\n # @markdown Number of (face) segments. Must be larger or equal to 3.\n num_segments = 14 # @param {type:\"slider\", min:3, max:30, step:1}\n edit_template.num_segments = num_segments\n # @markdown Half the cylinder length\n half_length = 1 # @param {type:\"slider\", min:0.05, max:2.0, step:0.05}\n edit_template.half_length = half_length\n # @markdown Whether to cap each end of the cylinder\n use_cap_ends = True # @param {type:\"boolean\"}\n edit_template.use_cap_ends = use_cap_ends\n # @markdown Do you want to make a solid cylinder using your above modifications?\n make_modified_solid_cylinder = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_solid_cylinder,\n edit_template,\n solid_handles_to_use,\n \"cylinderSolid\",\n )\n\n\nedit_solid_cylinder(cylinder_solid_template)",
"_____no_output_____"
],
[
"# @title ####2.3.2 Wireframe Cylinder : { display-mode: \"form\" }\n# Acquire default template\ncylinder_wireframe_template = prim_attr_mgr.get_default_cylinder_template(True)\n\n\ndef edit_wireframe_cylinder(edit_template):\n # @markdown Number of (face) rings. Must be larger or equal to 1.\n num_rings = 1 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.num_rings = num_rings\n # @markdown Number of (line) segments. Must be larger or equal to 4 and multiple of 4.\n num_segments = 28 # @param {type:\"slider\", min:4, max:64, step:4}\n edit_template.num_segments = num_segments\n # @markdown Half the cylinder length\n half_length = 0.7 # @param {type:\"slider\", min:0.05, max:2.0, step:0.05}\n edit_template.half_length = half_length\n # @markdown Do you want to make a wireframe cylinder using your above modifications?\n make_modified_wireframe_cylinder = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_wireframe_cylinder,\n edit_template,\n wireframe_handles_to_use,\n \"cylinderWireframe\",\n )\n\n\nedit_wireframe_cylinder(cylinder_wireframe_template)",
"_____no_output_____"
]
],
[
[
"####2.4 Icosphere Primitive : Icosahedron-based sphere of radius 1.0f, centered at the origin.\n\nOnly solid icospheres have any editable geometric parameters.",
"_____no_output_____"
]
],
[
[
"# @title ####2.4.1 Solid Icosphere : { display-mode: \"form\" }\n# Acquire default template\nicosphere_solid_template = prim_attr_mgr.get_default_icosphere_template(False)\n\n\ndef edit_solid_icosphere(edit_template):\n # @markdown Describes the depth of recursive subdivision for each icosphere triangle.\n subdivisions = 3 # @param {type:\"slider\", min:1, max:10, step:1}\n edit_template.subdivisions = subdivisions\n # @markdown Do you want to make a solid icosphere using your above modifications?\n make_modified_solid_icosphere = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_solid_icosphere,\n edit_template,\n solid_handles_to_use,\n \"icosphereSolid\",\n )\n\n\nedit_solid_icosphere(icosphere_solid_template)",
"_____no_output_____"
]
],
[
[
"####2.5 UVSphere Primitive : Sphere of radius 1.0f, centered at the origin.",
"_____no_output_____"
]
],
[
[
"# @title ####2.5.1 Solid UVSphere : { display-mode: \"form\" }\n# Acquire default template\nUVSphere_solid_template = prim_attr_mgr.get_default_UVsphere_template(False)\n\n\ndef edit_solid_UVSphere(edit_template):\n # @markdown Whether to build with texture coordinate support\n use_texture_coords = False # @param {type:\"boolean\"}\n edit_template.use_texture_coords = use_texture_coords\n # @markdown Whether to build tangents\n use_tangents = False # @param {type:\"boolean\"}\n edit_template.use_tangents = use_tangents\n # @markdown Number of (face) rings. Must be larger or equal to 2.\n num_rings = 13 # @param {type:\"slider\", min:2, max:30, step:1}\n edit_template.num_rings = num_rings\n # @markdown Number of (face) segments. Must be larger or equal to 3.\n num_segments = 8 # @param {type:\"slider\", min:3, max:30, step:1}\n edit_template.num_segments = num_segments\n\n # @markdown Do you want to make a solid UVSphere using your above modifications?\n make_modified_solid_UVSphere = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_solid_UVSphere,\n edit_template,\n solid_handles_to_use,\n \"uvSphereSolid\",\n )\n\n\nedit_solid_UVSphere(UVSphere_solid_template)",
"_____no_output_____"
],
[
"# @title ####2.5.2 Wireframe UVSphere : { display-mode: \"form\" }\n# Acquire default template\nUVSphere_wireframe_template = prim_attr_mgr.get_default_UVsphere_template(True)\n\n\ndef edit_wireframe_UVSphere(edit_template):\n # @markdown Number of (line) rings. Must be larger or equal to 2 and multiple of 2.\n num_rings = 16 # @param {type:\"slider\", min:2, max:64, step:2}\n edit_template.num_rings = num_rings\n # @markdown Number of (line) segments. Must be larger or equal to 4 and multiple of 4.\n num_segments = 40 # @param {type:\"slider\", min:4, max:64, step:4}\n edit_template.num_segments = num_segments\n # @markdown Do you want to make a UVSphere cylinder using your above modifications?\n make_modified_wireframe_UVSphere = True # @param {type:\"boolean\"}\n # if make is set to true, save modified template.\n register_prim_template_if_valid(\n make_modified_wireframe_UVSphere,\n edit_template,\n wireframe_handles_to_use,\n \"uvSphereWireframe\",\n )\n\n\nedit_wireframe_UVSphere(UVSphere_wireframe_template)",
"_____no_output_____"
]
],
[
[
"####2.6 Instancing Objects with Modified Primitive-Asset Attributes.",
"_____no_output_____"
]
],
[
[
"# @title ####Using the modifications set in the previous cells, instantiate examples of all available solid and wireframe primitives.{ display-mode: \"form\" }\n# clear all objects and observations\nremove_all_objects(sim)\nobservations = []\n# save initial camera state for tracking\ninit_config = init_camera_track_config(sim)\n# Previous cells configured solid_handles_to_use and wireframe_handles_to_use\n\n# Set desired offset from agent location to place object\noffset_solid = np.array([-1.1, 0.6, -1.8])\nobjs_to_sim = []\n# Create primitive-attributes based object templates for solid and wireframe objects\nfor solidHandle in solid_handles_to_use.values():\n # Create object template with passed handle\n obj_template = obj_attr_mgr.create_template(solidHandle)\n # Create object from object template handle\n print(\"Solid Object being made using handle :{}\".format(solidHandle))\n obj_solid_id = sim.add_object_by_handle(solidHandle)\n objs_to_sim.append(obj_solid_id)\n # Place object in scene relative to agent\n set_object_state_from_agent(sim, obj_solid_id, offset=offset_solid)\n # Move offset for next object\n offset_solid[0] += 0.4\n\noffset_wf = np.array([-1.1, 0.6, -1.0])\n\nfor wireframeHandle in wireframe_handles_to_use.values():\n # Create object template with passed handle\n obj_template = obj_attr_mgr.create_template(wireframeHandle)\n # Create object from object template handle\n print(\"Wireframe Object being made using handle :{}\".format(wireframeHandle))\n obj_wf_id = sim.add_object_by_handle(wireframeHandle)\n objs_to_sim.append(obj_wf_id)\n # Place object in scene relative to agent\n set_object_state_from_agent(sim, obj_wf_id, offset=offset_wf)\n # Move offset for next object\n offset_wf[0] += 0.4\n\nexample_type = \"Adding customized primitive-based objects\"\nobservations = camera_track_simulate(sim, objs_to_sim, dt=2.0)\nif make_video:\n vut.make_video(\n observations,\n \"color_sensor_1st_person\",\n \"color\",\n output_path + example_type,\n open_vid=show_video,\n )\n\n# restore camera tracking position\nrestore_camera_track_config(sim, init_config)\nmake_clear_all_objects_button()",
"_____no_output_____"
]
],
[
[
"## Additional Advanced Topics:\n\nIn addition to the topics we covered here, visit the Habitat-sim [python docs](https://aihabitat.org/docs/habitat-sim/) to explore more topics.\n\n###Custom Lighting Setups\n\nHabitat-sim allows for both Phong and Flat shading options and configurable lighting groups for objects and scenes to be customized. See our [Working with Lights tutorial page](https://aihabitat.org/docs/habitat-sim/lighting-setups.html) to learn more.\n\n###Interactive Rigid Objects\n\nFor more details on the rigid object API, see our [Interactive Rigid Objects tutorial](https://aihabitat.org/docs/habitat-sim/rigid-object-tutorial.html).\n",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecad3346f7efa0d62c02b8bad3f05ee9eb3e7cd1 | 330,700 | ipynb | Jupyter Notebook | C3 Applied Machine Learning in Python/Assignment 4.ipynb | z-h-u-j-u-n/Coursera-Applied-Data-Science-with-Py | d3ac8a460727169d434514e6b94705ed622388ea | [
"MIT"
] | 2 | 2018-10-05T13:20:16.000Z | 2019-03-19T11:14:10.000Z | C3 Applied Machine Learning in Python/Assignment 4.ipynb | z-h-u-j-u-n/Coursera-Applied-Data-Science-with-Py | d3ac8a460727169d434514e6b94705ed622388ea | [
"MIT"
] | null | null | null | C3 Applied Machine Learning in Python/Assignment 4.ipynb | z-h-u-j-u-n/Coursera-Applied-Data-Science-with-Py | d3ac8a460727169d434514e6b94705ed622388ea | [
"MIT"
] | null | null | null | 38.606117 | 773 | 0.373233 | [
[
[
"---\n\n_You are currently looking at **version 1.1** of this notebook. To download notebooks and datafiles, as well as get help on Jupyter notebooks in the Coursera platform, visit the [Jupyter Notebook FAQ](https://www.coursera.org/learn/python-machine-learning/resources/bANLa) course resource._\n\n---",
"_____no_output_____"
],
[
"## Assignment 4 - Understanding and Predicting Property Maintenance Fines\n\nThis assignment is based on a data challenge from the Michigan Data Science Team ([MDST](http://midas.umich.edu/mdst/)). \n\nThe Michigan Data Science Team ([MDST](http://midas.umich.edu/mdst/)) and the Michigan Student Symposium for Interdisciplinary Statistical Sciences ([MSSISS](https://sites.lsa.umich.edu/mssiss/)) have partnered with the City of Detroit to help solve one of the most pressing problems facing Detroit - blight. [Blight violations](http://www.detroitmi.gov/How-Do-I/Report/Blight-Complaint-FAQs) are issued by the city to individuals who allow their properties to remain in a deteriorated condition. Every year, the city of Detroit issues millions of dollars in fines to residents and every year, many of these fines remain unpaid. Enforcing unpaid blight fines is a costly and tedious process, so the city wants to know: how can we increase blight ticket compliance?\n\nThe first step in answering this question is understanding when and why a resident might fail to comply with a blight ticket. This is where predictive modeling comes in. For this assignment, your task is to predict whether a given blight ticket will be paid on time.\n\nAll data for this assignment has been provided to us through the [Detroit Open Data Portal](https://data.detroitmi.gov/). **Only the data already included in your Coursera directory can be used for training the model for this assignment.** Nonetheless, we encourage you to look into data from other Detroit datasets to help inform feature creation and model selection. We recommend taking a look at the following related datasets:\n\n* [Building Permits](https://data.detroitmi.gov/Property-Parcels/Building-Permits/xw2a-a7tf)\n* [Trades Permits](https://data.detroitmi.gov/Property-Parcels/Trades-Permits/635b-dsgv)\n* [Improve Detroit: Submitted Issues](https://data.detroitmi.gov/Government/Improve-Detroit-Submitted-Issues/fwz3-w3yn)\n* [DPD: Citizen Complaints](https://data.detroitmi.gov/Public-Safety/DPD-Citizen-Complaints-2016/kahe-efs3)\n* [Parcel Map](https://data.detroitmi.gov/Property-Parcels/Parcel-Map/fxkw-udwf)\n\n___\n\nWe provide you with two data files for use in training and validating your models: train.csv and test.csv. Each row in these two files corresponds to a single blight ticket, and includes information about when, why, and to whom each ticket was issued. The target variable is compliance, which is True if the ticket was paid early, on time, or within one month of the hearing data, False if the ticket was paid after the hearing date or not at all, and Null if the violator was found not responsible. Compliance, as well as a handful of other variables that will not be available at test-time, are only included in train.csv.\n\nNote: All tickets where the violators were found not responsible are not considered during evaluation. They are included in the training set as an additional source of data for visualization, and to enable unsupervised and semi-supervised approaches. However, they are not included in the test set.\n\n<br>\n\n**File descriptions** (Use only this data for training your model!)\n\n train.csv - the training set (all tickets issued 2004-2011)\n test.csv - the test set (all tickets issued 2012-2016)\n addresses.csv & latlons.csv - mapping from ticket id to addresses, and from addresses to lat/lon coordinates. \n Note: misspelled addresses may be incorrectly geolocated.\n\n<br>\n\n**Data fields**\n\ntrain.csv & test.csv\n\n ticket_id - unique identifier for tickets\n agency_name - Agency that issued the ticket\n inspector_name - Name of inspector that issued the ticket\n violator_name - Name of the person/organization that the ticket was issued to\n violation_street_number, violation_street_name, violation_zip_code - Address where the violation occurred\n mailing_address_str_number, mailing_address_str_name, city, state, zip_code, non_us_str_code, country - Mailing address of the violator\n ticket_issued_date - Date and time the ticket was issued\n hearing_date - Date and time the violator's hearing was scheduled\n violation_code, violation_description - Type of violation\n disposition - Judgment and judgement type\n fine_amount - Violation fine amount, excluding fees\n admin_fee - $20 fee assigned to responsible judgments\nstate_fee - $10 fee assigned to responsible judgments\n late_fee - 10% fee assigned to responsible judgments\n discount_amount - discount applied, if any\n clean_up_cost - DPW clean-up or graffiti removal cost\n judgment_amount - Sum of all fines and fees\n grafitti_status - Flag for graffiti violations\n \ntrain.csv only\n\n payment_amount - Amount paid, if any\n payment_date - Date payment was made, if it was received\n payment_status - Current payment status as of Feb 1 2017\n balance_due - Fines and fees still owed\n collection_status - Flag for payments in collections\n compliance [target variable for prediction] \n Null = Not responsible\n 0 = Responsible, non-compliant\n 1 = Responsible, compliant\n compliance_detail - More information on why each ticket was marked compliant or non-compliant\n\n\n___\n\n## Evaluation\n\nYour predictions will be given as the probability that the corresponding blight ticket will be paid on time.\n\nThe evaluation metric for this assignment is the Area Under the ROC Curve (AUC). \n\nYour grade will be based on the AUC score computed for your classifier. A model which with an AUROC of 0.7 passes this assignment, over 0.75 will recieve full points.\n___\n\nFor this assignment, create a function that trains a model to predict blight ticket compliance in Detroit using `train.csv`. Using this model, return a series of length 61001 with the data being the probability that each corresponding ticket from `test.csv` will be paid, and the index being the ticket_id.\n\nExample:\n\n ticket_id\n 284932 0.531842\n 285362 0.401958\n 285361 0.105928\n 285338 0.018572\n ...\n 376499 0.208567\n 376500 0.818759\n 369851 0.018528\n Name: compliance, dtype: float32\n \n### Hints\n\n* Make sure your code is working before submitting it to the autograder.\n\n* Print out your result to see whether there is anything weird (e.g., all probabilities are the same).\n\n* Generally the total runtime should be less than 10 mins. You should NOT use Neural Network related classifiers (e.g., MLPClassifier) in this question. \n\n* Try to avoid global variables. If you have other functions besides blight_model, you should move those functions inside the scope of blight_model.\n\n* Refer to the pinned threads in Week 4's discussion forum when there is something you could not figure it out.",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nimport numpy as np\n\ndef blight_model():\n \n # Your code here\n \n return # Your answer here",
"_____no_output_____"
],
[
"blight_model()",
"_____no_output_____"
]
],
[
[
"### 操作流程\n最终trainset auc: 0.8842903778633651, testset auc: 0.8316679094640728\n- 数据集不平衡,先进行下采样\n- 删除缺失值多的特征\n- 删除无用特征\n- 填充缺失值\n- 将类别属性转换成数值属性\n- 选择模型\n - 决策树\n - 随机森林\n - 梯度上升树",
"_____no_output_____"
]
],
[
[
"train = pd.read_csv('train.csv', encoding = \"ISO-8859-1\")\ntest = pd.read_csv('test.csv')\ntrain.head()",
"/Users/zhujun/anaconda3/lib/python3.6/site-packages/IPython/core/interactiveshell.py:3018: DtypeWarning: Columns (11,12,31) have mixed types. Specify dtype option on import or set low_memory=False.\n interactivity=interactivity, compiler=compiler, result=result)\n"
],
[
"test.head()",
"_____no_output_____"
],
[
"train.info()",
"<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 250306 entries, 0 to 250305\nData columns (total 34 columns):\nticket_id 250306 non-null int64\nagency_name 250306 non-null object\ninspector_name 250306 non-null object\nviolator_name 250272 non-null object\nviolation_street_number 250306 non-null float64\nviolation_street_name 250306 non-null object\nviolation_zip_code 0 non-null float64\nmailing_address_str_number 246704 non-null float64\nmailing_address_str_name 250302 non-null object\ncity 250306 non-null object\nstate 250213 non-null object\nzip_code 250305 non-null object\nnon_us_str_code 3 non-null object\ncountry 250306 non-null object\nticket_issued_date 250306 non-null object\nhearing_date 237815 non-null object\nviolation_code 250306 non-null object\nviolation_description 250306 non-null object\ndisposition 250306 non-null object\nfine_amount 250305 non-null float64\nadmin_fee 250306 non-null float64\nstate_fee 250306 non-null float64\nlate_fee 250306 non-null float64\ndiscount_amount 250306 non-null float64\nclean_up_cost 250306 non-null float64\njudgment_amount 250306 non-null float64\npayment_amount 250306 non-null float64\nbalance_due 250306 non-null float64\npayment_date 41113 non-null object\npayment_status 250306 non-null object\ncollection_status 36897 non-null object\ngrafitti_status 1 non-null object\ncompliance_detail 250306 non-null object\ncompliance 159880 non-null float64\ndtypes: float64(13), int64(1), object(20)\nmemory usage: 64.9+ MB\n"
],
[
"test.info()",
"<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 61001 entries, 0 to 61000\nData columns (total 27 columns):\nticket_id 61001 non-null int64\nagency_name 61001 non-null object\ninspector_name 61001 non-null object\nviolator_name 60973 non-null object\nviolation_street_number 61001 non-null float64\nviolation_street_name 61001 non-null object\nviolation_zip_code 24024 non-null object\nmailing_address_str_number 59987 non-null object\nmailing_address_str_name 60998 non-null object\ncity 61000 non-null object\nstate 60670 non-null object\nzip_code 60998 non-null object\nnon_us_str_code 0 non-null float64\ncountry 61001 non-null object\nticket_issued_date 61001 non-null object\nhearing_date 58804 non-null object\nviolation_code 61001 non-null object\nviolation_description 61001 non-null object\ndisposition 61001 non-null object\nfine_amount 61001 non-null float64\nadmin_fee 61001 non-null float64\nstate_fee 61001 non-null float64\nlate_fee 61001 non-null float64\ndiscount_amount 61001 non-null float64\nclean_up_cost 61001 non-null float64\njudgment_amount 61001 non-null float64\ngrafitti_status 2221 non-null object\ndtypes: float64(9), int64(1), object(17)\nmemory usage: 12.6+ MB\n"
],
[
"train.describe()",
"_____no_output_____"
],
[
"train.compliance.value_counts()",
"_____no_output_____"
]
],
[
[
"### 1. 对训练集进行采样\n建议采样完成后保存成csv文件",
"_____no_output_____"
]
],
[
[
"true_index = np.array(train[train.compliance == 1].index)\ntrue_index",
"_____no_output_____"
],
[
"true_index.shape",
"_____no_output_____"
],
[
"false_index = np.array(train[train.compliance == 0].index)\nfalse_index",
"_____no_output_____"
],
[
"false_index.shape",
"_____no_output_____"
],
[
"sample_false_index = np.random.choice(false_index, size=true_index.shape[0], replace=False)\nsample_false_index",
"_____no_output_____"
],
[
"sample_index = np.concatenate([true_index, sample_false_index])\nsample_index.shape",
"_____no_output_____"
],
[
"sample = train.iloc[sample_index, :]\nsample",
"_____no_output_____"
],
[
"sample.compliance.value_counts()",
"_____no_output_____"
],
[
"train_sample = sample.copy()\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2. 特征工程",
"_____no_output_____"
]
],
[
[
"train_sample.info()",
"<class 'pandas.core.frame.DataFrame'>\nInt64Index: 23194 entries, 1 to 13122\nData columns (total 34 columns):\nticket_id 23194 non-null int64\nagency_name 23194 non-null object\ninspector_name 23194 non-null object\nviolator_name 23186 non-null object\nviolation_street_number 23194 non-null float64\nviolation_street_name 23194 non-null object\nviolation_zip_code 0 non-null float64\nmailing_address_str_number 22822 non-null float64\nmailing_address_str_name 23193 non-null object\ncity 23194 non-null object\nstate 23179 non-null object\nzip_code 23193 non-null object\nnon_us_str_code 1 non-null object\ncountry 23194 non-null object\nticket_issued_date 23194 non-null object\nhearing_date 23022 non-null object\nviolation_code 23194 non-null object\nviolation_description 23194 non-null object\ndisposition 23194 non-null object\nfine_amount 23194 non-null float64\nadmin_fee 23194 non-null float64\nstate_fee 23194 non-null float64\nlate_fee 23194 non-null float64\ndiscount_amount 23194 non-null float64\nclean_up_cost 23194 non-null float64\njudgment_amount 23194 non-null float64\npayment_amount 23194 non-null float64\nbalance_due 23194 non-null float64\npayment_date 13617 non-null object\npayment_status 23194 non-null object\ncollection_status 3112 non-null object\ngrafitti_status 0 non-null object\ncompliance_detail 23194 non-null object\ncompliance 23194 non-null float64\ndtypes: float64(13), int64(1), object(20)\nmemory usage: 6.2+ MB\n"
],
[
"test.info()",
"<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 61001 entries, 0 to 61000\nData columns (total 27 columns):\nticket_id 61001 non-null int64\nagency_name 61001 non-null object\ninspector_name 61001 non-null object\nviolator_name 60973 non-null object\nviolation_street_number 61001 non-null float64\nviolation_street_name 61001 non-null object\nviolation_zip_code 24024 non-null object\nmailing_address_str_number 59987 non-null object\nmailing_address_str_name 60998 non-null object\ncity 61000 non-null object\nstate 60670 non-null object\nzip_code 60998 non-null object\nnon_us_str_code 0 non-null float64\ncountry 61001 non-null object\nticket_issued_date 61001 non-null object\nhearing_date 58804 non-null object\nviolation_code 61001 non-null object\nviolation_description 61001 non-null object\ndisposition 61001 non-null object\nfine_amount 61001 non-null float64\nadmin_fee 61001 non-null float64\nstate_fee 61001 non-null float64\nlate_fee 61001 non-null float64\ndiscount_amount 61001 non-null float64\nclean_up_cost 61001 non-null float64\njudgment_amount 61001 non-null float64\ngrafitti_status 2221 non-null object\ndtypes: float64(9), int64(1), object(17)\nmemory usage: 12.6+ MB\n"
]
],
[
[
"#### 2.1 删除无用列",
"_____no_output_____"
]
],
[
[
"del_train_columns = ['violation_zip_code', 'non_us_str_code', 'payment_amount', 'payment_date', 'payment_status', 'balance_due', 'collection_status', \n 'compliance_detail']\ndel_test_columns = ['violation_zip_code', 'non_us_str_code']\ntrain_sample = train_sample.drop(del_train_columns, axis=1)\ntest = test.drop(del_test_columns, axis=1)",
"_____no_output_____"
],
[
"print(train_sample.shape, test.shape)",
"(23194, 26) (61001, 25)\n"
]
],
[
[
"#### 2.2 agency_name",
"_____no_output_____"
]
],
[
[
"train_sample.agency_name.value_counts()",
"_____no_output_____"
],
[
"from sklearn.preprocessing import LabelEncoder\n\nle = LabelEncoder()\nle.fit(train_sample.agency_name)\ntrain_sample.agency_name = le.transform(train_sample.agency_name)\ntest.agency_name = le.transform(test.agency_name)\ntrain_sample.head()",
"_____no_output_____"
],
[
"test.head()",
"_____no_output_____"
]
],
[
[
"### 2.3 insepector_name",
"_____no_output_____"
]
],
[
[
"train_sample.inspector_name.value_counts()",
"_____no_output_____"
],
[
"le2 = LabelEncoder()\nle2.fit(train_sample.inspector_name)\ntrain_sample.inspector_name = le2.transform(train_sample.inspector_name)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.4 violator_name",
"_____no_output_____"
]
],
[
[
"train.violator_name.value_counts()",
"_____no_output_____"
],
[
"train_sample.violator_name = train_sample.violator_name.fillna(method='ffill')\ntrain_sample.violator_name.isnull().sum()",
"_____no_output_____"
],
[
"le3 = LabelEncoder()\nle3.fit(train_sample.violator_name)\ntrain_sample.violator_name = le3.transform(train_sample.violator_name)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.5 violation_street_number\n连续值而且无缺失值,暂不处理",
"_____no_output_____"
],
[
"### 2.6 violation_street_name",
"_____no_output_____"
]
],
[
[
"train_sample.violation_street_name.value_counts()",
"_____no_output_____"
],
[
"le4 = LabelEncoder()\nle4.fit(train_sample.violation_street_name)\ntrain_sample.violation_street_name = le4.transform(train_sample.violation_street_name)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.7 mailing_address_str_number",
"_____no_output_____"
]
],
[
[
"train_sample.mailing_address_str_number.dtype",
"_____no_output_____"
],
[
"train_sample.mailing_address_str_number = train_sample.mailing_address_str_number.fillna(method='ffill')\ntrain_sample.mailing_address_str_number.isnull().sum()",
"_____no_output_____"
]
],
[
[
"### 2.8 mailing_address_str_name",
"_____no_output_____"
]
],
[
[
"train_sample.mailing_address_str_name.value_counts()",
"_____no_output_____"
],
[
"train_sample.mailing_address_str_name = train_sample.mailing_address_str_name.fillna(method='ffill')\ntrain_sample.mailing_address_str_name.isnull().sum()",
"_____no_output_____"
],
[
"le5 = LabelEncoder()\nle5.fit(train_sample.mailing_address_str_name)\ntrain_sample.mailing_address_str_name = le5.transform(train_sample.mailing_address_str_name)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.9 city\n无缺失值,字符串类型,需要做转换",
"_____no_output_____"
]
],
[
[
"train_sample.city.value_counts()",
"_____no_output_____"
],
[
"le6 = LabelEncoder()\nle6.fit(train_sample.city)\ntrain_sample.city = le6.transform(train_sample.city)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.10 state\n有缺失值,字符串类型,先填充再转换",
"_____no_output_____"
]
],
[
[
"train_sample.state.value_counts()",
"_____no_output_____"
],
[
"train_sample.state = train_sample.state.fillna(method='ffill')\ntrain_sample.state.isnull().sum()",
"_____no_output_____"
],
[
"le7 = LabelEncoder()\nle7.fit(train_sample.state)\ntrain_sample.state = le7.transform(train_sample.state)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.11 zip_code\n是字符串和int类型和nan的混合,先填充空值,再转换类型为字符串",
"_____no_output_____"
]
],
[
[
"train_sample.zip_code = train_sample.zip_code.fillna(method='ffill')\ntrain_sample.zip_code.isnull().sum()",
"_____no_output_____"
],
[
"train_sample.zip_code = train_sample.zip_code.astype(str)\ntrain_sample.zip_code.dtype",
"_____no_output_____"
],
[
"le8 = LabelEncoder()\nle8.fit(train_sample.zip_code)\ntrain_sample.zip_code = le8.transform(train_sample.zip_code)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.zip_code.head()",
"_____no_output_____"
],
[
"train_sample.zip_code",
"_____no_output_____"
]
],
[
[
"### 2.12 country\n无缺失值,字符串类型",
"_____no_output_____"
]
],
[
[
"train_sample.country.value_counts()",
"_____no_output_____"
],
[
"le9 = LabelEncoder()\nle9.fit(train_sample.country)\ntrain_sample.country = le9.transform(train_sample.country)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.country.head()",
"_____no_output_____"
]
],
[
[
"### 2.13 ticket_issued_date\n无缺失值,时间序列",
"_____no_output_____"
]
],
[
[
"train_sample.ticket_issued_date.value_counts()",
"_____no_output_____"
],
[
"train_sample.ticket_issued_date = pd.to_datetime(train_sample.ticket_issued_date)\ntrain_sample.ticket_issued_date[:5]",
"_____no_output_____"
],
[
"train_sample['ticket_issued_year'] = train_sample.ticket_issued_date.dt.year",
"_____no_output_____"
],
[
"train_sample['ticket_issued_year'].head()",
"_____no_output_____"
],
[
"train_sample['ticket_issued_month'] = train_sample.ticket_issued_date.dt.month\ntrain_sample['ticket_issued_month'].head()",
"_____no_output_____"
],
[
"train_sample['ticket_issued_day'] = train_sample.ticket_issued_date.dt.day\ntrain_sample['ticket_issued_day'].head()",
"_____no_output_____"
],
[
"train_sample['ticket_issued_hour'] = train_sample.ticket_issued_date.dt.hour\ntrain_sample['ticket_issued_hour'].head()",
"_____no_output_____"
],
[
"train_sample['ticket_issued_minute'] = train_sample.ticket_issued_date.dt.minute\ntrain_sample['ticket_issued_minute'].head()",
"_____no_output_____"
],
[
"train_sample = train_sample.drop(['ticket_issued_date'], axis=1)\ntrain_sample.head()",
"_____no_output_____"
]
],
[
[
"### 2.14 hearing_date\n有缺失值,时间序列",
"_____no_output_____"
]
],
[
[
"train_sample.hearing_date.value_counts()",
"_____no_output_____"
],
[
"train_sample.hearing_date = train_sample.hearing_date.fillna(method='ffill')\ntrain_sample.hearing_date.isnull().sum()",
"_____no_output_____"
],
[
"train_sample.hearing_date = pd.to_datetime(train_sample.hearing_date)\ntrain_sample.hearing_date[:5]",
"_____no_output_____"
],
[
"train_sample['hearing_year'] = train_sample.hearing_date.dt.year.astype(int)\ntrain_sample['hearing_year'].head()",
"_____no_output_____"
],
[
"train_sample['hearing_month'] = train_sample.hearing_date.dt.month.astype(int)\ntrain_sample['hearing_month'].head()",
"_____no_output_____"
],
[
"train_sample['hearing_day'] = train_sample.hearing_date.dt.day.astype(int)\ntrain_sample['hearing_day'].head()",
"_____no_output_____"
],
[
"train_sample['hearing_hour'] = train_sample.hearing_date.dt.hour.astype(int)\ntrain_sample['hearing_hour'].head()",
"_____no_output_____"
],
[
"train_sample['hearing_minute'] = train_sample.hearing_date.dt.minute.astype(int)\ntrain_sample['hearing_minute'].head()",
"_____no_output_____"
],
[
"train_sample = train_sample.drop(['hearing_date'], axis=1)",
"_____no_output_____"
]
],
[
[
"### 2.14 violation_code\n无缺失值",
"_____no_output_____"
]
],
[
[
"train_sample.violation_code.value_counts()",
"_____no_output_____"
],
[
"le10 = LabelEncoder()\nle10.fit(train_sample.violation_code)\ntrain_sample.violation_code = le10.transform(train_sample.violation_code)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.violation_code.head()",
"_____no_output_____"
]
],
[
[
"### 2.15 violation_description\n无缺失值",
"_____no_output_____"
]
],
[
[
"train_sample.violation_description.head()",
"_____no_output_____"
],
[
"train_sample.violation_description.value_counts()",
"_____no_output_____"
],
[
"le11 = LabelEncoder()\nle11.fit(train_sample.violation_description)\ntrain_sample.violation_description = le11.transform(train_sample.violation_description)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.violation_description.head()",
"_____no_output_____"
]
],
[
[
"### 2.13 disposition\n无缺失值",
"_____no_output_____"
]
],
[
[
"train_sample.disposition.head()",
"_____no_output_____"
],
[
"train_sample.disposition.value_counts()",
"_____no_output_____"
],
[
"le12 = LabelEncoder()\nle12.fit(train_sample.disposition)\ntrain_sample.disposition = le12.transform(train_sample.disposition)\n# test.inspector_name = le2.transform(test.inspector_name)\ntrain_sample.disposition.head()",
"_____no_output_____"
]
],
[
[
"### 2.14 fine_amount\n无缺失值且为连续值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.fine_amount.head()",
"_____no_output_____"
]
],
[
[
"### 2.15 admin_fee\n连续值且无缺失值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.admin_fee.head()",
"_____no_output_____"
]
],
[
[
"### 2.16 state_fee\n连续值且无缺失值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.state_fee.head()",
"_____no_output_____"
]
],
[
[
"### 2.17 late_fee\n连续值且无缺失值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.late_fee.head()",
"_____no_output_____"
]
],
[
[
"### 2.18 discount_amount\n连续值且无缺失值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.discount_amount.head()",
"_____no_output_____"
]
],
[
[
"### 2.19 clean_up_cost\n连续值且无缺失值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.clean_up_cost.head()",
"_____no_output_____"
]
],
[
[
"### 2.20 judgment_amount\n连续值且无缺失值,暂不处理",
"_____no_output_____"
]
],
[
[
"train_sample.judgment_amount.head()",
"_____no_output_____"
]
],
[
[
"### 2.21 grafitti_status\n删除,太多缺失值",
"_____no_output_____"
]
],
[
[
"train_sample = train_sample.drop(['grafitti_status'], axis=1)\ntrain_sample.head()",
"_____no_output_____"
],
[
"train_sample = train_sample.drop(['ticket_id'], axis=1)",
"_____no_output_____"
],
[
"train_sample.columns",
"_____no_output_____"
]
],
[
[
"### 3. 划分数据",
"_____no_output_____"
]
],
[
[
"train_sample.head()",
"_____no_output_____"
],
[
"train_sample.info()",
"<class 'pandas.core.frame.DataFrame'>\nInt64Index: 23194 entries, 1 to 13122\nData columns (total 32 columns):\nagency_name 23194 non-null int64\ninspector_name 23194 non-null int64\nviolator_name 23194 non-null int64\nviolation_street_number 23194 non-null float64\nviolation_street_name 23194 non-null int64\nmailing_address_str_number 23194 non-null float64\nmailing_address_str_name 23194 non-null int64\ncity 23194 non-null int64\nstate 23194 non-null int64\nzip_code 23194 non-null int64\ncountry 23194 non-null int64\nviolation_code 23194 non-null int64\nviolation_description 23194 non-null int64\ndisposition 23194 non-null int64\nfine_amount 23194 non-null float64\nadmin_fee 23194 non-null float64\nstate_fee 23194 non-null float64\nlate_fee 23194 non-null float64\ndiscount_amount 23194 non-null float64\nclean_up_cost 23194 non-null float64\njudgment_amount 23194 non-null float64\ncompliance 23194 non-null float64\nticket_issued_year 23194 non-null int64\nticket_issued_month 23194 non-null int64\nticket_issued_day 23194 non-null int64\nticket_issued_hour 23194 non-null int64\nticket_issued_minute 23194 non-null int64\nhearing_year 23194 non-null int64\nhearing_month 23194 non-null int64\nhearing_day 23194 non-null int64\nhearing_hour 23194 non-null int64\nhearing_minute 23194 non-null int64\ndtypes: float64(10), int64(22)\nmemory usage: 5.8 MB\n"
],
[
"y = train_sample.compliance\nx = train_sample.drop(['compliance'], axis=1)",
"_____no_output_____"
],
[
"from sklearn.model_selection import train_test_split\n\nx_train, x_test, y_train, y_test = train_test_split(x, y, random_state=0)\nprint(x_train.shape, x_test.shape, y_train.shape, y_test.shape)",
"(17395, 31) (5799, 31) (17395,) (5799,)\n"
]
],
[
[
"### 4. 训练",
"_____no_output_____"
]
],
[
[
"from sklearn.naive_bayes import MultinomialNB\nfrom sklearn.metrics import roc_auc_score\n\nmulnb = MultinomialNB()\nmulnb.fit(x_train, y_train)\ny_pred_prob = mulnb.predict_proba(x_test)\nprint('multinomialnb auc:', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"multinomialnb auc: 0.5184081930407787\n"
],
[
"from sklearn.tree import DecisionTreeClassifier\n\ndtc = DecisionTreeClassifier(max_depth=3)\ndtc.fit(x_train, y_train)\ny_train_prob = dtc.predict_proba(x_train)\ny_pred_prob = dtc.predict_proba(x_test)\nprint('decisiontree train set acc:', dtc.score(x_train, y_train))\nprint('decisiontree test set acc:', dtc.score(x_test, y_test))\nprint('decisiontree train set auc:', roc_auc_score(y_train, y_train_prob[:, 1]))\nprint('decisiontree test set auc:', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"decisiontree train set acc: 0.7374532911756252\ndecisiontree test set acc: 0.7287463355750992\ndecisiontree train set auc: 0.7807323769259887\ndecisiontree test set auc: 0.7761710173300048\n"
],
[
"from sklearn.model_selection import GridSearchCV\n\nparams = {'max_depth': [2, 3, 4, 5], 'max_features': [5, 8, 10,15, 20]}\ndtc = DecisionTreeClassifier()\nsearch = GridSearchCV(dtc, param_grid=params, scoring='roc_auc', cv=5)\nsearch.fit(x_train, y_train)\ny_pred_prob = search.predict_proba(x_test)\n\nprint('Grid best parameter (max. AUC): ', search.best_params_)\nprint('Grid best score (AUC): ', search.best_score_)\nprint('test set score (AUC): ', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"Grid best parameter (max. AUC): {'max_depth': 5, 'max_features': 20}\nGrid best score (AUC): 0.7980020019119559\ntest set score (AUC): 0.7971266872937726\n"
],
[
"from sklearn.ensemble import RandomForestClassifier\n\nrfc = RandomForestClassifier(n_estimators=10)\nrfc.fit(x_train, y_train)\ny_train_prob = rfc.predict_proba(x_train)\ny_pred_prob = rfc.predict_proba(x_test)\nprint('randomforest train set acc:', rfc.score(x_train, y_train))\nprint('randomforest test set acc:', rfc.score(x_test, y_test))\nprint('randomforest train set auc:', roc_auc_score(y_train, y_train_prob[:, 1]))\nprint('randomforest test set auc:', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"randomforest train set acc: 0.9848807128485196\nrandomforest test set acc: 0.7323676495947578\nrandomforest train set auc: 0.9992675342382054\nrandomforest test set auc: 0.8015256309714948\n"
],
[
"# params = {'max_depth': [2, 3, 4, 5], 'max_features': [5, 8, 10,15, 20]}\nrfc = RandomForestClassifier()\nparams = {'n_estimators': [10, 20, 50, 100], 'max_depth': [3, 5, 10], 'max_features': [5, 10, 20]}\nsearch = GridSearchCV(rfc, param_grid=params, scoring='roc_auc', cv=5)\nsearch.fit(x_train, y_train)\ny_pred_prob = search.predict_proba(x_test)\n\nprint('Grid best parameter (max. AUC): ', search.best_params_)\nprint('Grid best score (AUC): ', search.best_score_)\nprint('test set score (AUC): ', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"Grid best parameter (max. AUC): {'max_depth': 10, 'max_features': 10, 'n_estimators': 100}\nGrid best score (AUC): 0.8265379162535097\ntest set score (AUC): 0.824607578986239\n"
],
[
"brfc = search.best_estimator_\ny_train_prob = brfc.predict_proba(x_train)\ny_pred_prob = brfc.predict_proba(x_test)\nprint('randomforest train set acc:', brfc.score(x_train, y_train))\nprint('randomforest test set acc:', brfc.score(x_test, y_test))\nprint('randomforest train set auc:', roc_auc_score(y_train, y_train_prob[:, 1]))\nprint('randomforest test set auc:', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"randomforest train set acc: 0.7848807128485197\nrandomforest test set acc: 0.738058285911364\nrandomforest train set auc: 0.8795445298334563\nrandomforest test set auc: 0.824607578986239\n"
],
[
"from sklearn.ensemble import GradientBoostingClassifier\n\ngbc = GradientBoostingClassifier()\ngbc.fit(x_train, y_train)\ny_train_prob = gbc.predict_proba(x_train)\ny_pred_prob = gbc.predict_proba(x_test)\nprint('gradientboosting tree train set acc:', gbc.score(x_train, y_train))\nprint('gradientboosting tree test set acc:', gbc.score(x_test, y_test))\nprint('gradientboosting tree train set auc:', roc_auc_score(y_train, y_train_prob[:, 1]))\nprint('gradientboosting tree test set auc:', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"gradientboosting tree train set acc: 0.756481747628629\ngradientboosting tree test set acc: 0.7401276082083118\ngradientboosting tree train set auc: 0.8400225373267037\ngradientboosting tree test set auc: 0.8220179881243451\n"
],
[
"gbc = GradientBoostingClassifier(random_state=0)\nparams = {'n_estimators': [10, 50, 100], 'max_depth': [2, 3, 5], 'max_features': [5, 10, 20]}\nsearch = GridSearchCV(gbc, param_grid=params, scoring='roc_auc', cv=5)\nsearch.fit(x_train, y_train)\ny_pred_prob = search.predict_proba(x_test)\n\nprint('Grid best parameter (max. AUC): ', search.best_params_)\nprint('Grid best score (AUC): ', search.best_score_)\nprint('test set score (AUC): ', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"Grid best parameter (max. AUC): {'max_depth': 5, 'max_features': 20, 'n_estimators': 100}\nGrid best score (AUC): 0.8304599386546886\ntest set score (AUC): 0.8316679094640728\n"
],
[
"bgbc = search.best_estimator_\ny_train_prob = bgbc.predict_proba(x_train)\ny_pred_prob = bgbc.predict_proba(x_test)\nprint('gradientboosting tree train set acc:', bgbc.score(x_train, y_train))\nprint('gradientboosting tree test set acc:', bgbc.score(x_test, y_test))\nprint('gradientboosting tree train set auc:', roc_auc_score(y_train, y_train_prob[:, 1]))\nprint('gradientboosting tree test set auc:', roc_auc_score(y_test, y_pred_prob[:, 1]))",
"gradientboosting tree train set acc: 0.7913768324231101\ngradientboosting tree test set acc: 0.7454733574754268\ngradientboosting tree train set auc: 0.8842903778633651\ngradientboosting tree test set auc: 0.8316679094640728\n"
]
],
[
[
"### 5. 对测试集进行处理,提交数据",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
]
] |
ecad33f0b5f6cc054a3b61ad7071d89d92e44afb | 33,073 | ipynb | Jupyter Notebook | _numpy_pandas/pandas intro-2.ipynb | aixpact/data-science | f04a54595fbc2d797918d450b979fd4c2eabac15 | [
"MIT"
] | 2 | 2020-07-22T23:12:39.000Z | 2020-07-25T02:30:48.000Z | _numpy_pandas/pandas intro-2.ipynb | aixpact/data-science | f04a54595fbc2d797918d450b979fd4c2eabac15 | [
"MIT"
] | null | null | null | _numpy_pandas/pandas intro-2.ipynb | aixpact/data-science | f04a54595fbc2d797918d450b979fd4c2eabac15 | [
"MIT"
] | null | null | null | 17.733512 | 149 | 0.482327 | [
[
[
"<h1>Pandas Playbook</h1>",
"_____no_output_____"
],
[
"This Notebook lets you develop some intuition of the key features of *pandas* in a *query-like* way, with a minimum of python syntax: \n* Basic properties and functions \n* Frequent used operations: slicing, selection, insertion, deletion and aggregation\n\n*pandas* is a library for data exploration and analysis and is built upon other high performant libraries (*numpy*, *scipy*, *matplotlib*) \n*pandas* provides easy-to-use data structures and data manipulation functions.",
"_____no_output_____"
],
[
"More resources on pandas: \nhttp://pandas.pydata.org/pandas-docs/stable/10min.html \nhttps://www.kaggle.com/rtatman/data-cleaning-challenge-scale-and-normalize-data/notebook",
"_____no_output_____"
],
[
"<h2>Import libraries</h2>",
"_____no_output_____"
]
],
[
[
"import numpy as np\nimport pandas as pd",
"_____no_output_____"
],
[
"# Set pandas defaults\n# Show max 10 rows: head(5) ... tail(5)\npd.set_option('max_rows', 10) ",
"_____no_output_____"
]
],
[
[
"## Terminal\nUse !<bash command> to use terminal commands",
"_____no_output_____"
]
],
[
[
"!ls",
"_____no_output_____"
],
[
"!head -3 excel_test.xlsx",
"_____no_output_____"
]
],
[
[
"### Import Excel file",
"_____no_output_____"
]
],
[
[
"df = df = pd.read_excel('excel_test.xlsx', skiprows=2)\ndf",
"_____no_output_____"
],
[
"df.sample(5)",
"_____no_output_____"
]
],
[
[
"## Series\nSeries are like one column of the dataframe, vice versa a dataframe consists of multiple series. A Series can also be a row from a dataframe!",
"_____no_output_____"
]
],
[
[
"ser = df.age\nser.head(), ser.tail()",
"_____no_output_____"
],
[
"ser.dtype",
"_____no_output_____"
],
[
"ser.index",
"_____no_output_____"
],
[
"ser.describe()",
"_____no_output_____"
],
[
"ser.iloc[2]",
"_____no_output_____"
],
[
"ser.loc[[1, 100]]",
"_____no_output_____"
],
[
"ser[[4, 3, 1]]",
"_____no_output_____"
],
[
"81 in ser",
"_____no_output_____"
],
[
"# todo get index of 81\nser.index.get_loc(81)",
"_____no_output_____"
],
[
"ser.max()",
"_____no_output_____"
],
[
"ser.argmax()",
"_____no_output_____"
],
[
"ser[149]",
"_____no_output_____"
]
],
[
[
"### Mutable state\nNOTE: Objects like Series and DataFrames are MUTABLE!",
"_____no_output_____"
]
],
[
[
"id(ser)",
"_____no_output_____"
],
[
"from copy import deepcopy\nser_copy = deepcopy(ser)",
"_____no_output_____"
],
[
"id(ser_copy)",
"_____no_output_____"
],
[
"ser_copy == ser",
"_____no_output_____"
],
[
"ser_copy is ser",
"_____no_output_____"
]
],
[
[
"### DataFrame row to Series",
"_____no_output_____"
]
],
[
[
"row_0 = df.iloc[0,:]\ntype(row_0)",
"_____no_output_____"
],
[
"row_0",
"_____no_output_____"
],
[
"row_0.name",
"_____no_output_____"
],
[
"row_0 = row_0.rename('first_row')\nrow_0.name",
"_____no_output_____"
],
[
"'weight' in row_0",
"_____no_output_____"
],
[
"row_0.index",
"_____no_output_____"
],
[
"row_0.isnull().any()",
"_____no_output_____"
]
],
[
[
"## DataFrames and Series",
"_____no_output_____"
],
[
"### Show dataframe and column properties",
"_____no_output_____"
]
],
[
[
"df.info()",
"_____no_output_____"
],
[
"df.select_dtypes(include=['object', 'category'])",
"_____no_output_____"
],
[
"df.select_dtypes(include=['int64', 'float64']).columns",
"_____no_output_____"
],
[
"df.shape",
"_____no_output_____"
],
[
"df.columns",
"_____no_output_____"
],
[
"df = df.rename(columns = {\n 'sex':'sex',\n 'id':'ID',\n})\ndf.head(3)",
"_____no_output_____"
]
],
[
[
"### List comprehension",
"_____no_output_____"
]
],
[
[
"[col_name for col_name in df.columns]",
"_____no_output_____"
],
[
"df.columns = [col.upper() for col in df.columns]\ndf.tail(5)",
"_____no_output_____"
],
[
"df.columns = [col.lower() for col in df.columns]\ndf.head(5)",
"_____no_output_____"
]
],
[
[
"### Type, dtype, category",
"_____no_output_____"
]
],
[
[
"type(df['age'])",
"_____no_output_____"
],
[
"df['age'].dtype, df['sexe'].dtype",
"_____no_output_____"
],
[
"df['sexe'].factorize()\ndf['sexe'].astype('category')",
"_____no_output_____"
],
[
"df.values",
"_____no_output_____"
],
[
"df[:5]",
"_____no_output_____"
],
[
"df.iloc[-5:,]",
"_____no_output_____"
],
[
"organs = df.pop('organs')\norgans[:5]",
"_____no_output_____"
],
[
"type(organs)",
"_____no_output_____"
],
[
"df.head()",
"_____no_output_____"
],
[
"del df['alcoholic']\ndf.head()",
"_____no_output_____"
],
[
"df.insert(5, 'organs', organs)\ndf.head(10)",
"_____no_output_____"
]
],
[
[
"### Check for type and NaN",
"_____no_output_____"
]
],
[
[
"df['height'].dtype",
"_____no_output_____"
],
[
"df['height'].isnull().any().sum()",
"_____no_output_____"
]
],
[
[
"### Coerce string values to numeric values",
"_____no_output_____"
]
],
[
[
"df['height_in_meter'] = pd.to_numeric(df['height'], errors='coerce') / 100\ndf.head()",
"_____no_output_____"
]
],
[
[
"### Set type to float\nFeature needs to be clean, no strings like 'ND'",
"_____no_output_____"
]
],
[
[
"# df.loc[:, 'height'].astype(np.float32, errors='ignore') # error",
"_____no_output_____"
]
],
[
[
"### Show summary statistics\n<li>The \"describe\" function returns a dataframe containing summary stats for all numerical columns\n<li>Columns containing non-numerical data are ignored",
"_____no_output_____"
]
],
[
[
"df.describe()",
"_____no_output_____"
],
[
"df['smoker'].mean()",
"_____no_output_____"
]
],
[
[
"### Transpose dataframe",
"_____no_output_____"
]
],
[
[
"df.describe().T",
"_____no_output_____"
]
],
[
[
"### Set precision format of DataFrame",
"_____no_output_____"
]
],
[
[
"pd.options.display.float_format = '{:.1f}'.format\ndf.describe().T",
"_____no_output_____"
],
[
"df.describe().T['75%']",
"_____no_output_____"
]
],
[
[
"### Get unique values",
"_____no_output_____"
]
],
[
[
"df['smoker'].unique()",
"_____no_output_____"
]
],
[
[
"### Get frequency",
"_____no_output_____"
]
],
[
[
"df.loc[:, 'smoker'].value_counts()",
"_____no_output_____"
],
[
"top = 3\ndf.loc[:, 'age'].value_counts().nlargest(top)",
"_____no_output_____"
]
],
[
[
"### Set index",
"_____no_output_____"
]
],
[
[
"df.set_index('id', inplace=True)\ndf.head()",
"_____no_output_____"
]
],
[
[
"### Reset index",
"_____no_output_____"
]
],
[
[
"df.reset_index()\ndf[:5]",
"_____no_output_____"
]
],
[
[
"## Accessing columns and rows\nThere are multiple ways to select columns and rows. \nThe prefered way is to use .loc and .iloc",
"_____no_output_____"
],
[
"<h3>Getting column data</h3>",
"_____no_output_____"
]
],
[
[
"df.age[:5]",
"_____no_output_____"
],
[
"df['age'][:5]",
"_____no_output_____"
],
[
"df.loc[:5, 'age']",
"_____no_output_____"
]
],
[
[
"<h3>Getting row data</h3>",
"_____no_output_____"
]
],
[
[
"#df[1] # KeyError",
"_____no_output_____"
],
[
"df.loc[1]",
"_____no_output_____"
]
],
[
[
"<h3>Getting a row by row number</h3>",
"_____no_output_____"
]
],
[
[
"df.iloc[0]",
"_____no_output_____"
]
],
[
[
"### Getting a column by column number",
"_____no_output_____"
]
],
[
[
"df.iloc[:5, 0]",
"_____no_output_____"
]
],
[
[
"### Getting multiple columns",
"_____no_output_____"
]
],
[
[
"df[['age','smoker']][:5]",
"_____no_output_____"
],
[
"df.loc[:5, ['age', 'smoker']]",
"_____no_output_____"
]
],
[
[
"### Getting a specific cell as view",
"_____no_output_____"
]
],
[
[
"df.loc[1,'age']",
"_____no_output_____"
]
],
[
[
"### Getting cell as view != copy\nWatch out for this caveat!",
"_____no_output_____"
]
],
[
[
"df.loc[1]['age']",
"_____no_output_____"
],
[
"a = df.loc[1]['age']\nb = df.loc[1,'age']\na == b",
"_____no_output_____"
],
[
"a is b",
"_____no_output_____"
],
[
"id(a) == id(b)",
"_____no_output_____"
]
],
[
[
"## Slicing\nBy index and by row/column number ",
"_____no_output_____"
]
],
[
[
"df.index",
"_____no_output_____"
],
[
"df.loc[1] == df.iloc[0]",
"_____no_output_____"
],
[
"df.loc[5:10]",
"_____no_output_____"
],
[
"df.loc[5:10, ['age', 'weight']]",
"_____no_output_____"
],
[
"df.iloc[-5:, -3:]",
"_____no_output_____"
]
],
[
[
"### Conditional slicing",
"_____no_output_____"
]
],
[
[
"df[df.age < 18]",
"_____no_output_____"
],
[
"df[pd.isnull(df)].sample(5)",
"_____no_output_____"
],
[
"df.where((df['age'] > 53)).sample(5)",
"_____no_output_____"
],
[
"df.where((df['age'] > 52), None).sample(5)",
"_____no_output_____"
],
[
"df[(df['age'] > 50) & (df['weight'] < 50)].sort_values('weight')",
"_____no_output_____"
]
],
[
[
"### Slicing based on value list",
"_____no_output_____"
]
],
[
[
"age_range = range(0, 20)\nage_range",
"_____no_output_____"
],
[
"valuelist = list(age_range)\nvaluelist",
"_____no_output_____"
],
[
"df[df.age.isin(valuelist)].sort_values(['sexe', 'age'])",
"_____no_output_____"
]
],
[
[
"### Create new (calcuculated) columns",
"_____no_output_____"
]
],
[
[
"df['is_smoker'] = df['smoker'] == 1\ndf.head()",
"_____no_output_____"
],
[
"df['bmi'] = df['weight'] / df['height_in_meter']**2\ndf.head()",
"_____no_output_____"
]
],
[
[
"### Conditionally replace values",
"_____no_output_____"
]
],
[
[
"df['adult'] = np.where(df.loc[:, 'age'] >= 21, 1, 0).astype(np.uint8)\ndf.sample(3)",
"_____no_output_____"
],
[
"df.loc[:, 'organs'] = np.where(df.loc[:, 'organs'] > 3, 3, df.loc[:, 'organs'])\ndf.organs.describe()",
"_____no_output_____"
]
],
[
[
"### Create dummy variables",
"_____no_output_____"
]
],
[
[
"df = pd.get_dummies(df, columns=['organs'], drop_first=True)\ndf",
"_____no_output_____"
]
],
[
[
"## Missing data",
"_____no_output_____"
]
],
[
[
"df.info()",
"_____no_output_____"
]
],
[
[
"### Get columns with NaN+ values",
"_____no_output_____"
]
],
[
[
"na_synonyms = ['ND', 'nan', 'NaN', 'NA', '']\ncontains_nan = [df.loc[:, feature].isin(na_synonyms).values.any() for feature in df.columns]\ndf.columns[contains_nan]",
"_____no_output_____"
],
[
"df['height'].unique()",
"_____no_output_____"
],
[
"df.loc[:, 'height'].value_counts()",
"_____no_output_____"
],
[
"df[df['height'] == 'ND'] = np.nan",
"_____no_output_____"
],
[
"missing_values_count = df.isnull().sum()\nmissing_values_count.sort_values()",
"_____no_output_____"
],
[
"total_cells = np.product(df.shape)\nmissing_values_count.sum() / total_cells",
"_____no_output_____"
],
[
"pd.isnull(df)",
"_____no_output_____"
],
[
"df.dropna(how='any', axis=0)",
"_____no_output_____"
],
[
"df.dropna(how='any', axis=1)",
"_____no_output_____"
],
[
"df.notnull().shape",
"_____no_output_____"
],
[
"df.fillna(value=df.mean())",
"_____no_output_____"
],
[
"df.notnull().shape",
"_____no_output_____"
]
],
[
[
"## Aggregation",
"_____no_output_____"
]
],
[
[
"df.groupby('sexe').count()",
"_____no_output_____"
],
[
"df[df.age.isin([16, 17, 18, 19, 20, 21])].groupby(['age', 'sexe']).count()['is_smoker']",
"_____no_output_____"
]
],
[
[
"### Get top-n by frequency",
"_____no_output_____"
]
],
[
[
"top = 3\ndf.groupby('age')['smoker'].count().sort_values(ascending=False).head(top).index.tolist()",
"_____no_output_____"
]
],
[
[
"## Stacking, pivotting",
"_____no_output_____"
]
],
[
[
"df.reset_index(inplace=True)\ndf.set_index(['sexe', 'is_smoker'], inplace=True)\ndf.sort_index().stack()[:18]",
"_____no_output_____"
],
[
"df.reset_index(inplace=True)\ndf.columns",
"_____no_output_____"
],
[
"pd.pivot_table(df, values='bmi', index=['sexe'], columns=['smoker'])",
"_____no_output_____"
],
[
"pd.pivot_table(df, values='bmi', index=['sexe'], columns=['smoker'], margins=True, aggfunc=np.std)",
"_____no_output_____"
],
[
"pd.crosstab(df['smoker'], df['age'])",
"_____no_output_____"
],
[
"df['age_group'] = pd.cut(df.age, range(0, 120, 20), right=False) #, labels=labels)\ndf['age_group'].describe()",
"_____no_output_____"
],
[
"df['age_group'].dtype",
"_____no_output_____"
],
[
"df['sexe'].astype('category'); # ';' kills output",
"_____no_output_____"
],
[
"pd.crosstab(df['smoker'], df['age_group'])",
"_____no_output_____"
]
],
[
[
"## Correlation matrix",
"_____no_output_____"
]
],
[
[
"df.corr()",
"_____no_output_____"
],
[
"df.apply(lambda x: x.factorize()[0]).corr()",
"_____no_output_____"
],
[
"df.loc[:, ['age', 'weight']].plot();",
"_____no_output_____"
],
[
"df.loc[df['age'] > 50, ['weight']].plot()\ndf.loc[df['age'] <= 50, ['weight']].plot();",
"_____no_output_____"
],
[
"writer = pd.ExcelWriter('file_name.xlsx')",
"_____no_output_____"
],
[
"df.to_excel(writer, 'sheet_name')\nwriter.save()",
"_____no_output_____"
],
[
"df.to_excel(writer, 'sheet_name2')\nwriter.save()",
"_____no_output_____"
],
[
"!ls",
"_____no_output_____"
],
[
"pd.read_excel('file_name.xlsx')",
"_____no_output_____"
]
],
[
[
"## Dates",
"_____no_output_____"
]
],
[
[
"pd.Timestamp('9/1/2016 10:05AM')",
"_____no_output_____"
],
[
"pd.Period('1/2016')",
"_____no_output_____"
],
[
"pd.Period('3/5/2016')",
"_____no_output_____"
]
],
[
[
"### DateTimeIndex",
"_____no_output_____"
]
],
[
[
"t1 = pd.Series(list('abc'), [pd.Timestamp('2016-09-01'), pd.Timestamp('2016-09-02'), pd.Timestamp('2016-09-03')])\nt1",
"_____no_output_____"
],
[
"type(t1.index)",
"_____no_output_____"
],
[
"t2 = pd.Series(list('def'), [pd.Period('2016-09'), pd.Period('2016-10'), pd.Period('2016-11')])\nt2",
"_____no_output_____"
],
[
"type(t2.index)",
"_____no_output_____"
]
],
[
[
"### Time in DataFrames",
"_____no_output_____"
]
],
[
[
"d1 = ['2 June 2013', 'Aug 29, 2014', '2015-06-26', '7/12/16']\nts3 = pd.DataFrame(np.random.randint(10, 100, (4,2)), index=d1, columns=list('ab'))\nts3",
"_____no_output_____"
],
[
"ts3.index = pd.to_datetime(ts3.index)\nts3",
"_____no_output_____"
],
[
"pd.to_datetime('4.7.12', dayfirst=True)",
"_____no_output_____"
]
],
[
[
"### Time deltas",
"_____no_output_____"
]
],
[
[
"pd.Timestamp('9/3/2016')-pd.Timestamp('9/1/2016')",
"_____no_output_____"
],
[
"pd.Timestamp('9/2/2016 8:10AM') + pd.Timedelta('12D 3H')",
"_____no_output_____"
]
],
[
[
"### Working with dates",
"_____no_output_____"
]
],
[
[
"dates = pd.date_range('10-01-2016', periods=9, freq='2W-SUN')\ndates",
"_____no_output_____"
],
[
"df = pd.DataFrame({'Count 1': 100 + np.random.randint(-5, 10, 9).cumsum(),\n 'Count 2': 120 + np.random.randint(-5, 10, 9)}, index=dates)\ndf",
"_____no_output_____"
],
[
"df.index.weekday_name",
"_____no_output_____"
],
[
"df.diff()",
"_____no_output_____"
],
[
"df.resample('M').mean()",
"_____no_output_____"
],
[
"df['2017']",
"_____no_output_____"
],
[
"df['2016-12']",
"_____no_output_____"
],
[
"df['2016-12':]",
"_____no_output_____"
],
[
"### FFill ",
"_____no_output_____"
],
[
"df.asfreq('W', method='ffill')",
"_____no_output_____"
],
[
"# !pip install pandas_datareader",
"_____no_output_____"
],
[
"from pandas_datareader import data\nimport datetime as dt\nstart = dt.datetime(2017, 1, 1)\nend = dt.datetime.today()\nprint(start,end)",
"_____no_output_____"
],
[
"data",
"_____no_output_____"
],
[
"df.to_pickle(\"df_name.pickle\")",
"_____no_output_____"
],
[
"df = pd.read_pickle(\"df_name.pickle\")",
"_____no_output_____"
],
[
"# !pip install html5lib\n# !pip install protobuf pyasn1 bs4\n# import bs4 as BeautifulSoup4\n# BeautifulSoup4.__version__",
"_____no_output_____"
],
[
"# df_list = pd.read_html('http://www.bloomberg.com/markets/currencies/major')\n# print(len(df_list))",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecad39a1dd58a0dd95d46c8babaee4f7b3d88f8a | 170,555 | ipynb | Jupyter Notebook | notebooks/Color Frequency Classifier.ipynb | vingkan/phylo | f9612b06940a5f62113e123be80bb4f9bd57dea7 | [
"MIT"
] | null | null | null | notebooks/Color Frequency Classifier.ipynb | vingkan/phylo | f9612b06940a5f62113e123be80bb4f9bd57dea7 | [
"MIT"
] | null | null | null | notebooks/Color Frequency Classifier.ipynb | vingkan/phylo | f9612b06940a5f62113e123be80bb4f9bd57dea7 | [
"MIT"
] | null | null | null | 165.106486 | 20,220 | 0.883838 | [
[
[
"import numpy as np\nimport pandas as pd\nimport scipy\nimport imageio\nimport math\nimport phylo as ph\n\nfrom PIL import Image\nfrom sklearn.linear_model import LogisticRegression\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import confusion_matrix\n\n%matplotlib inline\nimport matplotlib.pyplot as plt\nfrom matplotlib.pyplot import imshow\nimport seaborn as sns\nimport warnings\nsns.set(style=\"ticks\")\nplt.style.use(\"seaborn-whitegrid\")",
"_____no_output_____"
],
[
"%load_ext blackcellmagic",
"_____no_output_____"
]
],
[
[
"# Preparation\n\nAll the expensive setup happens up here.",
"_____no_output_____"
]
],
[
[
"np.random.seed(820)\nREGULAR_POKEMON = ph.vectorize_pokemon(ph.REGULAR_POKEMON_PATH)\nSHINY_POKEMON = ph.vectorize_pokemon(ph.SHINY_POKEMON_PATH)",
"Vectorizing pokemon from /Users/vineshkannan/Documents/GitHub/phylo/images/regular/\nVector iteration 0\nVector iteration 100\nVector iteration 200\nVector iteration 300\nVector iteration 400\nVector iteration 500\nVector iteration 600\nDone vectorizing\nVectorizing pokemon from /Users/vineshkannan/Documents/GitHub/phylo/images/shiny/\nVector iteration 0\nVector iteration 100\nVector iteration 200\nVector iteration 300\nVector iteration 400\nVector iteration 500\nVector iteration 600\nDone vectorizing\n"
],
[
"known_creatures = list(REGULAR_POKEMON) + list(SHINY_POKEMON)\nnp.random.shuffle(known_creatures)",
"_____no_output_____"
],
[
"random_vectors = [ph.generate_random() for i in range(len(known_creatures))]\nexpect_base_pop = known_creatures + random_vectors\nlen(expect_base_pop)",
"_____no_output_____"
],
[
"n_expected = len(known_creatures)\nexpected_from_n_sub = 50\nexpected_vectors = []\nfor i in range(n_expected):\n ev = ph.generate_expected(expect_base_pop, expected_from_n_sub)\n ev_ob = ph.outline_body(ev)\n expected_vectors.append(ev_ob)\n if i % 100 == 0:\n print(i)\nprint(\"Done.\")",
"0\n100\n200\n300\n400\n500\n600\n700\n800\n900\n1000\n1100\n1200\nDone.\n"
],
[
"kc_aps = [ph.active_prop(x) for x in known_creatures]\nev_aps = [ph.active_prop(x) for x in expected_vectors]\nrv_aps = [ph.active_prop(x) for x in random_vectors]",
"_____no_output_____"
]
],
[
[
"# Background\n\nHere are some kinds of vectors we are interested in.",
"_____no_output_____"
]
],
[
[
"ph.showim(known_creatures[4], scale=2)",
"_____no_output_____"
],
[
"ph.showim(expected_vectors[4], scale=2)",
"_____no_output_____"
],
[
"ph.showim(random_vectors[4], scale=2)",
"_____no_output_____"
]
],
[
[
"## Active Proportion\n\nActive proportion is the proportion of cells that have a color quantum greater than 1.",
"_____no_output_____"
]
],
[
[
"with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\")\n sns.distplot(kc_aps, color=\"green\", label=\"Known Creatures\")\n sns.distplot(ev_aps, color=\"red\", label=\"Expected Vectors\")\n sns.distplot(rv_aps, color=\"gray\", label=\"Random Vectors\")\n plt.xlim(0, 1)\n plt.title(\"Active Proportion\")\n plt.legend()",
"_____no_output_____"
]
],
[
[
"## Quantum Frequency\n\nThe frequency of each color quantum in the vector.",
"_____no_output_____"
]
],
[
[
"kc_qfreq = [ph.col_freq(xv) for xv in known_creatures]\nev_qfreq = [ph.col_freq(xv) for xv in expected_vectors]",
"_____no_output_____"
],
[
"kc_qdf = pd.DataFrame(kc_qfreq)\nkc_qdf.head(3)",
"_____no_output_____"
],
[
"ev_qdf = pd.DataFrame(ev_qfreq)\nev_qdf.head(3)",
"_____no_output_____"
],
[
"def plot_qfreq(kc_qdf, ev_qdf, qidx):\n with warnings.catch_warnings():\n warnings.simplefilter(\"ignore\")\n sns.distplot(kc_qdf[qidx], color=\"green\", label=\"Known Creatures\")\n sns.distplot(ev_qdf[qidx], color=\"red\", label=\"Expected Vectors\") \n plt.xlim(0, 1)\n plt.title(\"Frequency of Q = {}\".format(qidx))\n plt.legend()\n return plt",
"_____no_output_____"
],
[
"plot_qfreq(kc_qdf, ev_qdf, 0)",
"_____no_output_____"
],
[
"plot_qfreq(kc_qdf, ev_qdf, 1)",
"_____no_output_____"
],
[
"plot_qfreq(kc_qdf, ev_qdf, 2)",
"_____no_output_____"
],
[
"plot_qfreq(kc_qdf, ev_qdf, 3)",
"_____no_output_____"
],
[
"plot_qfreq(kc_qdf, ev_qdf, 4)",
"_____no_output_____"
]
],
[
[
"# Classification\n\nDistinguish between known creatures (`True`) and expected vectors (`False`).",
"_____no_output_____"
]
],
[
[
"X = kc_qfreq + ev_qfreq\ny = [True for i in kc_qfreq] + [False for i in ev_qfreq]",
"_____no_output_____"
],
[
"X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=1./3, random_state=820)",
"_____no_output_____"
],
[
"clf = LogisticRegression(\n random_state=0, solver=\"liblinear\", multi_class=\"ovr\", max_iter=200\n).fit(X_train, y_train)\nprint(\"Mean Train Accuracy = {0:.3f}\".format(clf.score(X_train, y_train)))\nprint(\"Mean Test Accuracy = {0:.3f}\".format(clf.score(X_test, y_test)))\nprint(clf.classes_)\nw = clf.coef_[0]\nw",
"Mean Train Accuracy = 0.826\nMean Test Accuracy = 0.820\n[False True]\n"
]
],
[
[
"The class distribution is 50/50 between known creatures/expected vectors. Accuracy seems fine, more important to consider the full confusion matrix\n\nThe weight values of the regression model make sense given the above histograms:\n- Note that all weight values were normalized into the range [0, 1]\n- `w0` is negative, influences prediction towards EV\n- `w3` has the greatest absolute value and influences prediction towards KC\n- It is not clear how signicant `w1`, `w2`, and `w4` are.",
"_____no_output_____"
]
],
[
[
"y_pred = clf.predict(X_test)\ntn, fp, fn, tp = confusion_matrix(y_test, y_pred).ravel()\nprint(\"TP = {}\\tFN = {}\".format(tp, fn))\nprint(\"FP = {}\\t\\tTN = {}\".format(fp, tn))",
"TP = 301\tFN = 156\nFP = 0\t\tTN = 409\n"
]
],
[
[
"The confusion matrix shows no false positives, meaning that the model did not predict any expected vectors as creatures. This is upsetting, we had hoped to find some creature-like expected vectors from the classification errors.\n\nThe false negative cases, known creatures classified as not creature-like, account for all of the test classification inaccuracies.\n\nFor now, we are satisfied with the accuracy level because the classifier did not misclassify any expected vectors. However, we cannot rule out overfitting because we cannot be sure that the expected vectors are representative of reasonable creature candidates. We also cannot be sure that there truly are no creature-like expected vectors in the test dataset.\n\nWe will look for low values of `P(False|x)` to identify possible creature-like expected vectors.",
"_____no_output_____"
]
],
[
[
"ev_proba_t = clf.predict_proba(ev_qfreq)[:,1]\nlen(ev_proba_t)",
"_____no_output_____"
],
[
"ev_qdf[\"pt\"] = ev_proba_t\nev_qdf.sort_values(by=\"pt\", ascending=False).head(5)",
"_____no_output_____"
],
[
"ph.showim(expected_vectors[507])",
"_____no_output_____"
],
[
"ph.showim(expected_vectors[665])",
"_____no_output_____"
],
[
"ph.showim(expected_vectors[470])",
"_____no_output_____"
],
[
"ph.showim(expected_vectors[1269])",
"_____no_output_____"
],
[
"ph.showim(expected_vectors[1039])",
"_____no_output_____"
]
],
[
[
"The top five true negative cases look somewhat like the silhouettes of creatures. Perhaps these would be suitable starting points for a search algorithm.",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
]
] |
ecad3f699d83c2b5262cd88cc4c99f8181930520 | 14,237 | ipynb | Jupyter Notebook | iN_SS.ipynb | szombara/coding-traning | fc9ee000eaac738abbc7b746c9769afb49f96564 | [
"MIT"
] | null | null | null | iN_SS.ipynb | szombara/coding-traning | fc9ee000eaac738abbc7b746c9769afb49f96564 | [
"MIT"
] | null | null | null | iN_SS.ipynb | szombara/coding-traning | fc9ee000eaac738abbc7b746c9769afb49f96564 | [
"MIT"
] | null | null | null | 29.055102 | 136 | 0.529817 | [
[
[
"# My tests of iNaturalist API",
"_____no_output_____"
],
[
"## import observation from iNaturalist",
"_____no_output_____"
]
],
[
[
"import requests # https://realpython.com/python-requests/ - lib for requests\nimport time\nfrom ipyleaflet import Map, Marker, GeoJSON, basemaps # ipyleaflet in anaconda https://anaconda.org/conda-forge/ipyleaflet\nfrom geojson import MultiPoint, Feature, FeatureCollection #geojson in anaconda - https://anaconda.org/conda-forge/geojson\n\n\n# my observation\nurl = \"https://api.inaturalist.org/v1/observations?id=72266225\"\n\n# r1 - response\nr1 = requests.get(url)\n\n# print and convert from jason to dict.\n#print(r.json())\n\n#location from tekst do list\n# l - location # lon, lat \n#print(r.json()['results'][0]['location']) \nl = [float(r1.json()['results'][0]['location'].split(\",\")[0]),float(r1.json()['results'][0]['location'].split(\",\")[1])]\nl",
"_____no_output_____"
]
],
[
[
"## define map and marker",
"_____no_output_____"
]
],
[
[
"#parameters for map\ncenter = l\nzoom = 15\n\n#map object\nm = Map(center=center, zoom=zoom)\n\n#define and add marker\nmarker = Marker(location=center, draggable=False)\nm.add_layer(marker);\n\n#add map\nm\n\n#to jest testowa linijka",
"_____no_output_____"
]
],
[
[
"## add geoJSON point",
"_____no_output_____"
]
],
[
[
"# !!!!!! Attention ! for unknown reasons ipyleaflet needs changed coordinates in MultiPoint !!!!!\n# https://github.com/jupyter-widgets/ipyleaflet/pull/439#issuecomment-658030755\n# definition of geoJSON - simple point :)\ndata1 = FeatureCollection( [ Feature ( geometry=MultiPoint( [(l[::-1])] ) ) ] )\n\n#print(data1)\n\n'''\n#optional saving to file\n#import json #optional saving to file\nif not os.path.exists('myobserv.json'):\n with open('myobserv.json', 'w') as f:\n f.writelines(str(data1))\n\nwith open('myobserv.json', 'r') as f:\n data = json.load(f)\nprint(data)\n'''\n\n#ipyleaflet GeoJSON layer\ngeo_json = GeoJSON(data=data1, point_style={'radius': 5, 'color': 'red', 'fillOpacity': 0.8, 'fillColor': 'blue', 'weight': 3})\n\n#print(geo_json1)\n\nm2 = Map(center=center, zoom=zoom)\nm2.add_layer(geo_json)\n\nm2",
"_____no_output_____"
]
],
[
[
"## Get place id from iN",
"_____no_output_____"
]
],
[
[
"#------------------------------\n# import place id from iN\nplace_type = \"Country\" #Type of place to retrieve\nq = \"Poland\" #query value\n\nurl_q = \"https://www.inaturalist.org/places.json?place_type=\" + place_type + \"&q=\" + q\n#print(url_q)\n\n# r - response with place atributes (without geometry -> query)\nr = requests.get(url_q)\n#print(r.json())\n\nplace_id = r.json()[0]['id']\n#print(place_id)\n\n# import observations for spec. taxon and spec. place\n#------------------------------\n\nprint(\"Place name:\", q, \", Place ID: \", place_id)",
"Place name: Poland , Place ID: 7800\n"
]
],
[
[
"## Get observation from iN",
"_____no_output_____"
]
],
[
[
"# Anemonoides nemorosa in Poland\n# get observation from iN\n\n\nt = \"Anemonoides nemorosa\" #taxon name\n\nurl_t = \"https://api.inaturalist.org/v1/observations?\"\nquery_params = {\"place_id\":place_id, \"taxon_name\":t, \"page\": 1 }\n\n#rt = requests.get(url_t, params=query_params)\n#print(rt.json()[\"total_results\"])\n\nobs = [] #observations\n\n#----------\n# inspiracion ane while loop :https://github.com/AgentschapPlantentuinMeise/iNatBioblitzes/blob/main/inat.ipynb\n#----------\n\npage = 1\nwhile True:\n \n #rt - object with observations from one page\n rt = requests.get(url_t, params=query_params)\n\n if page > num_pages: \n print(\"---END---\")\n break\n \n if page == 1:\n num_pages = rt.json()[\"total_results\"] // rt.json()[\"per_page\"] + 1\n\n print(\"Results:\", rt.json()[\"total_results\"], \", \", num_pages, \" pages total\")\n \n print(\"Retrieving page \", url_t + \" page \" + str(page))\n page += 1\n query_params[\"page\"] = page\n \n for i in rt.json()[\"results\"]:\n l = [ float(k) for k in i['location'].split(\",\") ]\n t = tuple(l[::-1] )\n obs.append( t )\n \n #print(t)\n\n time.sleep(1)\n",
"Results: 600 , 21 pages total\nRetrieving page https://api.inaturalist.org/v1/observations? page 1\nRetrieving page https://api.inaturalist.org/v1/observations? page 2\nRetrieving page https://api.inaturalist.org/v1/observations? page 3\nRetrieving page https://api.inaturalist.org/v1/observations? page 4\nRetrieving page https://api.inaturalist.org/v1/observations? page 5\nRetrieving page https://api.inaturalist.org/v1/observations? page 6\nRetrieving page https://api.inaturalist.org/v1/observations? page 7\nRetrieving page https://api.inaturalist.org/v1/observations? page 8\nRetrieving page https://api.inaturalist.org/v1/observations? page 9\nRetrieving page https://api.inaturalist.org/v1/observations? page 10\nRetrieving page https://api.inaturalist.org/v1/observations? page 11\nRetrieving page https://api.inaturalist.org/v1/observations? page 12\nRetrieving page https://api.inaturalist.org/v1/observations? page 13\nRetrieving page https://api.inaturalist.org/v1/observations? page 14\nRetrieving page https://api.inaturalist.org/v1/observations? page 15\nRetrieving page https://api.inaturalist.org/v1/observations? page 16\nRetrieving page https://api.inaturalist.org/v1/observations? page 17\nRetrieving page https://api.inaturalist.org/v1/observations? page 18\nRetrieving page https://api.inaturalist.org/v1/observations? page 19\nRetrieving page https://api.inaturalist.org/v1/observations? page 20\nRetrieving page https://api.inaturalist.org/v1/observations? page 21\n---END---\n"
]
],
[
[
"## Interactive map of iN observations",
"_____no_output_____"
]
],
[
[
"#Anemonoides nemorosa in Poland\n#vizualization\n\n#for i in range(10): print(obs[i]) #test firs 10 values\n \n \nmap_center = [ float(i) for i in [ r.json()[0]['latitude'], r.json()[0]['longitude'] ] ] \n#print(map_center)\n\nm_poland = Map(basemap=basemaps.CartoDB.Positron, center=map_center, zoom=5)\n\n#geoJSON object from observationns\ngeo_obs = FeatureCollection( [ Feature ( geometry=MultiPoint( obs ) ) ] )\n\n#ipyleaflet GeoJSON layer\ngeo_json = GeoJSON(data=geo_obs, point_style={'radius': 5, 'fillOpacity': 1, 'fillColor': 'green', 'weight': 0})\n\nm_poland.add_layer(geo_json )\n\nm_poland\n",
"_____no_output_____"
],
[
"#example from documentation\n#https://ipyleaflet.readthedocs.io/en/latest/api_reference/geo_json.html\n\nimport os\nimport json\nimport random\nimport requests\n\nfrom ipyleaflet import Map, GeoJSON\n\nif not os.path.exists('europe_110.geo.json'):\n url = 'https://github.com/jupyter-widgets/ipyleaflet/raw/master/examples/europe_110.geo.json'\n r = requests.get(url)\n with open('europe_110.geo.json', 'w') as f:\n f.write(r.content.decode(\"utf-8\"))\n\nwith open('europe_110.geo.json', 'r') as f:\n data = json.load(f)\n\ndef random_color(feature):\n return {\n 'color': 'black',\n 'fillColor': random.choice(['red', 'yellow', 'green', 'orange']),\n }\n\nm = Map(center=(50.6252978589571, 0.34580993652344), zoom=3)\n\n#print(data)\n\n\ngeo_json = GeoJSON(\n data=data,\n style={\n 'opacity': 1, 'dashArray': '9', 'fillOpacity': 0.1, 'weight': 1\n },\n hover_style={\n 'color': 'white', 'dashArray': '0', 'fillOpacity': 0.5\n },\n style_callback=random_color\n)\nm.add_layer(geo_json)\n\nm\n",
"_____no_output_____"
],
[
"# https://github.com/jupyter-widgets/ipyleaflet/pull/439#issuecomment-658030755\n\nfrom ipyleaflet import Map, GeoJSON\nm3 = Map(basemap=basemaps.OpenStreetMap.BlackAndWhite, center=(46.91, 7.43), zoom=17)\n\nd = {\n \"type\": \"FeatureCollection\",\n \"features\": [\n {\n \"type\": \"Feature\",\n \"properties\": {},\n \"geometry\": {\n \"type\": \"MultiPoint\",\n \"coordinates\": [\n [\n 7.43, 46.91\n ]\n ]\n }\n }\n ]\n}\n\ngeo_json = GeoJSON(data=d, point_style={'radius': 5, 'fillOpacity': 0.5, 'fillColor': 'green', 'weight': 0})\nm3.add_layer(geo_json)\nm3",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
]
] |
ecad4aba0fd6fdb79aa6bd5f4333e9251ea7b72c | 1,009,046 | ipynb | Jupyter Notebook | Chapter 3b - Hypothesis Test and Confidence Interval.ipynb | MacroAnalyst/Advanced_Quantitative_Methods | bc725b950cbfc1913831de709d919f244bee5df0 | [
"MIT"
] | 1 | 2022-01-13T22:47:31.000Z | 2022-01-13T22:47:31.000Z | Chapter 3b - Hypothesis Test and Confidence Interval.ipynb | MacroAnalyst/Advanced_Econometric_Theory_With_Python | 193abc1dc4008b6ede042a5c4ddf1cda7eb70674 | [
"MIT"
] | null | null | null | Chapter 3b - Hypothesis Test and Confidence Interval.ipynb | MacroAnalyst/Advanced_Econometric_Theory_With_Python | 193abc1dc4008b6ede042a5c4ddf1cda7eb70674 | [
"MIT"
] | 2 | 2022-02-20T16:02:13.000Z | 2022-02-25T20:49:23.000Z | 644.757827 | 304,124 | 0.942873 | [
[
[
"import numpy as np\nimport matplotlib.pyplot as plt\nimport scipy.stats\nimport scipy as sp\nfrom mpl_toolkits.mplot3d import Axes3D\nimport statsmodels.formula.api as smf\nimport linregfunc as lr\nimport pandas as pd\nimport seaborn as sns\n\nplt.style.use('fivethirtyeight')",
"_____no_output_____"
]
],
[
[
"# <font face=\"gotham\" color=\"purple\"> Common Distributions in Hypothesis Testing </font>",
"_____no_output_____"
],
[
"Here we will have a quick refresh of distributions that are commonly used in hypothesis testing. ",
"_____no_output_____"
],
[
"## <font face=\"gotham\" color=\"purple\"> The Normal Distributions </font>",
"_____no_output_____"
],
[
"Normal Distribution is the most important one among all, here we provide a graphic reminder of bivariate normal distribution. Please check out my notebooks of linear algebra, there is a whole chapter devoted for normal distribution.\n\nFor your reference, the pdf of multivariate normal distribution is",
"_____no_output_____"
],
[
"$$\np(\\boldsymbol{x} ; \\mu, \\Sigma)=\\frac{1}{(2 \\pi)^{n / 2}|\\Sigma|^{1 / 2}} \\exp \\left(-\\frac{1}{2}(x-\\mu)^{T} \\Sigma^{-1}(x-\\mu)\\right) \\tag{1}\\label{1}\n$$",
"_____no_output_____"
]
],
[
[
"x = np.linspace(-10,10,500)\ny = np.linspace(-10,10,500)\nX,Y = np.meshgrid(x,y)\n\npos = np.array([X.flatten(),Y.flatten()]).T # two columns matrix\n\nfig = plt.figure(figsize=(14,14))\n\n#########################\nax = fig.add_subplot(221, projection='3d')\n\nmu_x = 0\nmu_y = 0\n\nsigma_x = 3\nsigma_y = 15\nrho = 3\n\nrv = sp.stats.multivariate_normal([mu_x, mu_y], [[sigma_x, rho], [rho, sigma_y]]) # frozen distribution\nax.plot_surface(X, Y, rv.pdf(pos).reshape(500,500),cmap='coolwarm')\n\nax = fig.add_subplot(223)\nax.contour(rv.pdf(pos).reshape(500,500))\nstring1 = r'$\\sigma_x = %.1f$, $\\sigma_y = %.1f$, $\\rho = %.1f$'% (sigma_x, sigma_y, rho)\nax.annotate(text = string1, xy=(0.2, 0.05), xycoords='axes fraction', color = 'r')\n\n####\n\nmu_x = 0\nmu_y = 0\n\nsigma_x = 10\nsigma_y = 4\nrho = 0\n\nrv = sp.stats.multivariate_normal([mu_x, mu_y], [[sigma_x, rho], [rho, sigma_y]]) # frozen distribution\nax = fig.add_subplot(222, projection='3d')\nax.plot_surface(X, Y, rv.pdf(pos).reshape(500,500),cmap='coolwarm')\n\nax = fig.add_subplot(224)\nax.contour(rv.pdf(pos).reshape(500,500))\nstring2 = r'$\\sigma_x = %.1f$, $\\sigma_y = %.1f$, $\\rho = %.1f$'% (sigma_x, sigma_y, rho)\nax.annotate(text = string2, xy=(0.2, 0.05), xycoords='axes fraction', color = 'r')\n#########################\n\nplt.show()",
"_____no_output_____"
]
],
[
[
"Keep in your mind: _any linear combination of normally distributed variables is yet a normal distribution_.",
"_____no_output_____"
],
[
"## <font face=\"gotham\" color=\"purple\"> The Chi-Squared Distribution </font>",
"_____no_output_____"
],
[
"If an $n$-random vector follows $iid$ normal distribution, $\\boldsymbol{z}\\sim N(\\boldsymbol{0}, \\mathbf{I})$. Then the random variable\n\n$$\ny = \\boldsymbol{z}^T\\boldsymbol{z} = \\sum_{i=i}^n z_i^2\n$$\n\nis said to follow the **chi-squared distribution** with $n$ degrees of freedom. Denoted as\n\n$$\ny\\sim\\chi^2(n)\n$$",
"_____no_output_____"
],
[
"The mean is \n\n$$\\mathrm{E}(y)=\\sum_{i=1}^{m} \\mathrm{E}\\left(z_{i}^{2}\\right)=\\sum_{i=1}^{m} 1=m$$\n\nAnd the variance is\n\n$$\\begin{aligned}\n\\operatorname{Var}(y) &=\\sum_{i=1}^{m} \\operatorname{Var}\\left(z_{i}^{2}\\right)=m \\mathrm{E}\\left(\\left(z_{i}^{2}-1\\right)^{2}\\right) \\\\\n&=m \\mathrm{E}\\left(z_{i}^{4}-2 z_{i}^{2}+1\\right)=m(3-2+1)=2 m\n\\end{aligned}$$",
"_____no_output_____"
],
[
"As $n$ increases, the probability density function of $\\chi^2$ approaches the $N(m, 2m)$. Here is the graphic demonstration shows how $\\chi^2$ distribution changes as d.o.f. rises.",
"_____no_output_____"
]
],
[
[
"fig, ax = plt.subplots(figsize = (9, 9))\nx = np.linspace(0, 50, 1000)\nfor i in range(1, 14):\n chi_pdf = sp.stats.chi2.pdf(x, i)\n ax.plot(x, chi_pdf, lw = 3, label = '$\\chi^2 (%.0d)$'%i)\n ax.legend(fontsize = 12)\nax.axis([0, 20, 0, .6])\nplt.show()",
"_____no_output_____"
]
],
[
[
"### <font face=\"gotham\" color=\"purple\"> Quadratic Form of $\\chi^2$ Distribution </font>",
"_____no_output_____"
],
[
"If an $n$-random vector $\\boldsymbol{y} \\sim N(\\boldsymbol{\\mu}, \\Sigma)$ then \n\n$$\n(\\boldsymbol{y} - \\boldsymbol{\\mu})^T\\Sigma^{-1}(\\boldsymbol{y}-\\boldsymbol{\\mu})\\sim \\chi^2(n)\n$$\n\nIf $\\boldsymbol{y} \\sim N(\\boldsymbol{0}, \\Sigma)$ simplifies the expression\n\n$$\n\\boldsymbol{y}^T\\Sigma^{-1}\\boldsymbol{y}\\sim \\chi^2(n)\n$$",
"_____no_output_____"
],
[
"We will show why that holds by using diagonal decomposition. Since the $\\Sigma$ is symmetric, it is orthogonally diagonalizable, \n\n\n$$\n\\Sigma = QDQ^T \n$$\n\nwhere \n\n$$\nD=\\left[\\begin{array}{ccccc}\n\\lambda_{1} & 0 & 0 & \\ldots & 0 \\\\\n0 & \\lambda_{2} & 0 & \\ldots & 0 \\\\\n\\vdots & \\vdots & \\vdots & & \\vdots \\\\\n0 & 0 & 0 & \\ldots & \\lambda_{n}\n\\end{array}\\right]\n$$\n\n$\\lambda$s are eigenvalues. And $Q^{-1} = Q^T$, $Q$ holds all the eigenvectors of $\\Sigma$ which are mutually perpendicular.",
"_____no_output_____"
],
[
"Denote $D^*$ as \n\n$$\nD^* =\n\\left[\\begin{array}{ccccc}\n\\frac{1}{\\sqrt{\\lambda_{1}}} & 0 & 0 & \\ldots & 0 \\\\\n0 & \\frac{1}{\\sqrt{\\lambda_{2}}} & 0 & \\ldots & 0 \\\\\n\\vdots & \\vdots & \\vdots & & \\vdots \\\\\n0 & 0 & 0 & \\ldots & \\frac{1}{\\sqrt{\\lambda_{n}}}\n\\end{array}\\right]\n$$",
"_____no_output_____"
],
[
"Let the matrix $H = QD^*Q^T$, since $H$ is also symmetric\n\n$$\nHH^T= QD^*Q^TQD^*Q^T= Q^TD^*D^*Q = QD^{-1}Q^T =\\Sigma^{-1}\n$$",
"_____no_output_____"
],
[
"Furthermore\n\n$$\nH\\Sigma H^T = QD^*Q^T\\Sigma QD^*Q^T = QD^*Q^TQDQ^T QD^*Q^T = QD^*DD^*Q^T = QQ^T = I\n$$",
"_____no_output_____"
],
[
"Back to the results from above, we set $\\boldsymbol{z} = H^T (\\boldsymbol{y}-\\boldsymbol{\\mu})$, which is standard normal distribution since\n\n$$\nE(\\boldsymbol{z})= H^TE(\\boldsymbol{y}-\\boldsymbol{\\mu})=\\boldsymbol{0}\\\\\n\\text{Var}(\\boldsymbol{z}) = H\\text{Var}(\\boldsymbol{y}-\\boldsymbol{\\mu})H^T =H\\Sigma H^T = I \n$$\n\nBack to where we started\n\n$$\n(\\boldsymbol{y}-\\boldsymbol{\\mu})^T\\Sigma^{-1}(\\boldsymbol{y}-\\boldsymbol{\\mu}) = (\\boldsymbol{y}-\\boldsymbol{\\mu})^THH^T (\\boldsymbol{y}-\\boldsymbol{\\mu}) = (H^T (\\boldsymbol{y}-\\boldsymbol{\\mu}))^T(H^T (\\boldsymbol{y}-\\boldsymbol{\\mu})) = \\boldsymbol{z}^T\\boldsymbol{z}\n$$\n\nhere we proved that $(\\boldsymbol{y}-\\boldsymbol{\\mu})^T\\Sigma^{-1}(\\boldsymbol{y}-\\boldsymbol{\\mu}) \\sim \\chi^2(n)$.",
"_____no_output_____"
],
[
"More details of proof in <a href='https://math.stackexchange.com/questions/2808041/x-normally-distributed-then-xt-sigma-1-x-follows-chi-square-distribut?noredirect=1&lq=1'>this page</a>.\n",
"_____no_output_____"
],
[
"## <font face=\"gotham\" color=\"purple\"> The Student’s $t$ Distribution </font>",
"_____no_output_____"
],
[
"If $z\\sim N(0, 1)$ and $y\\sim \\chi^2(m)$, and $z$ and $y$ are independent, then \n\n$$\nt = \\frac{z}{\\sqrt{y/m}}\n$$\n\nfollows the **Student's t distribution** with $m$ d.o.f. ",
"_____no_output_____"
],
[
"Here is the plot of $t$-distribution, note that $t(1)$ is called **Cauchy distribution** which has no moments at all, because integral does not converge due to fat tails.",
"_____no_output_____"
]
],
[
[
"fig, ax = plt.subplots(figsize = (12, 7))\nx = np.linspace(-5, 5, 1000)\nfor i in range(1, 6):\n chi_pdf = sp.stats.t.pdf(x, i)\n if i == 1:\n ax.plot(x, chi_pdf, lw = 3, label = 'Cauchy', ls = '--')\n continue\n else:\n ax.plot(x, chi_pdf, lw = 3, label = '$t (%.0d)$'%i)\n ax.legend(fontsize = 12)\nax.axis([-5, 5, 0, .4])\nax.set_title(\"Student's $t$ Distribution\", size = 18)\nplt.show()",
"_____no_output_____"
]
],
[
[
"As $m \\rightarrow \\infty$, $t(m)\\rightarrow N(0, 1)$, in the limit process, the tails of $t$ distribution will diminish, and becoming thinner.",
"_____no_output_____"
],
[
"## <font face=\"gotham\" color=\"purple\"> The $F$ Distribution </font>",
"_____no_output_____"
],
[
"If $y_1$ and $y_2$ are independent random variables distributed as $\\chi^2(m_1)$ and $\\chi^2(m_2)$, then the random variable \n\n$$\nF = \\frac{y_1/m_1}{y_2/m_2}\n$$",
"_____no_output_____"
],
[
"follows the **$F$ distribution**, denoted $ F(m_1, m_2)$.",
"_____no_output_____"
]
],
[
[
"x = np.linspace(.001, 5, 100)\nfig, ax = plt.subplots(figsize = (12, 7))\n\ndf1 = 10\ndf2 = 2\nf_pdf = sp.stats.f.pdf(x, dfn = df1, dfd = df2)\nax.plot(x, f_pdf, lw =3, label = '$df_1 = %.d, df_2 = %.d$' %(df1, df2))\n\ndf1 = 2\ndf2 = 10\nf_pdf = sp.stats.f.pdf(x, dfn = df1, dfd = df2)\nax.plot(x, f_pdf, lw =3, label = '$df_1 = %.d, df_2 = %.d$ '%(df1, df2))\n\ndf1 = 8\ndf2 = 15\nf_pdf = sp.stats.f.pdf(x, dfn = df1, dfd = df2)\nax.plot(x, f_pdf, lw =3, color = 'red', label = '$df_1 = %.d, df_2 = %.d$' %(df1, df2))\n\ndf1 = 15\ndf2 = 8\nf_pdf = sp.stats.f.pdf(x, dfn = df1, dfd = df2)\nax.plot(x, f_pdf, lw =3, label = '$df_1 = %.d, df_2 = %.d$ '%(df1, df2))\n\nax.legend(fontsize = 15)\nax.axis([0, 4, 0, .8])\nax.set_title(\"$F$ Distribution\", size = 18)\nplt.show()",
"_____no_output_____"
]
],
[
[
"# <font face=\"gotham\" color=\"purple\">Single Restriction </font>",
"_____no_output_____"
],
[
"Any linear restriction, such as $\\beta_1 = 5$, $\\beta_1 =2{\\beta_2}$ can be tested, however, no loss of generality if linear restriction of $\\beta_2=0$ is demonstrated. \n\nWe first take a look at single restriction, see how FWL regression can help to construct statistic tests. \n\nThe regression model is \n\n$$\n\\boldsymbol{y} = \\boldsymbol{X}_1\\boldsymbol{\\beta}_1+\\beta_2\\boldsymbol{x}_2+\\boldsymbol{u}\n$$\n\nwhere $\\boldsymbol{x}_2$ is an $n$-vector, whereas $\\boldsymbol{X}_1$ is an $n\\times (m-1)$ matrix. ",
"_____no_output_____"
],
[
"Project $\\boldsymbol{X}_1$ off $\\boldsymbol{x}_2$, the FWL regression is\n\n$$\n\\boldsymbol{M}_1\\boldsymbol{y} = \\beta_2\\boldsymbol{M}_1\\boldsymbol{x}_2 + \\boldsymbol{M}_1\\boldsymbol{u}\n$$",
"_____no_output_____"
],
[
"Applying OLS estimate and variance formula,\n\n$$\n\\hat{\\beta}_2 = [(\\boldsymbol{M}_1\\boldsymbol{x}_2)^T\\boldsymbol{M}_1\\boldsymbol{x}_2]^{-1}(\\boldsymbol{M}_1\\boldsymbol{x}_2)^T\\boldsymbol{M}_1\\boldsymbol{y}=(\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2)^{-1}\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{y}=\\frac{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{y}}{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2}\\\\\n\\text{Var}(\\hat{\\beta}_2) = \\sigma^2 [(\\boldsymbol{M}_1\\boldsymbol{x}_2)^T(\\boldsymbol{M}_1\\boldsymbol{x}_2)]^{-1} = \\sigma^2(\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2)^{-1}\n$$",
"_____no_output_____"
],
[
"If null hypothesis is $\\beta_2^0=0$, also assuming that $\\sigma^2$ is known. Construct a $z$-statistic\n\n$$\nz_{\\beta_2} = \\frac{\\hat{\\beta}_2}\n{\\sqrt{\\text{Var}(\\hat{\\beta}_2)}}=\\frac{\\frac{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{y}}{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2}}{ \\sigma(\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2)^{-\\frac{1}{2}}}\n= \\frac{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{y}}{\\sigma(\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2)^{\\frac{1}{2}}}\n$$",
"_____no_output_____"
],
[
"However, $\\sigma$ is not likely to be known, hence we replace it with $s$, the least square standard error estimator. Recall that \n\n$$\ns^2 =\\frac{1}{n-k} \\sum_{t=1}^n u_t^2 = \\frac{\\boldsymbol{u}^T\\boldsymbol{u}}{n-k}= \\frac{(\\boldsymbol{M_X y})^T\\boldsymbol{M_X y}}{n-k}=\\frac{\\boldsymbol{y}^T\\boldsymbol{M_X y}}{n-k}\n$$",
"_____no_output_____"
],
[
"Replace the $\\sigma$ in $z_{\\beta_2}$, we obtain $t$-statistic\n\n$$\nt_{\\beta_2} = \\frac{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{y}}{s(\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2)^{\\frac{1}{2}}} = \\left(\\frac{\\boldsymbol{y}^T\\boldsymbol{M_X y}}{n-k}\\right)^{-\\frac{1}{2}}\\frac{\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{y}}{(\\boldsymbol{x}_2^T\\boldsymbol{M}_1\\boldsymbol{x}_2)^{\\frac{1}{2}}}\n$$",
"_____no_output_____"
],
[
"Of course we can also show it indeed follows the $t$ distribution by using the definition that the ratio of standard normal variable to a $\\chi^2$ variable. However, this is unnecessary for us.",
"_____no_output_____"
],
[
"# <font face=\"gotham\" color=\"purple\"> Multiple Restrictions </font>",
"_____no_output_____"
],
[
"Multiple restrictions test can be formulated as following\n\n$$\nH_0:\\quad \\boldsymbol{y} = \\boldsymbol{X}_1\\boldsymbol{\\beta_1} + \\boldsymbol{u}\\\\\nH_1:\\quad \\boldsymbol{y} = \\boldsymbol{X}_1\\boldsymbol{\\beta_1} +\\boldsymbol{X}_2\\boldsymbol{\\beta_2}+ \\boldsymbol{u}\n$$",
"_____no_output_____"
],
[
"$H_0$ is restricted model, $H_1$ is unrestricted. And we denote restricted residual sum of squares as $\\text{RRSS}$, and unrestricted residual sum of squares as $\\text{URSS}$, the test statistic is \n\n$$\nF_{\\beta_2}= \\frac{(\\text{RRSS}-\\text{URSS})/r}{\\text{URSS}/(n-k)}\n$$",
"_____no_output_____"
],
[
"where $r=k_2$, the number of restrictions on $\\beta_2$.\n\nUsing FWL regression with $\\boldsymbol{M}_1$ and $\\text{TSS = ESS + RSS}$, \n\n$$\n\\boldsymbol{M}_1\\boldsymbol{y}=\\boldsymbol{M}_1\\boldsymbol{X}_2\\boldsymbol{\\beta}_2+\\boldsymbol{u} \\tag{FWL regression}\n$$\n\n\\begin{align}\n\\text{URSS}& =(\\boldsymbol{M_1y})^T\\boldsymbol{M_1y}- \\underbrace{\\left[\\boldsymbol{M}_1\\boldsymbol{X}_2[(\\boldsymbol{M}_1\\boldsymbol{X}_2)^T\\boldsymbol{M}_1\\boldsymbol{X}_2]^{-1}(\\boldsymbol{M}_1\\boldsymbol{X}_2)^T\\boldsymbol{y}\\right]^T}_{\\text{projection matrix}\\ P}\\boldsymbol{y}\\\\\n &= \\boldsymbol{y}^T\\boldsymbol{M}_1\\boldsymbol{y} -\\boldsymbol{y}^T\\boldsymbol{M}_1\\boldsymbol{X}_2(\\boldsymbol{X}_2^T\\boldsymbol{M}_1\\boldsymbol{X}_2)^{-1}\\boldsymbol{X}^T_2\\boldsymbol{M}_1 \\boldsymbol{y} = \\boldsymbol{y}^T\\boldsymbol{M_X}\\boldsymbol{y}\n\\end{align}",
"_____no_output_____"
],
[
"$$\n\\text{RRSS} = (\\boldsymbol{M}_1y)^T\\boldsymbol{M}_1y = \\boldsymbol{y}^T\\boldsymbol{M}_1\\boldsymbol{y}\n$$",
"_____no_output_____"
],
[
"Therefore\n$$\n\\text{RRSS}-\\text{URSS}=\\boldsymbol{y}^T\\boldsymbol{M}_1\\boldsymbol{X}_2(\\boldsymbol{X}_2^T\\boldsymbol{M}_1\\boldsymbol{X}_2)^{-1}\\boldsymbol{X}^T_2\\boldsymbol{M}_1 \\boldsymbol{y}\n$$",
"_____no_output_____"
],
[
"We have all parts of $F$ statistic, combine them\n\n$$\nF_{\\boldsymbol{\\beta}_{2}}=\\frac{\\boldsymbol{y}^{T} \\boldsymbol{M}_{1} \\boldsymbol{X}_{2}\\left(\\boldsymbol{X}_{2}^{T} \\boldsymbol{M}_{1} \\boldsymbol{X}_{2}\\right)^{-1} \\boldsymbol{X}_{2}^{T} \\boldsymbol{M}_{1} \\boldsymbol{y} / r}{\\boldsymbol{y}^{T} \\boldsymbol{M}_{\\boldsymbol{X}} \\boldsymbol{y} /(n-k)}\n$$",
"_____no_output_____"
],
[
"In contrast, $t$ statistic will be\n$$\nt_{\\beta_{2}}=\\sqrt{\\frac{\\boldsymbol{y}^{\\top} \\boldsymbol{M}_{1} \\boldsymbol{x}_{2}\\left(\\boldsymbol{x}_{2}^{\\top} \\boldsymbol{M}_{1} \\boldsymbol{x}_{2}\\right)^{-1} \\boldsymbol{x}_{2}^{\\top} \\boldsymbol{M}_{1} \\boldsymbol{y}}{\\boldsymbol{y}^{\\top} \\boldsymbol{M}_{\\boldsymbol{X}} \\boldsymbol{y} /(n-k)}}\n$$",
"_____no_output_____"
],
[
"To test the equality of two parameter vectors, we modify the $F$ test as\n$$\nF_{\\gamma}=\\frac{\\left(\\mathrm{RRSS}-\\mathrm{RSS}_{1}-\\mathrm{RSS}_{2}\\right) / k}{\\left(\\mathrm{RSS}_{1}+\\mathrm{RSS}_{2}\\right) /(n-2 k)}\n$$\nfor example, the sample being divided into two subsamples, to compare the stability of two subsamples, this so-called **Chow test** is a common practice.",
"_____no_output_____"
],
[
"# <font face=\"gotham\" color=\"purple\"> Asymptotic Theory </font>",
"_____no_output_____"
],
[
"**Asymptotic Theory** is concerned with the distribution of estimators and test statistics as the sample size $n$ tends to infinity.",
"_____no_output_____"
],
[
"## <font face=\"gotham\" color=\"purple\"> Law of Large Numbers </font>",
"_____no_output_____"
],
[
"The widely-known **Law of Large Numbers** ($\\text{LLN}$) takes the form\n$$\n\\bar{x} = \\frac{1}{n}\\sum_{t=1}^nx_t\n$$\nwhere $x_t$ are independent variables with its own bounded variance $\\sigma_t^2$ and a common mean $\\mu$. $\\text{LLN}$ tells that as $n\\rightarrow \\infty$, then $\\bar{x} \\rightarrow \\mu$.\n\nThe **Fundamental Theorem of Statistics** can be proved with $\\text{LLN}$.\n\nAn **empirical distribution function** ($\\text{EDF}$) can be expressed as\n$$\n\\hat{F}(x) \\equiv \\frac{1}{n} \\sum_{t=1}^{n} I\\left(x_{t} \\leq x\\right)\n$$\nwhere $I(\\cdot)$ is an **indicator function**, which takes value $1$ when its argument is true, otherwise $0$. To prove the Fundamental Theorem of Statistics, we invoke the $\\text{LLN}$, expand the expectation",
"_____no_output_____"
],
[
"\\begin{aligned}\n\\mathrm{E}\\left(I\\left(x_{t} \\leq x\\right)\\right) &=0 \\cdot \\operatorname{Pr}\\left(I\\left(x_{t} \\leq x\\right)=0\\right)+1 \\cdot \\operatorname{Pr}\\left(I\\left(x_{t} \\leq x\\right)=1\\right) \\\\\n&=\\operatorname{Pr}\\left(I\\left(x_{t} \\leq x\\right)=1\\right)=\\operatorname{Pr}\\left(x_{t} \\leq x\\right)=F(x)\n\\end{aligned}",
"_____no_output_____"
],
[
"It turns out that $\\hat{F}(x)$ is a consistent estimator of $F(x)$.",
"_____no_output_____"
],
[
"## <font face=\"gotham\" color=\"purple\"> Central Limit Theorems </font>",
"_____no_output_____"
],
[
"The **Central Limit Theorems** ($\\text{CLT}$) tells that $\\frac{1}{n}$ times the sum of $n$ centered random variables will approximately follow a normal distribution when $n$ is sufficiently large. The most well $\\text{CLT}$ is **Lindeberg-Lévy** $\\text{CLT}$, the quantity\n$$\nz \\equiv \\frac{1}{\\sqrt{n}} \\sum_{t=1}^{n} \\frac{x_{t}-\\mu}{\\sigma}\n$$\nis **asymptotically distributed** as $N(0,1)$.",
"_____no_output_____"
],
[
"We won't bother to prove them, but they are the implicit theoretical foundation when we are discussing **simulation-based tests**.",
"_____no_output_____"
],
[
"# <font face=\"gotham\" color=\"purple\"> Bootstrapping </font>",
"_____no_output_____"
],
[
"The bootstrapping is a computational technique for handling small size sample or any sample that doesn't follow any known distribution. \n\nIt's rare to see it in classical linear regression model, since the sampling distribution of coefficients follow normal distribution if disturbance terms follow normal distribution.\n\nHowever, for demonstration purpose, we will show how a bootstrap test is perform. The model is a simple linear regression\n$$\nY_t = 5 + 6 X_t + 10u_t\n$$\nwhere $u_t\\sim N(0, 1)$.",
"_____no_output_____"
],
[
"Generate $Y$ and $X$ then pass them to a data frame.",
"_____no_output_____"
]
],
[
[
"ols_obj = lr.OLS_Simu(100, 2, [5, 6], 10)",
"_____no_output_____"
],
[
"bootstr_params_const, bootstr_params_1 = [], []\nnr_bootstrp = 100",
"_____no_output_____"
],
[
"df = pd.DataFrame(ols_obj.X)\ndf['y'] = ols_obj.y\ndf.columns = ['const', 'x1', 'y']",
"_____no_output_____"
],
[
"resample_size = 100",
"_____no_output_____"
]
],
[
[
"Repetitively sample from the generated dataframe and estimate parameters.",
"_____no_output_____"
]
],
[
[
"fig, ax = plt.subplots(figsize=(18, 8), nrows=1, ncols=3)\nfor i in range(nr_bootstrp):\n df_resample = df.sample(resample_size, replace=True)\n ols_fit = smf.ols(formula = 'y ~ x1', data = df_resample).fit()\n bootstrap_params = ols_fit.params\n bootstr_params_const.append(bootstrap_params[0])\n bootstr_params_1.append(bootstrap_params[1])\n y_pred_temp = ols_fit.predict(df_resample['x1'])\n ax[0].plot(df_resample['x1'], y_pred_temp, alpha=0.2)\nax[0].set_title('Bootstrap Regression Plot')\nax[1].hist(bootstr_params_const, bins=30)\nax[1].set_title(r'$\\beta_1$')\nax[2].hist(bootstr_params_1, bins=30)\nax[2].set_title(r'$\\beta_2$')\nplt.show()",
"_____no_output_____"
]
],
[
[
"# <font face=\"gotham\" color=\"purple\"> Confidence Interval </font>",
"_____no_output_____"
],
[
"A **confidence interval** for some parameter $\\theta$ consists all values of $\\theta_0$ that can't be rejected by corresponding hypothesis. If the finite-sample distribution is known, we have an **exact confidence interval** $[\\theta_l, \\theta_u]$, of which $\\theta_l$ and $\\theta_u$ represents lower and upper limit. ",
"_____no_output_____"
],
[
"For instance, we have a test statistic\n$$\n\\tau\\left(\\boldsymbol{y}, \\theta_{0}\\right) \\equiv\\frac{\\hat{\\theta}-\\theta_{0}}{s_{\\theta}}\n$$",
"_____no_output_____"
],
[
"Here $\\boldsymbol{y}$ denotes the sample used to compute the particular realization of the statistic, $\\hat{\\theta}$ is the estimate of $\\theta$ and $s_\\theta$ is the corresponding standard error. The confidence interval can be found by solving the equation\n$$\n\\tau(\\boldsymbol{y}, \\theta)=c_{\\alpha}\n$$",
"_____no_output_____"
],
[
"where $c_\\alpha$ is the critical value with significance level $\\alpha$. Solve\n$$\n\\frac{\\hat{\\theta}-\\theta}{s_{\\theta}}=c_{\\alpha}\n$$",
"_____no_output_____"
],
[
"Two solutions are \n$$\n\\theta_{l}=\\hat{\\theta}-s_{\\theta} c_{\\alpha} \\quad \\text { and } \\quad \\theta_{u}=\\hat{\\theta}+s_{\\theta} c_{\\alpha}\n$$\nThe confidence interval is \n$$\n[\\hat{\\theta}-s_{\\theta} c_{\\alpha},\\quad \\hat{\\theta}+s_{\\theta} c_{\\alpha}]\n$$",
"_____no_output_____"
],
[
"To obtain critical values, it is convenient to use cumulative distribution function, e.g. the common critical value of $t$-statistic is $\\pm 1.96$ assuming a large degree of freedom. ",
"_____no_output_____"
]
],
[
[
"sp.stats.t.ppf([0.025, 0.975], df=1000)",
"_____no_output_____"
]
],
[
[
"If you wish to have the same mass on each side of the distribution, the quantiles are $\\frac{\\alpha}{2}$ and $1-\\frac{\\alpha}{2}$.",
"_____no_output_____"
],
[
"For a linear regression model\n$$\n\\operatorname{Pr}\\left(t_{\\alpha / 2} \\leq \\frac{\\hat{\\beta}-\\beta}{s} \\leq t_{1-(\\alpha / 2)}\\right)=1-\\alpha\n$$\nSolve it, we get\n$$\n\\operatorname{Pr}\\left(\\hat{\\beta}_{2}-s_{2} t_{\\alpha / 2} \\geq \\beta_{20} \\geq \\hat{\\beta}_{2}-s_{2} t_{1-(\\alpha / 2)}\\right)\n$$",
"_____no_output_____"
],
[
"Or more intuitively written as\n$$\n[\\hat{\\beta}_{2}-s_{2} t_{1-(\\alpha / 2)}, \\quad \\hat{\\beta}_{2}+s_{2} t_{1-(\\alpha / 2)}]\n$$",
"_____no_output_____"
]
],
[
[
"df = pd.read_excel('Basic_Econometrics_practice_data.xlsx', sheet_name='US_CobbDauglas')\ndf.columns = ('Area', 'Output', 'Labour', 'Capital')\nols_obj_fit = smf.ols(formula='np.log(Output) ~ np.log(Labour) + np.log(Capital)', data=df).fit()",
"_____no_output_____"
],
[
"print(ols_obj_fit.summary())",
" OLS Regression Results \n==============================================================================\nDep. Variable: np.log(Output) R-squared: 0.964\nModel: OLS Adj. R-squared: 0.963\nMethod: Least Squares F-statistic: 645.9\nDate: Fri, 18 Mar 2022 Prob (F-statistic): 2.00e-35\nTime: 14:16:17 Log-Likelihood: -3.4267\nNo. Observations: 51 AIC: 12.85\nDf Residuals: 48 BIC: 18.65\nDf Model: 2 \nCovariance Type: nonrobust \n===================================================================================\n coef std err t P>|t| [0.025 0.975]\n-----------------------------------------------------------------------------------\nIntercept 3.8876 0.396 9.812 0.000 3.091 4.684\nnp.log(Labour) 0.4683 0.099 4.734 0.000 0.269 0.667\nnp.log(Capital) 0.5213 0.097 5.380 0.000 0.326 0.716\n==============================================================================\nOmnibus: 45.645 Durbin-Watson: 1.946\nProb(Omnibus): 0.000 Jarque-Bera (JB): 196.024\nSkew: 2.336 Prob(JB): 2.72e-43\nKurtosis: 11.392 Cond. No. 201.\n==============================================================================\n\nNotes:\n[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
],
[
"ols_obj_fit.conf_int()[0]",
"_____no_output_____"
],
[
"ols_obj_fit.conf_int()",
"_____no_output_____"
]
],
[
[
"# <font face=\"gotham\" color=\"purple\"> Full Session of Bootstrapping </font>",
"_____no_output_____"
]
],
[
[
"df = pd.read_excel('Basic_Econometrics_practice_data.xlsx', sheet_name='US_CobbDauglas')\ndf.columns = ('Area', 'Output', 'Labour', 'Capital')\nols_obj_fit = smf.ols(formula='np.log(Output) ~ np.log(Labour) + np.log(Capital)', data=df).fit()",
"_____no_output_____"
],
[
"print(ols_obj_fit.summary())",
" OLS Regression Results \n==============================================================================\nDep. Variable: np.log(Output) R-squared: 0.964\nModel: OLS Adj. R-squared: 0.963\nMethod: Least Squares F-statistic: 645.9\nDate: Fri, 18 Mar 2022 Prob (F-statistic): 2.00e-35\nTime: 14:16:17 Log-Likelihood: -3.4267\nNo. Observations: 51 AIC: 12.85\nDf Residuals: 48 BIC: 18.65\nDf Model: 2 \nCovariance Type: nonrobust \n===================================================================================\n coef std err t P>|t| [0.025 0.975]\n-----------------------------------------------------------------------------------\nIntercept 3.8876 0.396 9.812 0.000 3.091 4.684\nnp.log(Labour) 0.4683 0.099 4.734 0.000 0.269 0.667\nnp.log(Capital) 0.5213 0.097 5.380 0.000 0.326 0.716\n==============================================================================\nOmnibus: 45.645 Durbin-Watson: 1.946\nProb(Omnibus): 0.000 Jarque-Bera (JB): 196.024\nSkew: 2.336 Prob(JB): 2.72e-43\nKurtosis: 11.392 Cond. No. 201.\n==============================================================================\n\nNotes:\n[1] Standard Errors assume that the covariance matrix of the errors is correctly specified.\n"
],
[
"len(ols_obj_fit.params)",
"_____no_output_____"
],
[
"ols_obj_fit.params['Intercept']",
"_____no_output_____"
],
[
"ols_obj_fit.conf_int()[0]",
"_____no_output_____"
],
[
"ols_obj_fit.conf_int()",
"_____no_output_____"
],
[
"formula='np.log(Output) ~ np.log(Labour) + np.log(Capital)'\n# number of bootstrap rounds\nB = 2000 \n\n# placeholder matrix B rows and k columns\nresults_bootrp = np.zeros((B, len(ols_obj_fit.params))) \n\n# row id range\nrow_id = range(0, df.shape[0]) \n\nfor i in range(B):\n # this samples with replacement from rows\n this_sample = np.random.choice(row_id, size=df.shape[0], \n replace=True) # gives sampled row numbers\n # Define data for this replicate: \n df_bootstrp = df.iloc[this_sample] \n # Estimate model\n params_bootstrp = smf.ols(formula, data=df_bootstrp).fit().params\n # Store in row r of results_boot:\n results_bootrp[i, :] = params_bootstrp ",
"_____no_output_____"
],
[
"results_bootrp = pd.DataFrame(results_bootrp, columns = ['Intercept', 'Labour', 'Capital'])",
"_____no_output_____"
],
[
"results_bootrp",
"_____no_output_____"
],
[
"x_range = np.arange(B)\nfig, ax = plt.subplots(figsize=(18, 12), nrows=3, ncols=2)\nax[0, 0].plot(x_range, results_bootrp['Intercept'], lw=1)\nax[0, 1].hist( results_bootrp['Intercept'], bins=50 ,orientation='horizontal')\n\nax[1, 0].plot(x_range, results_bootrp['Labour'], lw=1)\nax[1, 1].hist( results_bootrp['Labour'], bins=50 ,orientation='horizontal')\n\nax[2, 0].plot(x_range, results_bootrp['Capital'], lw=1)\nax[2, 1].hist( results_bootrp['Capital'], bins=50 ,orientation='horizontal')\nplt.show()",
"_____no_output_____"
],
[
"g = sns.PairGrid(results_bootrp)\ng.fig.set_size_inches(12,12)\ng.map_diag(sns.kdeplot)\ng.map_lower(sns.kdeplot, cmap=\"Blues_d\")\ng.map_upper(sns.scatterplot)\nplt.show()",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecad4f8763a4c8f76fb85a67b936818f3b388817 | 11,812 | ipynb | Jupyter Notebook | Loop_Statement.ipynb | paulfrancis24/CPEN-21A-CPE-1-2 | 770c447575dc90691367a86342fa720f228d03f1 | [
"Apache-2.0"
] | null | null | null | Loop_Statement.ipynb | paulfrancis24/CPEN-21A-CPE-1-2 | 770c447575dc90691367a86342fa720f228d03f1 | [
"Apache-2.0"
] | null | null | null | Loop_Statement.ipynb | paulfrancis24/CPEN-21A-CPE-1-2 | 770c447575dc90691367a86342fa720f228d03f1 | [
"Apache-2.0"
] | null | null | null | 21.282883 | 241 | 0.352269 | [
[
[
"<a href=\"https://colab.research.google.com/github/paulfrancis24/CPEN-21A-CPE-1-2/blob/main/Loop_Statement.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>",
"_____no_output_____"
],
[
"##For Loop",
"_____no_output_____"
]
],
[
[
"week = [\"Sunday\", \"Monday\", \"Tuesday\", \"Wednesday\", \"Thursday\", \"Friday\", \"Saturday\"]\n\nfor x in week:\n print(x)",
"Sunday\nMonday\nTuesday\nWednesday\nThursday\nFriday\nSaturday\n"
]
],
[
[
"##The Break Statement",
"_____no_output_____"
]
],
[
[
"for x in week:\n print(x)\n if x == \"Thursday\":\n break",
"Sunday\nMonday\nTuesday\nWednesday\nThursday\n"
]
],
[
[
"##The Break Statement",
"_____no_output_____"
]
],
[
[
"for x in week:\n if x == \"Thursday\":\n break\n print(x)",
"Sunday\nMonday\nTuesday\nWednesday\n"
]
],
[
[
"##Looping through String",
"_____no_output_____"
]
],
[
[
"for x in \"Programming with Python\":\n print(x)",
"P\nr\no\ng\nr\na\nm\nm\ni\nn\ng\n \nw\ni\nt\nh\n \nP\ny\nt\nh\no\nn\n"
]
],
[
[
"##The range function",
"_____no_output_____"
]
],
[
[
"for x in range(10):\n print(x)",
"0\n1\n2\n3\n4\n5\n6\n7\n8\n9\n"
]
],
[
[
"##Nested Loop",
"_____no_output_____"
]
],
[
[
"adjective = [\"red\", \"big\", \"tasty\"]\nfruits = [\"apple\", \"banana\", \"cherry\"]\n\nfor x in adjective:\n for y in fruits:\n print(x, y)",
"red apple\nred banana\nred cherry\nbig apple\nbig banana\nbig cherry\ntasty apple\ntasty banana\ntasty cherry\n"
]
],
[
[
"##While loop",
"_____no_output_____"
]
],
[
[
"i = 10\n\nwhile i>6:\n print(i)\n i -= 1",
"10\n9\n8\n7\n"
]
],
[
[
"##The break statement",
"_____no_output_____"
]
],
[
[
"i = 10\n\nwhile i>6:\n print(i)\n if i==8:\n break\n i -= 1",
"10\n9\n8\n"
]
],
[
[
"##The continue statement",
"_____no_output_____"
]
],
[
[
"i = 10\n\nwhile i > 6:\n i -= 1\n if i == 8:\n continue\n print(i)\n",
"9\n7\n6\n"
]
],
[
[
"##The else statement",
"_____no_output_____"
]
],
[
[
"i = 10\n\nwhile i > 6:\n i = i-1\n print(i)\nelse:\n print(\"i is no longer greater than 6\")",
"9\n8\n7\n6\ni is no longer greater than 6\n"
]
],
[
[
"##Application 1",
"_____no_output_____"
]
],
[
[
"x = [\"Value\"]\ny = 0\nfor x in x:\n while y <= 10:\n print(x, y)\n y = y+1\n",
"Value 0\nValue 1\nValue 2\nValue 3\nValue 4\nValue 5\nValue 6\nValue 7\nValue 8\nValue 9\nValue 10\n"
]
],
[
[
"##Application 2",
"_____no_output_____"
]
],
[
[
"i = 20\nwhile i>4:\n i-= 1\n if i == 3:\n break\n print(i)\nelse:\n print(\"i is no longer greater than 3\")\n ",
"19\n18\n17\n16\n15\n14\n13\n12\n11\n10\n9\n8\n7\n6\n5\n4\ni is no longer greater than 3\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecad83cc0fd98527f78e931403fbfbf37a72194f | 20,191 | ipynb | Jupyter Notebook | docs/examples/general/expressions/expr_type_promotions.ipynb | npanpaliya/DALI | dc13d3b9d1a2fe67931b05a2861e81cd50da4d2b | [
"ECL-2.0",
"Apache-2.0"
] | 11 | 2021-03-16T05:09:16.000Z | 2022-03-29T12:48:44.000Z | docs/examples/general/expressions/expr_type_promotions.ipynb | npanpaliya/DALI | dc13d3b9d1a2fe67931b05a2861e81cd50da4d2b | [
"ECL-2.0",
"Apache-2.0"
] | null | null | null | docs/examples/general/expressions/expr_type_promotions.ipynb | npanpaliya/DALI | dc13d3b9d1a2fe67931b05a2861e81cd50da4d2b | [
"ECL-2.0",
"Apache-2.0"
] | 3 | 2021-05-08T16:51:55.000Z | 2021-07-22T09:02:44.000Z | 39.054159 | 397 | 0.541875 | [
[
[
"# DALI binary arithmetic operators - type promotions\n\nIn this example, we will describe the rules regarding type promotions for binary arithmetic operators in DALI. Details on using arithmetic operators in DALI can be found in \"DALI expressions and arithmetic operators\" notebook.",
"_____no_output_____"
],
[
"## Prepare the test pipeline\n\nFirst, we will prepare the helper code, so we can easily manipulate the types and values that will appear as tensors in the DALI pipeline.\n\nWe use `from __future__ import division` to allow `/` and `//` as true division and floor division operators.\nWe will be using numpy as source for the custom provided data and we also need to import several things from DALI, needed to create Pipeline and use ExternalSource Operator. ",
"_____no_output_____"
]
],
[
[
"from __future__ import division\nimport numpy as np\nfrom nvidia.dali.pipeline import Pipeline\nimport nvidia.dali.ops as ops \nimport nvidia.dali.types as types\nfrom nvidia.dali.types import Constant\n\nbatch_size = 1",
"_____no_output_____"
]
],
[
[
"### Defining the data\n\nAs we are dealing with binary operators, we need two inputs. \nWe will create a simple helper function that returns two numpy arrays of given numpy types with arbitrary selected values. It is to make the manipulation of types easy. In an actual scenario the data processed by DALI arithmetic operators would be tensors produced by other Operator containing some images, video sequences or other data.\n\nKeep in mind that shapes of both inputs need to match as those will be element-wise operations. ",
"_____no_output_____"
]
],
[
[
"left_magic_values = [42, 8]\nright_magic_values = [9, 2]\n\ndef get_data(left_type, right_type):\n return ([left_type(left_magic_values)], [right_type(right_magic_values)])\n\nbatch_size = 1",
"_____no_output_____"
]
],
[
[
"### Defining the pipeline\n\nThe next step is to define the Pipeline. We override `Pipeline.iter_setup`, a method called by the pipeline before every `Pipeline.run`. It is meant to feed the data into `ExternalSource()` operators indicated by `self.left` and `self.right`.\nThe data will be obtained from `get_data` function to which we pass the left and right types. \n\nNote, that we do not need to instantiate any additional operators, we can use regular Python arithmetic expressions on the results of other operators in the `define_graph` step.\n\nFor convenience, we'll wrap the usage of arithmetic operations in a lambda called `operation`, specified when creating the pipeline.\n\n`define_graph` will return both our data inputs and the result of applying `operation` to them.",
"_____no_output_____"
]
],
[
[
" class ArithmeticPipeline(Pipeline): \n def __init__(self, operation, left_type, right_type, batch_size, num_threads, device_id):\n super(ArithmeticPipeline, self).__init__(batch_size, num_threads, device_id, seed=12)\n self.left_source = ops.ExternalSource()\n self.right_source = ops.ExternalSource()\n self.operation = operation\n self.left_type = left_type\n self.right_type = right_type\n\n def define_graph(self): \n self.left = self.left_source()\n self.right = self.right_source()\n return self.left, self.right, self.operation(self.left, self.right)\n\n def iter_setup(self):\n (l, r) = get_data(self.left_type, self.right_type)\n self.feed_input(self.left, l)\n self.feed_input(self.right, r)",
"_____no_output_____"
]
],
[
[
"## Type promotion rules\n\nType promotions for binary operators are described below. The type promotion rules are commutative. They apply to `+`, `-`, `*`, and `//`. The `/` always returns a float32 for integer inputs, and applies the rules below when at least one of the inputs is a floating point number.\n\n| Operand Type | Operand Type | Result Type | Additional Conditions |\n|:------------:|:------------:|:-----------:| --------------------- |\n| T | T | T | |\n| floatX | T | floatX | where T is not a float |\n| floatX | floatY | float(max(X, Y)) | |\n| intX | intY | int(max(X, Y)) | |\n| uintX | uintY | uint(max(X, Y)) | |\n| intX | uintY | int2Y | if X <= Y |\n| intX | uintY | intX | if X > Y |\n\n`bool` type is considered the smallest unsigned integer type and is treated as `uint1` with respect to the table above.\n\nThe bitwise binary `|`, `&`, and `^` operations abide by the same type promotion rules as arithmetic binary operations, but their inputs are restricted to integral types (bool included).\n\nOnly multiplication `*` and bitwise operations `|`, `&`, `^` can accept two `bool` inputs.",
"_____no_output_____"
],
[
"### Using the Pipeline\n\nLet's create a Pipeline that adds two tensors of type `uint8`, run it and see the results.",
"_____no_output_____"
]
],
[
[
"def build_and_run(pipe, op_name):\n pipe.build() \n pipe_out = pipe.run()\n l = pipe_out[0].as_array()\n r = pipe_out[1].as_array()\n out = pipe_out[2].as_array()\n print(\"{} {} {} = {}; \\n\\twith types {} {} {} -> {}\\n\".format(l, op_name, r, out, l.dtype, op_name, r.dtype, out.dtype))\n \npipe = ArithmeticPipeline((lambda x, y: x + y), np.uint8, np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run(pipe, \"+\")",
"[[42 8]] + [[9 2]] = [[51 10]]; \n\twith types uint8 + uint8 -> uint8\n\n"
]
],
[
[
"Let's see how all of the operators behave with different type combinations by generalizing the example above.\nYou can use the `np_types` or `np_int_types` in the loops to see all possible type combinations. To reduce the output we limit ourselves to only few of them. We also set some additional printing options for numpy to make the output more aligned.",
"_____no_output_____"
]
],
[
[
"np.set_printoptions(precision=2)",
"_____no_output_____"
],
[
"arithmetic_operations = [((lambda x, y: x + y) , \"+\"), ((lambda x, y: x - y) , \"-\"),\n ((lambda x, y: x * y) , \"*\"), ((lambda x, y: x / y) , \"/\"),\n ((lambda x, y: x // y) , \"//\")]\n\nbitwise_operations = [((lambda x, y: x | y) , \"|\"), ((lambda x, y: x & y) , \"&\"),\n ((lambda x, y: x ^ y) , \"^\")]\n\nnp_types = [np.int8, np.int16, np.int32, np.int64, \n np.uint8, np.uint16, np.uint32, np.uint64,\n np.float32, np.float64]\n\nfor (op, op_name) in arithmetic_operations:\n for left_type in [np.uint8]:\n for right_type in [np.uint8, np.int32, np.float32]:\n pipe = ArithmeticPipeline(op, left_type, right_type, batch_size=batch_size, num_threads=2, device_id = 0)\n build_and_run(pipe, op_name)\n \nfor (op, op_name) in bitwise_operations:\n for left_type in [np.uint8]:\n for right_type in [np.uint8, np.int32]:\n pipe = ArithmeticPipeline(op, left_type, right_type, batch_size=batch_size, num_threads=2, device_id = 0)\n build_and_run(pipe, op_name)\n ",
"[[42 8]] + [[9 2]] = [[51 10]]; \n\twith types uint8 + uint8 -> uint8\n\n[[42 8]] + [[9 2]] = [[51 10]]; \n\twith types uint8 + int32 -> int32\n\n[[42 8]] + [[9. 2.]] = [[51. 10.]]; \n\twith types uint8 + float32 -> float32\n\n[[42 8]] - [[9 2]] = [[33 6]]; \n\twith types uint8 - uint8 -> uint8\n\n[[42 8]] - [[9 2]] = [[33 6]]; \n\twith types uint8 - int32 -> int32\n\n[[42 8]] - [[9. 2.]] = [[33. 6.]]; \n\twith types uint8 - float32 -> float32\n\n[[42 8]] * [[9 2]] = [[122 16]]; \n\twith types uint8 * uint8 -> uint8\n\n[[42 8]] * [[9 2]] = [[378 16]]; \n\twith types uint8 * int32 -> int32\n\n[[42 8]] * [[9. 2.]] = [[378. 16.]]; \n\twith types uint8 * float32 -> float32\n\n[[42 8]] / [[9 2]] = [[4.67 4. ]]; \n\twith types uint8 / uint8 -> float32\n\n[[42 8]] / [[9 2]] = [[4.67 4. ]]; \n\twith types uint8 / int32 -> float32\n\n[[42 8]] / [[9. 2.]] = [[4.67 4. ]]; \n\twith types uint8 / float32 -> float32\n\n[[42 8]] // [[9 2]] = [[4 4]]; \n\twith types uint8 // uint8 -> uint8\n\n[[42 8]] // [[9 2]] = [[4 4]]; \n\twith types uint8 // int32 -> int32\n\n[[42 8]] // [[9. 2.]] = [[4.67 4. ]]; \n\twith types uint8 // float32 -> float32\n\n[[42 8]] | [[9 2]] = [[43 10]]; \n\twith types uint8 | uint8 -> uint8\n\n[[42 8]] | [[9 2]] = [[43 10]]; \n\twith types uint8 | int32 -> int32\n\n[[42 8]] & [[9 2]] = [[8 0]]; \n\twith types uint8 & uint8 -> uint8\n\n[[42 8]] & [[9 2]] = [[8 0]]; \n\twith types uint8 & int32 -> int32\n\n[[42 8]] ^ [[9 2]] = [[35 10]]; \n\twith types uint8 ^ uint8 -> uint8\n\n[[42 8]] ^ [[9 2]] = [[35 10]]; \n\twith types uint8 ^ int32 -> int32\n\n"
]
],
[
[
"## Using Constants\n\nInstead of operating only on Tensor data, DALI expressions can also work with constants. Those can be either values of Python `int` and `float` types used directly, or those values wrapped in `nvidia.dali.types.Constant`. Operation between tensor and constant results in the constant being broadcasted to all elements of the tensor. The same costant is used with all samples in the batch.\n\n*Note: Currently all values of integral constants are passed to DALI as int32 and all values of floating point constants are passed to DALI as float32.*\n\nThe Python `int` values will be treated as `int32` and the `float` as `float32` in regard to type promotions.\n\nThe DALI `Constant` can be used to indicate other types. It accepts `DALIDataType` enum values as second argument and has convenience member functions like `.uint8()` or `.float32()` that can be used for conversions.\n\nAs our expressions will consist of a tensor and a constant, we will adjust our previous pipeline and the helper functions - they only need to generate one tensor.",
"_____no_output_____"
]
],
[
[
"class ArithmeticConstantsPipeline(Pipeline): \n def __init__(self, operation, tensor_data_type,batch_size, num_threads, device_id):\n super(ArithmeticConstantsPipeline, self).__init__(batch_size, num_threads, device_id, seed=12)\n self.tensor_source = ops.ExternalSource()\n self.operation = operation\n self.tensor_data_type = tensor_data_type\n\n def define_graph(self): \n self.tensor = self.tensor_source()\n return self.tensor, self.operation(self.tensor)\n\n def iter_setup(self):\n (t, _) = get_data(self.tensor_data_type, self.tensor_data_type)\n self.feed_input(self.tensor, t)\n \ndef build_and_run_with_const(pipe, op_name, constant, is_const_left = False):\n pipe.build() \n pipe_out = pipe.run()\n t_in = pipe_out[0].as_array()\n t_out = pipe_out[1].as_array()\n if is_const_left:\n print(\"{} {} {} = \\n{}; \\n\\twith types {} {} {} -> {}\\n\".format(constant, op_name, t_in, t_out, type(constant), op_name, t_in.dtype, t_out.dtype))\n else:\n print(\"{} {} {} = \\n{}; \\n\\twith types {} {} {} -> {}\\n\".format(t_in, op_name, constant, t_out, t_in.dtype, op_name, type(constant), t_out.dtype))\n",
"_____no_output_____"
]
],
[
[
"Now, the `ArithmeticConstantsPipeline` can be parametrized with a function taking the only tensor and returning the result of arithmetic operation between that tensor and a constant.\n\nWe also adjusted our print message.\n\nNow we will check all the examples we mentioned at the beginning: `int`, `float` constants and `nvidia.dali.types.Constant`.",
"_____no_output_____"
]
],
[
[
"constant = 10\npipe = ArithmeticConstantsPipeline((lambda x: x + constant), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"+\", constant)\n\nconstant = 10\npipe = ArithmeticConstantsPipeline((lambda x: x + constant), np.float32, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"+\", constant)\n\n\nconstant = 42.3\npipe = ArithmeticConstantsPipeline((lambda x: x + constant), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"+\", constant)\n\nconstant = 42.3\npipe = ArithmeticConstantsPipeline((lambda x: x + constant), np.float32, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"+\", constant)\n",
"[[42 8]] + 10 = \n[[52 18]]; \n\twith types uint8 + <class 'int'> -> int32\n\n[[42. 8.]] + 10 = \n[[52. 18.]]; \n\twith types float32 + <class 'int'> -> float32\n\n[[42 8]] + 42.3 = \n[[84.3 50.3]]; \n\twith types uint8 + <class 'float'> -> float32\n\n[[42. 8.]] + 42.3 = \n[[84.3 50.3]]; \n\twith types float32 + <class 'float'> -> float32\n\n"
]
],
[
[
"As we can see the value of the constant is applied to all the elements of the tensor to which it is added.\n\nNow let's check how to use the DALI Constant wrapper.\n\nPassing an `int` or `float` to DALI Constant marks it as `int32` or `float32` respectively",
"_____no_output_____"
]
],
[
[
"constant = Constant(10)\npipe = ArithmeticConstantsPipeline((lambda x: x * constant), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"*\", constant)\n\n\nconstant = Constant(10.0)\npipe = ArithmeticConstantsPipeline((lambda x: constant * x), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"*\", constant, True)",
"[[42 8]] * 10:DALIDataType.INT32 = \n[[420 80]]; \n\twith types uint8 * <class 'nvidia.dali.types.Constant'> -> int32\n\n10.0:DALIDataType.FLOAT * [[42 8]] = \n[[420. 80.]]; \n\twith types <class 'nvidia.dali.types.Constant'> * uint8 -> float32\n\n"
]
],
[
[
"We can either explicitly specify the type as a second argument, or use convenience conversion member functions.",
"_____no_output_____"
]
],
[
[
"constant = Constant(10, types.DALIDataType.UINT8)\npipe = ArithmeticConstantsPipeline((lambda x: x * constant), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"*\", constant)\n\n\nconstant = Constant(10.0, types.DALIDataType.UINT8)\npipe = ArithmeticConstantsPipeline((lambda x: constant * x), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"*\", constant, True)\n\n\nconstant = Constant(10).uint8()\npipe = ArithmeticConstantsPipeline((lambda x: constant * x), np.uint8, batch_size = batch_size, num_threads = 2, device_id = 0)\nbuild_and_run_with_const(pipe, \"*\", constant, True)",
"[[42 8]] * 10:DALIDataType.UINT8 = \n[[164 80]]; \n\twith types uint8 * <class 'nvidia.dali.types.Constant'> -> uint8\n\n10:DALIDataType.UINT8 * [[42 8]] = \n[[164 80]]; \n\twith types <class 'nvidia.dali.types.Constant'> * uint8 -> uint8\n\n10:DALIDataType.UINT8 * [[42 8]] = \n[[164 80]]; \n\twith types <class 'nvidia.dali.types.Constant'> * uint8 -> uint8\n\n"
]
],
[
[
"## Treating tensors as scalars\n\nIf one of the tensors is considered a scalar input, the same rules apply.\n",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
]
] |
ecad86927f15862519d61c0434d1c20c982883f6 | 257,335 | ipynb | Jupyter Notebook | march_2022_research/obstical_avoid.ipynb | yunethitsar/Obstacle-avoiding-robot | 6bb84dcad982942b155c5d02d89665a04031fde6 | [
"MIT"
] | null | null | null | march_2022_research/obstical_avoid.ipynb | yunethitsar/Obstacle-avoiding-robot | 6bb84dcad982942b155c5d02d89665a04031fde6 | [
"MIT"
] | null | null | null | march_2022_research/obstical_avoid.ipynb | yunethitsar/Obstacle-avoiding-robot | 6bb84dcad982942b155c5d02d89665a04031fde6 | [
"MIT"
] | null | null | null | 138.874798 | 46,200 | 0.653149 | [
[
[
"!pip install numpy",
"Requirement already satisfied: numpy in ./pyenv/lib/python3.8/site-packages (1.22.3)\n"
],
[
"!pip install tensorflow\n!pip install gym\n!pip install matplotlib\n!pip install opencv-python",
"Requirement already satisfied: tensorflow in ./pyenv/lib/python3.8/site-packages (2.8.0)\nRequirement already satisfied: gast>=0.2.1 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (0.5.3)\nRequirement already satisfied: keras-preprocessing>=1.1.1 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.1.2)\nRequirement already satisfied: tensorboard<2.9,>=2.8 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (2.8.0)\nRequirement already satisfied: libclang>=9.0.1 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (13.0.0)\nRequirement already satisfied: astunparse>=1.6.0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.6.3)\nRequirement already satisfied: google-pasta>=0.1.1 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (0.2.0)\nRequirement already satisfied: numpy>=1.20 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.22.3)\nRequirement already satisfied: tf-estimator-nightly==2.8.0.dev2021122109 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (2.8.0.dev2021122109)\nRequirement already satisfied: tensorflow-io-gcs-filesystem>=0.23.1 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (0.24.0)\nRequirement already satisfied: flatbuffers>=1.12 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (2.0)\nRequirement already satisfied: termcolor>=1.1.0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.1.0)\nRequirement already satisfied: wrapt>=1.11.0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.14.0)\nRequirement already satisfied: h5py>=2.9.0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (3.6.0)\nRequirement already satisfied: opt-einsum>=2.3.2 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (3.3.0)\nRequirement already satisfied: typing-extensions>=3.6.6 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (4.1.1)\nRequirement already satisfied: grpcio<2.0,>=1.24.3 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.44.0)\nRequirement already satisfied: setuptools in ./pyenv/lib/python3.8/site-packages (from tensorflow) (44.0.0)\nRequirement already satisfied: protobuf>=3.9.2 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (3.19.4)\nRequirement already satisfied: six>=1.12.0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.16.0)\nRequirement already satisfied: keras<2.9,>=2.8.0rc0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (2.8.0)\nRequirement already satisfied: absl-py>=0.4.0 in ./pyenv/lib/python3.8/site-packages (from tensorflow) (1.0.0)\nRequirement already satisfied: google-auth<3,>=1.6.3 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (2.6.2)\nRequirement already satisfied: werkzeug>=0.11.15 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (2.0.3)\nRequirement already satisfied: google-auth-oauthlib<0.5,>=0.4.1 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (0.4.6)\nRequirement already satisfied: requests<3,>=2.21.0 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (2.27.1)\nRequirement already satisfied: markdown>=2.6.8 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (3.3.6)\nRequirement already satisfied: tensorboard-plugin-wit>=1.6.0 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (1.8.1)\nRequirement already satisfied: tensorboard-data-server<0.7.0,>=0.6.0 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (0.6.1)\nRequirement already satisfied: wheel>=0.26 in ./pyenv/lib/python3.8/site-packages (from tensorboard<2.9,>=2.8->tensorflow) (0.37.1)\nRequirement already satisfied: rsa<5,>=3.1.4; python_version >= \"3.6\" in ./pyenv/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (4.8)\nRequirement already satisfied: cachetools<6.0,>=2.0.0 in ./pyenv/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (5.0.0)\nRequirement already satisfied: pyasn1-modules>=0.2.1 in ./pyenv/lib/python3.8/site-packages (from google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (0.2.8)\nRequirement already satisfied: requests-oauthlib>=0.7.0 in ./pyenv/lib/python3.8/site-packages (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.9,>=2.8->tensorflow) (1.3.1)\nRequirement already satisfied: certifi>=2017.4.17 in ./pyenv/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.9,>=2.8->tensorflow) (2021.10.8)\nRequirement already satisfied: charset-normalizer~=2.0.0; python_version >= \"3\" in ./pyenv/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.9,>=2.8->tensorflow) (2.0.12)\nRequirement already satisfied: idna<4,>=2.5; python_version >= \"3\" in ./pyenv/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.9,>=2.8->tensorflow) (3.3)\nRequirement already satisfied: urllib3<1.27,>=1.21.1 in ./pyenv/lib/python3.8/site-packages (from requests<3,>=2.21.0->tensorboard<2.9,>=2.8->tensorflow) (1.26.9)\nRequirement already satisfied: importlib-metadata>=4.4; python_version < \"3.10\" in ./pyenv/lib/python3.8/site-packages (from markdown>=2.6.8->tensorboard<2.9,>=2.8->tensorflow) (4.11.3)\nRequirement already satisfied: pyasn1>=0.1.3 in ./pyenv/lib/python3.8/site-packages (from rsa<5,>=3.1.4; python_version >= \"3.6\"->google-auth<3,>=1.6.3->tensorboard<2.9,>=2.8->tensorflow) (0.4.8)\nRequirement already satisfied: oauthlib>=3.0.0 in ./pyenv/lib/python3.8/site-packages (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.9,>=2.8->tensorflow) (3.2.0)\nRequirement already satisfied: zipp>=0.5 in ./pyenv/lib/python3.8/site-packages (from importlib-metadata>=4.4; python_version < \"3.10\"->markdown>=2.6.8->tensorboard<2.9,>=2.8->tensorflow) (3.7.0)\nRequirement already satisfied: gym in ./pyenv/lib/python3.8/site-packages (0.23.1)\nRequirement already satisfied: gym-notices>=0.0.4 in ./pyenv/lib/python3.8/site-packages (from gym) (0.0.6)\nRequirement already satisfied: cloudpickle>=1.2.0 in ./pyenv/lib/python3.8/site-packages (from gym) (2.0.0)\nRequirement already satisfied: numpy>=1.18.0 in ./pyenv/lib/python3.8/site-packages (from gym) (1.22.3)\nRequirement already satisfied: importlib-metadata>=4.10.0; python_version < \"3.10\" in ./pyenv/lib/python3.8/site-packages (from gym) (4.11.3)\nRequirement already satisfied: zipp>=0.5 in ./pyenv/lib/python3.8/site-packages (from importlib-metadata>=4.10.0; python_version < \"3.10\"->gym) (3.7.0)\nRequirement already satisfied: matplotlib in ./pyenv/lib/python3.8/site-packages (3.5.1)\nRequirement already satisfied: kiwisolver>=1.0.1 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (1.4.0)\nRequirement already satisfied: pyparsing>=2.2.1 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (3.0.7)\nRequirement already satisfied: numpy>=1.17 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (1.22.3)\nRequirement already satisfied: packaging>=20.0 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (21.3)\nRequirement already satisfied: python-dateutil>=2.7 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (2.8.2)\nRequirement already satisfied: cycler>=0.10 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (0.11.0)\nRequirement already satisfied: fonttools>=4.22.0 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (4.31.2)\nRequirement already satisfied: pillow>=6.2.0 in ./pyenv/lib/python3.8/site-packages (from matplotlib) (9.0.1)\nRequirement already satisfied: six>=1.5 in ./pyenv/lib/python3.8/site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)\nRequirement already satisfied: opencv-python in ./pyenv/lib/python3.8/site-packages (4.5.5.64)\nRequirement already satisfied: numpy>=1.14.5; python_version >= \"3.7\" in ./pyenv/lib/python3.8/site-packages (from opencv-python) (1.22.3)\n"
],
[
"#!pip install tensorflow",
"_____no_output_____"
],
[
"#!sudo apt-get install ffmpeg libsm6 libxext6 -y",
"_____no_output_____"
],
[
"import numpy as np \nimport cv2 \nimport matplotlib.pyplot as plt\nimport PIL.Image as Image\nimport gym\nimport random\nimport math\nfrom gym import Env, spaces\nimport time\nfont = cv2.FONT_HERSHEY_COMPLEX_SMALL ",
"_____no_output_____"
],
[
"class Point(object):\n def __init__(self, name, x_max, x_min, y_max, y_min):\n self.x = 0\n self.y = 0\n self.x_min = x_min\n self.x_max = x_max\n self.y_min = y_min\n self.y_max = y_max\n self.name = name\n \n def set_position(self, x, y):\n self.x = self.clamp(x, self.x_min, self.x_max - self.icon_w)\n self.y = self.clamp(y, self.y_min, self.y_max - self.icon_h)\n \n def get_position(self):\n return (self.x, self.y)\n \n def move(self, del_x, del_y):\n self.x += del_x\n self.y += del_y\n \n self.x = self.clamp(self.x, self.x_min, self.x_max - self.icon_w)\n self.y = self.clamp(self.y, self.y_min, self.y_max - self.icon_h)\n\n def clamp(self, n, minn, maxn):\n return max(min(maxn, n), minn)",
"_____no_output_____"
],
[
"class Robot(Point):\n def __init__(self, name, x_max, x_min, y_max, y_min):\n super(Robot, self).__init__(name, x_max, x_min, y_max, y_min)\n self.icon = cv2.imread(\"robot.PNG\") / 255.0\n self.icon_w = 20\n self.icon_h = 20\n self.icon = cv2.resize(self.icon, (self.icon_h, self.icon_w))",
"_____no_output_____"
],
[
"class Obstical(Point):\n def __init__(self, name, x_max, x_min, y_max, y_min):\n super(Obstical, self).__init__(name, x_max, x_min, y_max, y_min)\n self.icon = cv2.imread(\"building.png\") / 255.0\n self.icon_w = 20\n self.icon_h = 20\n self.icon = cv2.resize(self.icon, (self.icon_h, self.icon_w))\n ",
"_____no_output_____"
],
[
"class Flag(Point):\n def __init__(self, name, x_max, x_min, y_max, y_min):\n super(Flag, self).__init__(name, x_max, x_min, y_max, y_min)\n self.icon = cv2.imread(\"flag.PNG\") / 255.0\n self.icon_w = 32\n self.icon_h = 32\n self.icon = cv2.resize(self.icon, (self.icon_h, self.icon_w))",
"_____no_output_____"
],
[
"class Robot_Env(Env):\n def __init__(self):\n super(Robot_Env, self).__init__()\n \n # Define a 2-D observation space\n self.observation_shape = (400, 400, 3)\n self.observation_space = spaces.Box(low = np.zeros(self.observation_shape), \n high = np.ones(self.observation_shape),\n dtype = np.float16)\n \n # Define an action space ranging from 0 to 4\n self.action_space = spaces.Discrete(6,)\n \n # Create a canvas to render the environment images upon \n self.canvas = np.ones(self.observation_shape) * 1\n \n self.elements = []\n self.max_fuel = 300\n \n \n self.y_min = int (self.observation_shape[0] * 0.1)\n self.x_min = 0\n self.y_max = int (self.observation_shape[0] * 0.9)\n self.x_max = self.observation_shape[1]\n \n \n \n def step(self, action):\n done = False\n assert self.action_space.contains(action), \"Invalid Action\"\n # Decrease the fuel counter \n self.fuel_left -= 1 \n # Reward for executing a step.\n \n \n \n if action == 0:\n self.robot.move(0,5)\n elif action == 1:\n self.robot.move(0,-5)\n elif action == 2:\n self.robot.move(5,0)\n elif action == 3:\n self.robot.move(-5,0)\n elif action == 4:\n self.robot.move(0,0)\n \n \n \n \n \n reward = 0 \n \n for elem in self.elements:\n ## check robot hit building\n if isinstance(elem, Obstical):\n if self.has_collided(self.robot, elem):\n # Conclude the episode and remove the chopper from the Env.\n done = True\n reward = -10\n #self.elements.remove(self.robot)\n\n elif isinstance(elem, Flag):\n if self.has_collided(self.robot, elem):\n done = True\n reward = 100\n self.elements.remove(self.robot)\n\n else:\n robot_x, robot_y = self.robot.get_position()\n goal_x,goal_y = elem.get_position()\n dist = math.sqrt((goal_x -robot_x)**2+(goal_y-robot_y)**2)\n reward = (1/dist) * 1000\n \n \n\n \n \n # Increment the episodic return\n self.ep_return += reward\n \n # Draw elements on the canvas\n self.draw_elements_on_canvas()\n \n # If out of fuel, end the episode.\n if self.fuel_left == 0:\n done = True\n\n return self.canvas, reward, done, []\n \n \n \n \n def reset(self):\n # Reset the fuel consumed\n self.fuel_left = self.max_fuel\n\n # Reset the reward\n self.ep_return = 0\n \n \n # Number of birds\n self.obstical_count = 0\n \n \n x = random.randrange(int(self.observation_shape[0] * 0.05), int(self.observation_shape[0] * 0.10))\n y = random.randrange(int(self.observation_shape[1] * 0.15), int(self.observation_shape[1] * 0.20))\n \n self.robot = Robot(\"Robot\", self.x_max, self.x_min, self.y_max, self.y_min)\n self.robot.set_position(x,y)\n \n \n # Intialise the elements \n self.elements = [self.robot]\n \n \n # Reset the Canvas \n self.canvas = np.ones(self.observation_shape) * 1\n\n # Draw elements on the canvas\n self.draw_elements_on_canvas()\n\n\n # return the observation\n return self.canvas \n \n \n \n def set_obsticals(self,points):\n for obstical_x, obstical_y in points:\n obstical_obj = Obstical(\"obstical_{}\".format(self.obstical_count), self.x_max, self.x_min, self.y_max, self.y_min) \n obstical_obj.set_position(obstical_x, obstical_y)\n self.elements.append(obstical_obj)\n self.draw_elements_on_canvas()\n return self.canvas\n\n def set_goal(self,points):\n for flag_x, flag_y in points:\n flag_obj = Flag(\"flag_{}\".format(self.obstical_count), self.x_max, self.x_min, self.y_max, self.y_min) \n flag_obj.set_position(flag_x, flag_y)\n self.elements.append(flag_obj)\n self.draw_elements_on_canvas()\n return self.canvas\n \n def draw_elements_on_canvas(self):\n # Init the canvas \n self.canvas = np.ones(self.observation_shape) * 1\n\n # Draw the heliopter on canvas\n for elem in self.elements:\n elem_shape = elem.icon.shape\n x,y = elem.x, elem.y\n self.canvas[y : y + elem_shape[1], x:x + elem_shape[0]] = elem.icon\n\n text = 'Fuel Left: {} | Rewards: {}'.format(self.fuel_left, self.ep_return)\n\n # Put the info on canvas \n self.canvas = cv2.putText(self.canvas, text, (10,20), font, \n 0.8, (0,0,0), 1, cv2.LINE_AA)\n \n def get_action_meanings(self):\n return {0: \"Right\", 1: \"Left\", 2: \"Down\", 3: \"Up\", 4: \"Do Nothing\"}\n \n def render(self, mode = \"human\"):\n assert mode in [\"human\", \"rgb_array\"], \"Invalid mode, must be either \\\"human\\\" or \\\"rgb_array\\\"\"\n if mode == \"human\":\n cv2.imshow(\"Ukraine attack on russia\", self.canvas)\n cv2.waitKey(10)\n\n elif mode == \"rgb_array\":\n return self.canvas\n \n def close(self):\n cv2.destroyAllWindows()\n \n def has_collided(self, elem1, elem2):\n x_col = False\n y_col = False\n\n elem1_x, elem1_y = elem1.get_position()\n elem2_x, elem2_y = elem2.get_position()\n\n if 2 * abs(elem1_x - elem2_x) <= (elem1.icon_w + elem2.icon_w):\n x_col = True\n\n if 2 * abs(elem1_y - elem2_y) <= (elem1.icon_h + elem2.icon_h):\n y_col = True\n\n if x_col and y_col:\n return True\n\n return False",
"_____no_output_____"
],
[
"env = Robot_Env()\nobs = env.reset()\nplt.figure(figsize=(10, 10))\nplt.imshow(obs)",
"_____no_output_____"
],
[
"full_obstacle_list = [ (200,100), (400,150),(400, 110), \n (430, 390), (201, 304), (135, 281), \n (286, 373), (175, 280), (250, 375), (139, 327), (369, 278), \n (295, 196), (210, 111),(110,110)]",
"_____no_output_____"
],
[
"obstical_env = env.set_obsticals(full_obstacle_list)\nplt.figure(figsize=(10, 10))\nplt.imshow(obstical_env)",
"_____no_output_____"
],
[
"goal_pos = [[700,700]]\nobstical_env = env.set_goal(goal_pos)\nplt.figure(figsize=(8, 8))\nplt.imshow(obstical_env)",
"_____no_output_____"
],
[
"from IPython import display\n\nenv = Robot_Env()\nobs = env.reset()\n\ngoal_pos = [[380,380]]\nfull_obstacle_list = [ (200,100), (400,150),(400, 110), \n (430, 390), (201, 304), (135, 281), \n (286, 373), (175, 280), (250, 375), (139, 327), (369, 278), \n (295, 196), (210, 111),(110,110)]\n\n\nenv.set_obsticals(full_obstacle_list)\nenv.set_goal(goal_pos)\n\n\nwhile True:\n # Take a random action\n action = env.action_space.sample()\n obs, reward, done, info = env.step(action)\n \n # Render the game\n #env.render()\n \n if done == True:\n break\n\nenv.close()",
"_____no_output_____"
],
[
"def pre_process(image_frame):\n \n \n I = image_frame[20:] # Crop\n \n #print(\"Croped Image size : \",I.shape)\n I = cv2.resize(I,(128,128))\n return I.astype(np.float32)",
"_____no_output_____"
],
[
"\"\"\"\naction = env.action_space.sample()\nobs, reward, done, info = env.step(action)\nprint(\"Action : \",action)\nprint(\"Reward : \",reward)\nprint(\"is done : \",done)\nprint(\"info : \",info)\nprint(\"Image size : \",obs.shape)\nplt.imshow(obs)\n\"\"\"",
"_____no_output_____"
],
[
"test_img = obs\npre_process_img = pre_process(test_img)\nprint(\"Pre process image : \",pre_process_img.shape)\nplt.imshow(pre_process_img)",
"Pre process image : (128, 128, 3)\n"
],
[
"n_actions = 5\nMAX_ITERS= 2000\nlearning_rate=1e-3\nIMG_SIZE = 128",
"_____no_output_____"
],
[
"#!pip install tensorflow",
"_____no_output_____"
],
[
"import tensorflow as tf",
"_____no_output_____"
],
[
"def create_model():\n pre_train = tf.keras.applications.InceptionV3(include_top=False, weights=None,input_shape= (IMG_SIZE, IMG_SIZE,3))\n x= pre_train.output\n x = tf.keras.layers.GlobalAveragePooling2D()(x)\n x = tf.keras.layers.Dropout(0.25)(x)\n x = tf.keras.layers.Dense(1024, activation=\"relu\",name='hidden_layer1')(x)\n x = tf.keras.layers.Dense(1024, activation=\"relu\",name='hidden_layer2')(x)\n x = tf.keras.layers.Dropout(0.5)(x)\n x = tf.keras.layers.Dense(512, activation=\"relu\",name='hidden_layer3')(x)\n x = tf.keras.layers.Dense(512, activation=\"relu\",name='hidden_layer4')(x)\n preds =tf.keras.layers.Dense(n_actions,activation='sigmoid', name='output')(x)\n model=tf.keras.Model(inputs=pre_train.input,outputs=preds)\n return model",
"_____no_output_____"
],
[
"model = create_model()\noptimizer = tf.keras.optimizers.Adam(learning_rate)\nmodel.summary()",
"Model: \"model_1\"\n__________________________________________________________________________________________________\n Layer (type) Output Shape Param # Connected to \n==================================================================================================\n input_2 (InputLayer) [(None, 128, 128, 3 0 [] \n )] \n \n conv2d_94 (Conv2D) (None, 63, 63, 32) 864 ['input_2[0][0]'] \n \n batch_normalization_94 (BatchN (None, 63, 63, 32) 96 ['conv2d_94[0][0]'] \n ormalization) \n \n activation_94 (Activation) (None, 63, 63, 32) 0 ['batch_normalization_94[0][0]'] \n \n conv2d_95 (Conv2D) (None, 61, 61, 32) 9216 ['activation_94[0][0]'] \n \n batch_normalization_95 (BatchN (None, 61, 61, 32) 96 ['conv2d_95[0][0]'] \n ormalization) \n \n activation_95 (Activation) (None, 61, 61, 32) 0 ['batch_normalization_95[0][0]'] \n \n conv2d_96 (Conv2D) (None, 61, 61, 64) 18432 ['activation_95[0][0]'] \n \n batch_normalization_96 (BatchN (None, 61, 61, 64) 192 ['conv2d_96[0][0]'] \n ormalization) \n \n activation_96 (Activation) (None, 61, 61, 64) 0 ['batch_normalization_96[0][0]'] \n \n max_pooling2d_4 (MaxPooling2D) (None, 30, 30, 64) 0 ['activation_96[0][0]'] \n \n conv2d_97 (Conv2D) (None, 30, 30, 80) 5120 ['max_pooling2d_4[0][0]'] \n \n batch_normalization_97 (BatchN (None, 30, 30, 80) 240 ['conv2d_97[0][0]'] \n ormalization) \n \n activation_97 (Activation) (None, 30, 30, 80) 0 ['batch_normalization_97[0][0]'] \n \n conv2d_98 (Conv2D) (None, 28, 28, 192) 138240 ['activation_97[0][0]'] \n \n batch_normalization_98 (BatchN (None, 28, 28, 192) 576 ['conv2d_98[0][0]'] \n ormalization) \n \n activation_98 (Activation) (None, 28, 28, 192) 0 ['batch_normalization_98[0][0]'] \n \n max_pooling2d_5 (MaxPooling2D) (None, 13, 13, 192) 0 ['activation_98[0][0]'] \n \n conv2d_102 (Conv2D) (None, 13, 13, 64) 12288 ['max_pooling2d_5[0][0]'] \n \n batch_normalization_102 (Batch (None, 13, 13, 64) 192 ['conv2d_102[0][0]'] \n Normalization) \n \n activation_102 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_102[0][0]']\n \n conv2d_100 (Conv2D) (None, 13, 13, 48) 9216 ['max_pooling2d_5[0][0]'] \n \n conv2d_103 (Conv2D) (None, 13, 13, 96) 55296 ['activation_102[0][0]'] \n \n batch_normalization_100 (Batch (None, 13, 13, 48) 144 ['conv2d_100[0][0]'] \n Normalization) \n \n batch_normalization_103 (Batch (None, 13, 13, 96) 288 ['conv2d_103[0][0]'] \n Normalization) \n \n activation_100 (Activation) (None, 13, 13, 48) 0 ['batch_normalization_100[0][0]']\n \n activation_103 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_103[0][0]']\n \n average_pooling2d_9 (AveragePo (None, 13, 13, 192) 0 ['max_pooling2d_5[0][0]'] \n oling2D) \n \n conv2d_99 (Conv2D) (None, 13, 13, 64) 12288 ['max_pooling2d_5[0][0]'] \n \n conv2d_101 (Conv2D) (None, 13, 13, 64) 76800 ['activation_100[0][0]'] \n \n conv2d_104 (Conv2D) (None, 13, 13, 96) 82944 ['activation_103[0][0]'] \n \n conv2d_105 (Conv2D) (None, 13, 13, 32) 6144 ['average_pooling2d_9[0][0]'] \n \n batch_normalization_99 (BatchN (None, 13, 13, 64) 192 ['conv2d_99[0][0]'] \n ormalization) \n \n batch_normalization_101 (Batch (None, 13, 13, 64) 192 ['conv2d_101[0][0]'] \n Normalization) \n \n batch_normalization_104 (Batch (None, 13, 13, 96) 288 ['conv2d_104[0][0]'] \n Normalization) \n \n batch_normalization_105 (Batch (None, 13, 13, 32) 96 ['conv2d_105[0][0]'] \n Normalization) \n \n activation_99 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_99[0][0]'] \n \n activation_101 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_101[0][0]']\n \n activation_104 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_104[0][0]']\n \n activation_105 (Activation) (None, 13, 13, 32) 0 ['batch_normalization_105[0][0]']\n \n mixed0 (Concatenate) (None, 13, 13, 256) 0 ['activation_99[0][0]', \n 'activation_101[0][0]', \n 'activation_104[0][0]', \n 'activation_105[0][0]'] \n \n conv2d_109 (Conv2D) (None, 13, 13, 64) 16384 ['mixed0[0][0]'] \n \n batch_normalization_109 (Batch (None, 13, 13, 64) 192 ['conv2d_109[0][0]'] \n Normalization) \n \n activation_109 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_109[0][0]']\n \n conv2d_107 (Conv2D) (None, 13, 13, 48) 12288 ['mixed0[0][0]'] \n \n conv2d_110 (Conv2D) (None, 13, 13, 96) 55296 ['activation_109[0][0]'] \n \n batch_normalization_107 (Batch (None, 13, 13, 48) 144 ['conv2d_107[0][0]'] \n Normalization) \n \n batch_normalization_110 (Batch (None, 13, 13, 96) 288 ['conv2d_110[0][0]'] \n Normalization) \n \n activation_107 (Activation) (None, 13, 13, 48) 0 ['batch_normalization_107[0][0]']\n \n activation_110 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_110[0][0]']\n \n average_pooling2d_10 (AverageP (None, 13, 13, 256) 0 ['mixed0[0][0]'] \n ooling2D) \n \n conv2d_106 (Conv2D) (None, 13, 13, 64) 16384 ['mixed0[0][0]'] \n \n conv2d_108 (Conv2D) (None, 13, 13, 64) 76800 ['activation_107[0][0]'] \n \n conv2d_111 (Conv2D) (None, 13, 13, 96) 82944 ['activation_110[0][0]'] \n \n conv2d_112 (Conv2D) (None, 13, 13, 64) 16384 ['average_pooling2d_10[0][0]'] \n \n batch_normalization_106 (Batch (None, 13, 13, 64) 192 ['conv2d_106[0][0]'] \n Normalization) \n \n batch_normalization_108 (Batch (None, 13, 13, 64) 192 ['conv2d_108[0][0]'] \n Normalization) \n \n batch_normalization_111 (Batch (None, 13, 13, 96) 288 ['conv2d_111[0][0]'] \n Normalization) \n \n batch_normalization_112 (Batch (None, 13, 13, 64) 192 ['conv2d_112[0][0]'] \n Normalization) \n \n activation_106 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_106[0][0]']\n \n activation_108 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_108[0][0]']\n \n activation_111 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_111[0][0]']\n \n activation_112 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_112[0][0]']\n \n mixed1 (Concatenate) (None, 13, 13, 288) 0 ['activation_106[0][0]', \n 'activation_108[0][0]', \n 'activation_111[0][0]', \n 'activation_112[0][0]'] \n \n conv2d_116 (Conv2D) (None, 13, 13, 64) 18432 ['mixed1[0][0]'] \n \n batch_normalization_116 (Batch (None, 13, 13, 64) 192 ['conv2d_116[0][0]'] \n Normalization) \n \n activation_116 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_116[0][0]']\n \n conv2d_114 (Conv2D) (None, 13, 13, 48) 13824 ['mixed1[0][0]'] \n \n conv2d_117 (Conv2D) (None, 13, 13, 96) 55296 ['activation_116[0][0]'] \n \n batch_normalization_114 (Batch (None, 13, 13, 48) 144 ['conv2d_114[0][0]'] \n Normalization) \n \n batch_normalization_117 (Batch (None, 13, 13, 96) 288 ['conv2d_117[0][0]'] \n Normalization) \n \n activation_114 (Activation) (None, 13, 13, 48) 0 ['batch_normalization_114[0][0]']\n \n activation_117 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_117[0][0]']\n \n average_pooling2d_11 (AverageP (None, 13, 13, 288) 0 ['mixed1[0][0]'] \n ooling2D) \n \n conv2d_113 (Conv2D) (None, 13, 13, 64) 18432 ['mixed1[0][0]'] \n \n conv2d_115 (Conv2D) (None, 13, 13, 64) 76800 ['activation_114[0][0]'] \n \n conv2d_118 (Conv2D) (None, 13, 13, 96) 82944 ['activation_117[0][0]'] \n \n conv2d_119 (Conv2D) (None, 13, 13, 64) 18432 ['average_pooling2d_11[0][0]'] \n \n batch_normalization_113 (Batch (None, 13, 13, 64) 192 ['conv2d_113[0][0]'] \n Normalization) \n \n batch_normalization_115 (Batch (None, 13, 13, 64) 192 ['conv2d_115[0][0]'] \n Normalization) \n \n batch_normalization_118 (Batch (None, 13, 13, 96) 288 ['conv2d_118[0][0]'] \n Normalization) \n \n batch_normalization_119 (Batch (None, 13, 13, 64) 192 ['conv2d_119[0][0]'] \n Normalization) \n \n activation_113 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_113[0][0]']\n \n activation_115 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_115[0][0]']\n \n activation_118 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_118[0][0]']\n \n activation_119 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_119[0][0]']\n \n mixed2 (Concatenate) (None, 13, 13, 288) 0 ['activation_113[0][0]', \n 'activation_115[0][0]', \n 'activation_118[0][0]', \n 'activation_119[0][0]'] \n \n conv2d_121 (Conv2D) (None, 13, 13, 64) 18432 ['mixed2[0][0]'] \n \n batch_normalization_121 (Batch (None, 13, 13, 64) 192 ['conv2d_121[0][0]'] \n Normalization) \n \n activation_121 (Activation) (None, 13, 13, 64) 0 ['batch_normalization_121[0][0]']\n \n conv2d_122 (Conv2D) (None, 13, 13, 96) 55296 ['activation_121[0][0]'] \n \n batch_normalization_122 (Batch (None, 13, 13, 96) 288 ['conv2d_122[0][0]'] \n Normalization) \n \n activation_122 (Activation) (None, 13, 13, 96) 0 ['batch_normalization_122[0][0]']\n \n conv2d_120 (Conv2D) (None, 6, 6, 384) 995328 ['mixed2[0][0]'] \n \n conv2d_123 (Conv2D) (None, 6, 6, 96) 82944 ['activation_122[0][0]'] \n \n batch_normalization_120 (Batch (None, 6, 6, 384) 1152 ['conv2d_120[0][0]'] \n Normalization) \n \n batch_normalization_123 (Batch (None, 6, 6, 96) 288 ['conv2d_123[0][0]'] \n Normalization) \n \n activation_120 (Activation) (None, 6, 6, 384) 0 ['batch_normalization_120[0][0]']\n \n activation_123 (Activation) (None, 6, 6, 96) 0 ['batch_normalization_123[0][0]']\n \n max_pooling2d_6 (MaxPooling2D) (None, 6, 6, 288) 0 ['mixed2[0][0]'] \n \n mixed3 (Concatenate) (None, 6, 6, 768) 0 ['activation_120[0][0]', \n 'activation_123[0][0]', \n 'max_pooling2d_6[0][0]'] \n \n conv2d_128 (Conv2D) (None, 6, 6, 128) 98304 ['mixed3[0][0]'] \n \n batch_normalization_128 (Batch (None, 6, 6, 128) 384 ['conv2d_128[0][0]'] \n Normalization) \n \n activation_128 (Activation) (None, 6, 6, 128) 0 ['batch_normalization_128[0][0]']\n \n conv2d_129 (Conv2D) (None, 6, 6, 128) 114688 ['activation_128[0][0]'] \n \n batch_normalization_129 (Batch (None, 6, 6, 128) 384 ['conv2d_129[0][0]'] \n Normalization) \n \n activation_129 (Activation) (None, 6, 6, 128) 0 ['batch_normalization_129[0][0]']\n \n conv2d_125 (Conv2D) (None, 6, 6, 128) 98304 ['mixed3[0][0]'] \n \n conv2d_130 (Conv2D) (None, 6, 6, 128) 114688 ['activation_129[0][0]'] \n \n batch_normalization_125 (Batch (None, 6, 6, 128) 384 ['conv2d_125[0][0]'] \n Normalization) \n \n batch_normalization_130 (Batch (None, 6, 6, 128) 384 ['conv2d_130[0][0]'] \n Normalization) \n \n activation_125 (Activation) (None, 6, 6, 128) 0 ['batch_normalization_125[0][0]']\n \n activation_130 (Activation) (None, 6, 6, 128) 0 ['batch_normalization_130[0][0]']\n \n conv2d_126 (Conv2D) (None, 6, 6, 128) 114688 ['activation_125[0][0]'] \n \n conv2d_131 (Conv2D) (None, 6, 6, 128) 114688 ['activation_130[0][0]'] \n \n batch_normalization_126 (Batch (None, 6, 6, 128) 384 ['conv2d_126[0][0]'] \n Normalization) \n \n batch_normalization_131 (Batch (None, 6, 6, 128) 384 ['conv2d_131[0][0]'] \n Normalization) \n \n activation_126 (Activation) (None, 6, 6, 128) 0 ['batch_normalization_126[0][0]']\n \n activation_131 (Activation) (None, 6, 6, 128) 0 ['batch_normalization_131[0][0]']\n \n average_pooling2d_12 (AverageP (None, 6, 6, 768) 0 ['mixed3[0][0]'] \n ooling2D) \n \n conv2d_124 (Conv2D) (None, 6, 6, 192) 147456 ['mixed3[0][0]'] \n \n conv2d_127 (Conv2D) (None, 6, 6, 192) 172032 ['activation_126[0][0]'] \n \n conv2d_132 (Conv2D) (None, 6, 6, 192) 172032 ['activation_131[0][0]'] \n \n conv2d_133 (Conv2D) (None, 6, 6, 192) 147456 ['average_pooling2d_12[0][0]'] \n \n batch_normalization_124 (Batch (None, 6, 6, 192) 576 ['conv2d_124[0][0]'] \n Normalization) \n \n batch_normalization_127 (Batch (None, 6, 6, 192) 576 ['conv2d_127[0][0]'] \n Normalization) \n \n batch_normalization_132 (Batch (None, 6, 6, 192) 576 ['conv2d_132[0][0]'] \n Normalization) \n \n batch_normalization_133 (Batch (None, 6, 6, 192) 576 ['conv2d_133[0][0]'] \n Normalization) \n \n activation_124 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_124[0][0]']\n \n activation_127 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_127[0][0]']\n \n activation_132 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_132[0][0]']\n \n activation_133 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_133[0][0]']\n \n mixed4 (Concatenate) (None, 6, 6, 768) 0 ['activation_124[0][0]', \n 'activation_127[0][0]', \n 'activation_132[0][0]', \n 'activation_133[0][0]'] \n \n conv2d_138 (Conv2D) (None, 6, 6, 160) 122880 ['mixed4[0][0]'] \n \n batch_normalization_138 (Batch (None, 6, 6, 160) 480 ['conv2d_138[0][0]'] \n Normalization) \n \n activation_138 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_138[0][0]']\n \n conv2d_139 (Conv2D) (None, 6, 6, 160) 179200 ['activation_138[0][0]'] \n \n batch_normalization_139 (Batch (None, 6, 6, 160) 480 ['conv2d_139[0][0]'] \n Normalization) \n \n activation_139 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_139[0][0]']\n \n conv2d_135 (Conv2D) (None, 6, 6, 160) 122880 ['mixed4[0][0]'] \n \n conv2d_140 (Conv2D) (None, 6, 6, 160) 179200 ['activation_139[0][0]'] \n \n batch_normalization_135 (Batch (None, 6, 6, 160) 480 ['conv2d_135[0][0]'] \n Normalization) \n \n batch_normalization_140 (Batch (None, 6, 6, 160) 480 ['conv2d_140[0][0]'] \n Normalization) \n \n activation_135 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_135[0][0]']\n \n activation_140 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_140[0][0]']\n \n conv2d_136 (Conv2D) (None, 6, 6, 160) 179200 ['activation_135[0][0]'] \n \n conv2d_141 (Conv2D) (None, 6, 6, 160) 179200 ['activation_140[0][0]'] \n \n batch_normalization_136 (Batch (None, 6, 6, 160) 480 ['conv2d_136[0][0]'] \n Normalization) \n \n batch_normalization_141 (Batch (None, 6, 6, 160) 480 ['conv2d_141[0][0]'] \n Normalization) \n \n activation_136 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_136[0][0]']\n \n activation_141 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_141[0][0]']\n \n average_pooling2d_13 (AverageP (None, 6, 6, 768) 0 ['mixed4[0][0]'] \n ooling2D) \n \n conv2d_134 (Conv2D) (None, 6, 6, 192) 147456 ['mixed4[0][0]'] \n \n conv2d_137 (Conv2D) (None, 6, 6, 192) 215040 ['activation_136[0][0]'] \n \n conv2d_142 (Conv2D) (None, 6, 6, 192) 215040 ['activation_141[0][0]'] \n \n conv2d_143 (Conv2D) (None, 6, 6, 192) 147456 ['average_pooling2d_13[0][0]'] \n \n batch_normalization_134 (Batch (None, 6, 6, 192) 576 ['conv2d_134[0][0]'] \n Normalization) \n \n batch_normalization_137 (Batch (None, 6, 6, 192) 576 ['conv2d_137[0][0]'] \n Normalization) \n \n batch_normalization_142 (Batch (None, 6, 6, 192) 576 ['conv2d_142[0][0]'] \n Normalization) \n \n batch_normalization_143 (Batch (None, 6, 6, 192) 576 ['conv2d_143[0][0]'] \n Normalization) \n \n activation_134 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_134[0][0]']\n \n activation_137 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_137[0][0]']\n \n activation_142 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_142[0][0]']\n \n activation_143 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_143[0][0]']\n \n mixed5 (Concatenate) (None, 6, 6, 768) 0 ['activation_134[0][0]', \n 'activation_137[0][0]', \n 'activation_142[0][0]', \n 'activation_143[0][0]'] \n \n conv2d_148 (Conv2D) (None, 6, 6, 160) 122880 ['mixed5[0][0]'] \n \n batch_normalization_148 (Batch (None, 6, 6, 160) 480 ['conv2d_148[0][0]'] \n Normalization) \n \n activation_148 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_148[0][0]']\n \n conv2d_149 (Conv2D) (None, 6, 6, 160) 179200 ['activation_148[0][0]'] \n \n batch_normalization_149 (Batch (None, 6, 6, 160) 480 ['conv2d_149[0][0]'] \n Normalization) \n \n activation_149 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_149[0][0]']\n \n conv2d_145 (Conv2D) (None, 6, 6, 160) 122880 ['mixed5[0][0]'] \n \n conv2d_150 (Conv2D) (None, 6, 6, 160) 179200 ['activation_149[0][0]'] \n \n batch_normalization_145 (Batch (None, 6, 6, 160) 480 ['conv2d_145[0][0]'] \n Normalization) \n \n batch_normalization_150 (Batch (None, 6, 6, 160) 480 ['conv2d_150[0][0]'] \n Normalization) \n \n activation_145 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_145[0][0]']\n \n activation_150 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_150[0][0]']\n \n conv2d_146 (Conv2D) (None, 6, 6, 160) 179200 ['activation_145[0][0]'] \n \n conv2d_151 (Conv2D) (None, 6, 6, 160) 179200 ['activation_150[0][0]'] \n \n batch_normalization_146 (Batch (None, 6, 6, 160) 480 ['conv2d_146[0][0]'] \n Normalization) \n \n batch_normalization_151 (Batch (None, 6, 6, 160) 480 ['conv2d_151[0][0]'] \n Normalization) \n \n activation_146 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_146[0][0]']\n \n activation_151 (Activation) (None, 6, 6, 160) 0 ['batch_normalization_151[0][0]']\n \n average_pooling2d_14 (AverageP (None, 6, 6, 768) 0 ['mixed5[0][0]'] \n ooling2D) \n \n conv2d_144 (Conv2D) (None, 6, 6, 192) 147456 ['mixed5[0][0]'] \n \n conv2d_147 (Conv2D) (None, 6, 6, 192) 215040 ['activation_146[0][0]'] \n \n conv2d_152 (Conv2D) (None, 6, 6, 192) 215040 ['activation_151[0][0]'] \n \n conv2d_153 (Conv2D) (None, 6, 6, 192) 147456 ['average_pooling2d_14[0][0]'] \n \n batch_normalization_144 (Batch (None, 6, 6, 192) 576 ['conv2d_144[0][0]'] \n Normalization) \n \n batch_normalization_147 (Batch (None, 6, 6, 192) 576 ['conv2d_147[0][0]'] \n Normalization) \n \n batch_normalization_152 (Batch (None, 6, 6, 192) 576 ['conv2d_152[0][0]'] \n Normalization) \n \n batch_normalization_153 (Batch (None, 6, 6, 192) 576 ['conv2d_153[0][0]'] \n Normalization) \n \n activation_144 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_144[0][0]']\n \n activation_147 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_147[0][0]']\n \n activation_152 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_152[0][0]']\n \n activation_153 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_153[0][0]']\n \n mixed6 (Concatenate) (None, 6, 6, 768) 0 ['activation_144[0][0]', \n 'activation_147[0][0]', \n 'activation_152[0][0]', \n 'activation_153[0][0]'] \n \n conv2d_158 (Conv2D) (None, 6, 6, 192) 147456 ['mixed6[0][0]'] \n \n batch_normalization_158 (Batch (None, 6, 6, 192) 576 ['conv2d_158[0][0]'] \n Normalization) \n \n activation_158 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_158[0][0]']\n \n conv2d_159 (Conv2D) (None, 6, 6, 192) 258048 ['activation_158[0][0]'] \n \n batch_normalization_159 (Batch (None, 6, 6, 192) 576 ['conv2d_159[0][0]'] \n Normalization) \n \n activation_159 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_159[0][0]']\n \n conv2d_155 (Conv2D) (None, 6, 6, 192) 147456 ['mixed6[0][0]'] \n \n conv2d_160 (Conv2D) (None, 6, 6, 192) 258048 ['activation_159[0][0]'] \n \n batch_normalization_155 (Batch (None, 6, 6, 192) 576 ['conv2d_155[0][0]'] \n Normalization) \n \n batch_normalization_160 (Batch (None, 6, 6, 192) 576 ['conv2d_160[0][0]'] \n Normalization) \n \n activation_155 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_155[0][0]']\n \n activation_160 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_160[0][0]']\n \n conv2d_156 (Conv2D) (None, 6, 6, 192) 258048 ['activation_155[0][0]'] \n \n conv2d_161 (Conv2D) (None, 6, 6, 192) 258048 ['activation_160[0][0]'] \n \n batch_normalization_156 (Batch (None, 6, 6, 192) 576 ['conv2d_156[0][0]'] \n Normalization) \n \n batch_normalization_161 (Batch (None, 6, 6, 192) 576 ['conv2d_161[0][0]'] \n Normalization) \n \n activation_156 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_156[0][0]']\n \n activation_161 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_161[0][0]']\n \n average_pooling2d_15 (AverageP (None, 6, 6, 768) 0 ['mixed6[0][0]'] \n ooling2D) \n \n conv2d_154 (Conv2D) (None, 6, 6, 192) 147456 ['mixed6[0][0]'] \n \n conv2d_157 (Conv2D) (None, 6, 6, 192) 258048 ['activation_156[0][0]'] \n \n conv2d_162 (Conv2D) (None, 6, 6, 192) 258048 ['activation_161[0][0]'] \n \n conv2d_163 (Conv2D) (None, 6, 6, 192) 147456 ['average_pooling2d_15[0][0]'] \n \n batch_normalization_154 (Batch (None, 6, 6, 192) 576 ['conv2d_154[0][0]'] \n Normalization) \n \n batch_normalization_157 (Batch (None, 6, 6, 192) 576 ['conv2d_157[0][0]'] \n Normalization) \n \n batch_normalization_162 (Batch (None, 6, 6, 192) 576 ['conv2d_162[0][0]'] \n Normalization) \n \n batch_normalization_163 (Batch (None, 6, 6, 192) 576 ['conv2d_163[0][0]'] \n Normalization) \n \n activation_154 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_154[0][0]']\n \n activation_157 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_157[0][0]']\n \n activation_162 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_162[0][0]']\n \n activation_163 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_163[0][0]']\n \n mixed7 (Concatenate) (None, 6, 6, 768) 0 ['activation_154[0][0]', \n 'activation_157[0][0]', \n 'activation_162[0][0]', \n 'activation_163[0][0]'] \n \n conv2d_166 (Conv2D) (None, 6, 6, 192) 147456 ['mixed7[0][0]'] \n \n batch_normalization_166 (Batch (None, 6, 6, 192) 576 ['conv2d_166[0][0]'] \n Normalization) \n \n activation_166 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_166[0][0]']\n \n conv2d_167 (Conv2D) (None, 6, 6, 192) 258048 ['activation_166[0][0]'] \n \n batch_normalization_167 (Batch (None, 6, 6, 192) 576 ['conv2d_167[0][0]'] \n Normalization) \n \n activation_167 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_167[0][0]']\n \n conv2d_164 (Conv2D) (None, 6, 6, 192) 147456 ['mixed7[0][0]'] \n \n conv2d_168 (Conv2D) (None, 6, 6, 192) 258048 ['activation_167[0][0]'] \n \n batch_normalization_164 (Batch (None, 6, 6, 192) 576 ['conv2d_164[0][0]'] \n Normalization) \n \n batch_normalization_168 (Batch (None, 6, 6, 192) 576 ['conv2d_168[0][0]'] \n Normalization) \n \n activation_164 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_164[0][0]']\n \n activation_168 (Activation) (None, 6, 6, 192) 0 ['batch_normalization_168[0][0]']\n \n conv2d_165 (Conv2D) (None, 2, 2, 320) 552960 ['activation_164[0][0]'] \n \n conv2d_169 (Conv2D) (None, 2, 2, 192) 331776 ['activation_168[0][0]'] \n \n batch_normalization_165 (Batch (None, 2, 2, 320) 960 ['conv2d_165[0][0]'] \n Normalization) \n \n batch_normalization_169 (Batch (None, 2, 2, 192) 576 ['conv2d_169[0][0]'] \n Normalization) \n \n activation_165 (Activation) (None, 2, 2, 320) 0 ['batch_normalization_165[0][0]']\n \n activation_169 (Activation) (None, 2, 2, 192) 0 ['batch_normalization_169[0][0]']\n \n max_pooling2d_7 (MaxPooling2D) (None, 2, 2, 768) 0 ['mixed7[0][0]'] \n \n mixed8 (Concatenate) (None, 2, 2, 1280) 0 ['activation_165[0][0]', \n 'activation_169[0][0]', \n 'max_pooling2d_7[0][0]'] \n \n conv2d_174 (Conv2D) (None, 2, 2, 448) 573440 ['mixed8[0][0]'] \n \n batch_normalization_174 (Batch (None, 2, 2, 448) 1344 ['conv2d_174[0][0]'] \n Normalization) \n \n activation_174 (Activation) (None, 2, 2, 448) 0 ['batch_normalization_174[0][0]']\n \n conv2d_171 (Conv2D) (None, 2, 2, 384) 491520 ['mixed8[0][0]'] \n \n conv2d_175 (Conv2D) (None, 2, 2, 384) 1548288 ['activation_174[0][0]'] \n \n batch_normalization_171 (Batch (None, 2, 2, 384) 1152 ['conv2d_171[0][0]'] \n Normalization) \n \n batch_normalization_175 (Batch (None, 2, 2, 384) 1152 ['conv2d_175[0][0]'] \n Normalization) \n \n activation_171 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_171[0][0]']\n \n activation_175 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_175[0][0]']\n \n conv2d_172 (Conv2D) (None, 2, 2, 384) 442368 ['activation_171[0][0]'] \n \n conv2d_173 (Conv2D) (None, 2, 2, 384) 442368 ['activation_171[0][0]'] \n \n conv2d_176 (Conv2D) (None, 2, 2, 384) 442368 ['activation_175[0][0]'] \n \n conv2d_177 (Conv2D) (None, 2, 2, 384) 442368 ['activation_175[0][0]'] \n \n average_pooling2d_16 (AverageP (None, 2, 2, 1280) 0 ['mixed8[0][0]'] \n ooling2D) \n \n conv2d_170 (Conv2D) (None, 2, 2, 320) 409600 ['mixed8[0][0]'] \n \n batch_normalization_172 (Batch (None, 2, 2, 384) 1152 ['conv2d_172[0][0]'] \n Normalization) \n \n batch_normalization_173 (Batch (None, 2, 2, 384) 1152 ['conv2d_173[0][0]'] \n Normalization) \n \n batch_normalization_176 (Batch (None, 2, 2, 384) 1152 ['conv2d_176[0][0]'] \n Normalization) \n \n batch_normalization_177 (Batch (None, 2, 2, 384) 1152 ['conv2d_177[0][0]'] \n Normalization) \n \n conv2d_178 (Conv2D) (None, 2, 2, 192) 245760 ['average_pooling2d_16[0][0]'] \n \n batch_normalization_170 (Batch (None, 2, 2, 320) 960 ['conv2d_170[0][0]'] \n Normalization) \n \n activation_172 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_172[0][0]']\n \n activation_173 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_173[0][0]']\n \n activation_176 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_176[0][0]']\n \n activation_177 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_177[0][0]']\n \n batch_normalization_178 (Batch (None, 2, 2, 192) 576 ['conv2d_178[0][0]'] \n Normalization) \n \n activation_170 (Activation) (None, 2, 2, 320) 0 ['batch_normalization_170[0][0]']\n \n mixed9_0 (Concatenate) (None, 2, 2, 768) 0 ['activation_172[0][0]', \n 'activation_173[0][0]'] \n \n concatenate_2 (Concatenate) (None, 2, 2, 768) 0 ['activation_176[0][0]', \n 'activation_177[0][0]'] \n \n activation_178 (Activation) (None, 2, 2, 192) 0 ['batch_normalization_178[0][0]']\n \n mixed9 (Concatenate) (None, 2, 2, 2048) 0 ['activation_170[0][0]', \n 'mixed9_0[0][0]', \n 'concatenate_2[0][0]', \n 'activation_178[0][0]'] \n \n conv2d_183 (Conv2D) (None, 2, 2, 448) 917504 ['mixed9[0][0]'] \n \n batch_normalization_183 (Batch (None, 2, 2, 448) 1344 ['conv2d_183[0][0]'] \n Normalization) \n \n activation_183 (Activation) (None, 2, 2, 448) 0 ['batch_normalization_183[0][0]']\n \n conv2d_180 (Conv2D) (None, 2, 2, 384) 786432 ['mixed9[0][0]'] \n \n conv2d_184 (Conv2D) (None, 2, 2, 384) 1548288 ['activation_183[0][0]'] \n \n batch_normalization_180 (Batch (None, 2, 2, 384) 1152 ['conv2d_180[0][0]'] \n Normalization) \n \n batch_normalization_184 (Batch (None, 2, 2, 384) 1152 ['conv2d_184[0][0]'] \n Normalization) \n \n activation_180 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_180[0][0]']\n \n activation_184 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_184[0][0]']\n \n conv2d_181 (Conv2D) (None, 2, 2, 384) 442368 ['activation_180[0][0]'] \n \n conv2d_182 (Conv2D) (None, 2, 2, 384) 442368 ['activation_180[0][0]'] \n \n conv2d_185 (Conv2D) (None, 2, 2, 384) 442368 ['activation_184[0][0]'] \n \n conv2d_186 (Conv2D) (None, 2, 2, 384) 442368 ['activation_184[0][0]'] \n \n average_pooling2d_17 (AverageP (None, 2, 2, 2048) 0 ['mixed9[0][0]'] \n ooling2D) \n \n conv2d_179 (Conv2D) (None, 2, 2, 320) 655360 ['mixed9[0][0]'] \n \n batch_normalization_181 (Batch (None, 2, 2, 384) 1152 ['conv2d_181[0][0]'] \n Normalization) \n \n batch_normalization_182 (Batch (None, 2, 2, 384) 1152 ['conv2d_182[0][0]'] \n Normalization) \n \n batch_normalization_185 (Batch (None, 2, 2, 384) 1152 ['conv2d_185[0][0]'] \n Normalization) \n \n batch_normalization_186 (Batch (None, 2, 2, 384) 1152 ['conv2d_186[0][0]'] \n Normalization) \n \n conv2d_187 (Conv2D) (None, 2, 2, 192) 393216 ['average_pooling2d_17[0][0]'] \n \n batch_normalization_179 (Batch (None, 2, 2, 320) 960 ['conv2d_179[0][0]'] \n Normalization) \n \n activation_181 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_181[0][0]']\n \n activation_182 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_182[0][0]']\n \n activation_185 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_185[0][0]']\n \n activation_186 (Activation) (None, 2, 2, 384) 0 ['batch_normalization_186[0][0]']\n \n batch_normalization_187 (Batch (None, 2, 2, 192) 576 ['conv2d_187[0][0]'] \n Normalization) \n \n activation_179 (Activation) (None, 2, 2, 320) 0 ['batch_normalization_179[0][0]']\n \n mixed9_1 (Concatenate) (None, 2, 2, 768) 0 ['activation_181[0][0]', \n 'activation_182[0][0]'] \n \n concatenate_3 (Concatenate) (None, 2, 2, 768) 0 ['activation_185[0][0]', \n 'activation_186[0][0]'] \n \n activation_187 (Activation) (None, 2, 2, 192) 0 ['batch_normalization_187[0][0]']\n \n mixed10 (Concatenate) (None, 2, 2, 2048) 0 ['activation_179[0][0]', \n 'mixed9_1[0][0]', \n 'concatenate_3[0][0]', \n 'activation_187[0][0]'] \n \n global_average_pooling2d_1 (Gl (None, 2048) 0 ['mixed10[0][0]'] \n obalAveragePooling2D) \n \n dropout_2 (Dropout) (None, 2048) 0 ['global_average_pooling2d_1[0][0\n ]'] \n \n hidden_layer1 (Dense) (None, 1024) 2098176 ['dropout_2[0][0]'] \n \n hidden_layer2 (Dense) (None, 1024) 1049600 ['hidden_layer1[0][0]'] \n \n dropout_3 (Dropout) (None, 1024) 0 ['hidden_layer2[0][0]'] \n \n hidden_layer3 (Dense) (None, 512) 524800 ['dropout_3[0][0]'] \n \n hidden_layer4 (Dense) (None, 512) 262656 ['hidden_layer3[0][0]'] \n \n output (Dense) (None, 5) 2565 ['hidden_layer4[0][0]'] \n \n==================================================================================================\nTotal params: 25,740,581\nTrainable params: 25,706,149\nNon-trainable params: 34,432\n__________________________________________________________________________________________________\n"
],
[
"def normalize(x):\n x = x - np.mean(x)\n x = x / np.std(x)\n \n return x.astype(np.float32) ",
"_____no_output_____"
],
[
"def isNan(val):\n return val != val",
"_____no_output_____"
],
[
"def discount_rewards(rewards, gamma = 0.99):\n discounted_rewards = np.zeros_like(rewards)\n \n R = 0 \n for t in reversed(range (0,len(rewards))):\n \n if rewards[t] != 0 :\n R = 0\n R = R * gamma + rewards[t]\n \n \n discounted_rewards[t] = R\n \n return normalize(discounted_rewards)",
"_____no_output_____"
],
[
"class Memory:\n def __init__(self):\n self.clear()\n \n \n def clear(self):\n self.observations = []\n self.actions = []\n self.rewards = []\n \n def add_to_memory(self,new_observation,new_action,new_reward):\n self.observations.append(new_observation)\n \n self.actions.append(new_action)\n \n self.rewards.append(new_reward)",
"_____no_output_____"
],
[
"def choose_action(model,observation):\n \n observation = np.expand_dims(observation,axis = 0)\n \n logits = model.predict(observation)\n \n prob_weights = tf.nn.softmax(logits).numpy()\n \n isContainNan = [ isNan(x) for x in prob_weights.flatten()]\n \n if True in isContainNan:\n return np.random.choice(n_actions,size = 1)[0]\n \n action = np.random.choice(n_actions,size = 1, p = prob_weights.flatten())[0]\n \n return action",
"_____no_output_____"
],
[
"### Loss function ###\ndef compute_loss(logits,actions,rewards):\n neg_logprob = tf.nn.sparse_softmax_cross_entropy_with_logits(logits = logits,labels = actions)\n\n loss = tf.reduce_mean(neg_logprob * rewards)\n\n return loss",
"_____no_output_____"
]
],
[
[
"### logging",
"_____no_output_____"
]
],
[
[
"import IPython\nimport time\nfrom IPython import display as ipythondisplay",
"_____no_output_____"
],
[
"class LossHistory:\n def __init__(self, smoothing_factor=0.0):\n self.alpha = smoothing_factor\n self.loss = []\n def append(self, value):\n self.loss.append( self.alpha*self.loss[-1] + (1-self.alpha)*value if len(self.loss)>0 else value )\n def get(self):\n return self.loss",
"_____no_output_____"
],
[
"class PeriodicPlotter:\n def __init__(self, sec, xlabel='', ylabel='', scale=None):\n\n self.xlabel = xlabel\n self.ylabel = ylabel\n self.sec = sec\n self.scale = scale\n\n self.tic = time.time()\n\n def plot(self, data):\n if time.time() - self.tic > self.sec:\n plt.cla()\n\n if self.scale is None:\n plt.plot(data)\n elif self.scale == 'semilogx':\n plt.semilogx(data)\n elif self.scale == 'semilogy':\n plt.semilogy(data)\n elif self.scale == 'loglog':\n plt.loglog(data)\n else:\n raise ValueError(\"unrecognized parameter scale {}\".format(self.scale))\n\n plt.xlabel(self.xlabel); plt.ylabel(self.ylabel)\n ipythondisplay.clear_output(wait=True)\n ipythondisplay.display(plt.gcf())\n \n self.tic = time.time()",
"_____no_output_____"
],
[
"# plotting\nsmoothed_reward = LossHistory(smoothing_factor=0.9)\nplotter = PeriodicPlotter(sec=5, xlabel='Iterations', ylabel='Rewards')\nmemory = Memory()",
"_____no_output_____"
],
[
"### Training step (forward and backpropagation) ###\ndef train_step(model,optimizer,observations,actions,discounted_rewards):\n with tf.GradientTape() as tape:\n logits = model(observations)\n \n loss = compute_loss(logits,actions,discounted_rewards)\n \n grads = tape.gradient(loss,model.trainable_variables)\n optimizer.apply_gradients(zip(grads,model.trainable_variables))",
"_____no_output_____"
],
[
"for i_episode in range(MAX_ITERS):\n plotter.plot(smoothed_reward.get())\n \n # Restart the environment\n observation = env.reset()\n env.set_obsticals(full_obstacle_list)\n env.set_goal(goal_pos)\n\n previous_frame = pre_process(observation)\n \n while True :\n current_frame = pre_process(observation)\n \n obs_change = current_frame - previous_frame\n \n action = choose_action(model,obs_change)\n #env.render()\n next_observation, reward, done, info = env.step(action)\n \n memory.add_to_memory(obs_change,action,reward)\n \n if done :\n \n total_reward = sum(memory.rewards)\n smoothed_reward.append(total_reward)\n \n train_step(model,\n optimizer,\n observations = np.stack(memory.observations,0),\n actions = np.array(memory.actions),\n discounted_rewards = discount_rewards(memory.rewards))\n memory.clear()\n break\n \n observation = next_observation\n previous_frame = current_frame",
"_____no_output_____"
],
[
"model.save(\"26_3_2022.h5\")",
"_____no_output_____"
],
[
"print(\"hello\")",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecad8a3a2af374c9b221a8a10ae5c1018356a272 | 218,319 | ipynb | Jupyter Notebook | Lightcurve/Lightcurve tutorial.ipynb | swapsha96/notebooks | 7eca687fede9456a34c2187f86fa1b913fbb0668 | [
"MIT"
] | 2 | 2020-05-02T15:07:43.000Z | 2020-05-02T15:08:45.000Z | Lightcurve/Lightcurve tutorial.ipynb | astrojuan/notebooks | 98cd54a94a4b117c762e9c17b4d7713324467e2f | [
"MIT"
] | null | null | null | Lightcurve/Lightcurve tutorial.ipynb | astrojuan/notebooks | 98cd54a94a4b117c762e9c17b4d7713324467e2f | [
"MIT"
] | null | null | null | 240.439427 | 110,204 | 0.931028 | [
[
[
"Start here to begin with Stingray.",
"_____no_output_____"
]
],
[
[
"import numpy as np\n%matplotlib inline\nimport warnings\nwarnings.filterwarnings('ignore')",
"_____no_output_____"
]
],
[
[
"# Creating a light curve",
"_____no_output_____"
]
],
[
[
"from stingray import Lightcurve",
"_____no_output_____"
]
],
[
[
"A `Lightcurve` object can be created in two ways :\n\n1. From an array of time stamps and an array of counts.\n2. From photon arrival times.",
"_____no_output_____"
],
[
"## 1. Array of time stamps and counts",
"_____no_output_____"
],
[
"Create 1000 time stamps",
"_____no_output_____"
]
],
[
[
"times = np.arange(1000)\ntimes[:10]",
"_____no_output_____"
]
],
[
[
"Create 1000 random count values between 0 to 100",
"_____no_output_____"
]
],
[
[
"counts = np.random.rand(1000)*100\ncounts[:10]",
"_____no_output_____"
]
],
[
[
"Create a Lightcurve object with the times and counts array.",
"_____no_output_____"
]
],
[
[
"lc = Lightcurve(times, counts)",
"_____no_output_____"
]
],
[
[
"The number of data points can be counted with the `len` function.",
"_____no_output_____"
]
],
[
[
"len(lc)",
"_____no_output_____"
]
],
[
[
"## 2. Photon Arrival Times",
"_____no_output_____"
]
],
[
[
"arrivals = np.loadtxt(\"photon_arrivals.txt\")\narrivals[:10]",
"_____no_output_____"
],
[
"lc_new = Lightcurve.make_lightcurve(arrivals, 1)",
"_____no_output_____"
]
],
[
[
"The time bins and respective counts can be seen with `lc.counts` and `lc.time`",
"_____no_output_____"
]
],
[
[
"lc_new.counts",
"_____no_output_____"
],
[
"lc_new.time",
"_____no_output_____"
]
],
[
[
"# Properties",
"_____no_output_____"
],
[
"A Lightcurve object has the following properties :\n\n1. `time` : numpy array of time values\n2. `counts` : numpy array of counts per bin values\n3. `countrate` : numpy array of counts per second values\n4. `n` : Number of data points in the lightcurve\n5. `dt` : Time resolution of the light curve\n6. `tseg` : Total duration of the light curve\n7. `tstart` : Start time of the light curve",
"_____no_output_____"
]
],
[
[
"lc.n == len(lc)",
"_____no_output_____"
]
],
[
[
"# Operations",
"_____no_output_____"
],
[
"## Addition/Subtraction",
"_____no_output_____"
],
[
"Two light curves can be summed up or subtracted from each other if they have same time arrays.",
"_____no_output_____"
]
],
[
[
"lc_rand = Lightcurve(np.arange(1000), [500]*1000)",
"_____no_output_____"
],
[
"lc_sum = lc + lc_rand",
"_____no_output_____"
],
[
"# We can see the difference between the maximum and minimum values\nprint(max(lc_sum) - max(lc))\nprint(min(lc_sum) - min(lc))",
"500.00000000000006\n500.0\n"
]
],
[
[
"## Negation",
"_____no_output_____"
],
[
"A negation operation on the lightcurve object inverts the count array from positive to negative values.",
"_____no_output_____"
]
],
[
[
"lc_neg = -lc",
"_____no_output_____"
],
[
"lc_sum = lc + lc_neg",
"_____no_output_____"
],
[
"np.all(lc_sum.counts == 0) # All the points on lc and lc_neg cancel each other",
"_____no_output_____"
]
],
[
[
"## Indexing",
"_____no_output_____"
],
[
"Count value at a particular time can be obtained using indexing.",
"_____no_output_____"
]
],
[
[
"lc[120]",
"_____no_output_____"
]
],
[
[
"A Lightcurve can also be sliced to generate a new object.",
"_____no_output_____"
]
],
[
[
"lc_sliced = lc[100:200]",
"_____no_output_____"
],
[
"len(lc_sliced.counts)",
"_____no_output_____"
]
],
[
[
"# Methods",
"_____no_output_____"
],
[
"## Concatenation",
"_____no_output_____"
],
[
"Two light curves can be combined into a single object using the `join` method. Note that both of them must not have overlapping time arrays.",
"_____no_output_____"
]
],
[
[
"lc_1 = lc",
"_____no_output_____"
],
[
"lc_2 = Lightcurve(np.arange(1000, 2000), np.random.rand(1000)*1000)",
"_____no_output_____"
],
[
"lc_long = lc_1.join(lc_2) # Or vice-versa",
"_____no_output_____"
],
[
"print(len(lc_long))",
"2000\n"
]
],
[
[
"## Truncation",
"_____no_output_____"
],
[
"A light curve can also be truncated.",
"_____no_output_____"
]
],
[
[
"lc_cut = lc_long.truncate(start=0, stop=1000)",
"_____no_output_____"
],
[
"len(lc_cut)",
"_____no_output_____"
]
],
[
[
"**Note** : The `start` and `stop` values can also be given as time values.",
"_____no_output_____"
]
],
[
[
"lc_cut = lc_long.truncate(start=500, stop=1500, method='time')",
"_____no_output_____"
],
[
"lc_cut.time[0], lc_cut.time[-1]",
"_____no_output_____"
]
],
[
[
"## Re-binning",
"_____no_output_____"
],
[
"The time resolution (`dt`) can also be changed to a larger value.\n\n**Note** : While the new resolution need not be an integer multiple of the previous time resolution, be aware that if it is not, the last bin will be cut off by the fraction left over by the integer division.",
"_____no_output_____"
]
],
[
[
"lc_rebinned = lc_long.rebin(2)",
"_____no_output_____"
],
[
"print(\"Old time resolution = \" + str(lc_long.dt))\nprint(\"Number of data points = \" + str(lc_long.n))\nprint(\"New time resolution = \" + str(lc_rebinned.dt))\nprint(\"Number of data points = \" + str(lc_rebinned.n))",
"Old time resolution = 1.0\nNumber of data points = 2000\nNew time resolution = 2\nNumber of data points = 1000\n"
]
],
[
[
"## Sorting",
"_____no_output_____"
],
[
"A lightcurve can be sorted using the `sort` method. This function sorts `time` array and the `counts` array is changed accordingly.",
"_____no_output_____"
]
],
[
[
"new_lc_long = lc_long[:] # Copying into a new object",
"_____no_output_____"
],
[
"new_lc_long = new_lc_long.sort(reverse=True)",
"_____no_output_____"
],
[
"new_lc_long.time[0] == max(lc_long.time)",
"_____no_output_____"
]
],
[
[
"You can sort `counts` array using `sort_counts` method which changes `time` array accordingly.",
"_____no_output_____"
]
],
[
[
"new_lc = lc_long[:]\nnew_lc = new_lc.sort_counts()\nnew_lc.counts[-1] == max(lc_long.counts)",
"_____no_output_____"
]
],
[
[
"## Plotting",
"_____no_output_____"
],
[
"A curve can be plotted with the `plot` method.",
"_____no_output_____"
]
],
[
[
"lc.plot()",
"_____no_output_____"
]
],
[
[
"A plot can also be customized using several keyword arguments.",
"_____no_output_____"
]
],
[
[
"lc.plot(labels=('Time', \"Counts\"), # (xlabel, ylabel)\n axis=(0, 1000, -50, 150), # (xmin, xmax, ymin, ymax)\n title=\"Random generated lightcurve\",\n marker='c:') # c is for cyan and : is the marker style",
"_____no_output_____"
]
],
[
[
"The figure drawn can also be saved in a file using keywords arguments in the plot method itself.",
"_____no_output_____"
]
],
[
[
"lc.plot(marker = 'k', save=True, filename=\"lightcurve.png\")",
"_____no_output_____"
]
],
[
[
"**Note** : See `utils.savefig` function for more options on saving a file.",
"_____no_output_____"
],
[
"# Sample Data",
"_____no_output_____"
],
[
"Stingray also has a sample `Lightcurve` data which can be imported from within the library.",
"_____no_output_____"
]
],
[
[
"from stingray import sampledata",
"_____no_output_____"
],
[
"lc = sampledata.sample_data()",
"_____no_output_____"
],
[
"lc.plot()",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code",
"code"
]
] |
ecad8d710ddd08b141c9648964f418933ddde2e7 | 51,870 | ipynb | Jupyter Notebook | deep_learning/softmax_tensorflow.ipynb | awesome-archive/machine-learning | 8494f3fe73db511f7b97d082c786097bfbe71463 | [
"MIT"
] | 1 | 2017-07-05T09:32:31.000Z | 2017-07-05T09:32:31.000Z | deep_learning/softmax_tensorflow.ipynb | JediKoder/machine-learning | ab48b70720625cd85b374229f8e3c72d7fc558dc | [
"MIT"
] | null | null | null | deep_learning/softmax_tensorflow.ipynb | JediKoder/machine-learning | ab48b70720625cd85b374229f8e3c72d7fc558dc | [
"MIT"
] | null | null | null | 54.947034 | 18,558 | 0.683266 | [
[
[
"# code for loading the format for the notebook\nimport os\n\n# path : store the current path to convert back to it later\npath = os.getcwd()\nos.chdir( os.path.join('..', 'notebook_format') )\nfrom formats import load_style\nload_style()",
"_____no_output_____"
],
[
"os.chdir(path)\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# 1. magic for inline plot\n# 2. magic to print version\n# 3. magic so that the notebook will reload external python modules\n%matplotlib inline\n%load_ext watermark\n%load_ext autoreload \n%autoreload 2\n\nimport tensorflow as tf\n\n%watermark -a 'Ethen' -d -t -v -p numpy,pandas,matplotlib,tensorflow",
"Ethen 2017-06-22 14:04:27 \n\nCPython 3.5.2\nIPython 5.4.1\n\nnumpy 1.12.1\npandas 0.20.2\nmatplotlib 2.0.2\ntensorflow 1.1.0\n"
]
],
[
[
"# Tensorflow\n\nTensorFlow provides multiple APIs. The lowest level API--TensorFlow Core-- provides you with complete programming control. We recommend TensorFlow Core for machine learning researchers and others who require fine levels of control over their models\n\n## Hello World\n\nWe think of TensorFlow Core programs as consisting of two discrete sections:\n\n- Building the computational graph.\n- Running the computational graph.",
"_____no_output_____"
]
],
[
[
"# note that this is simply telling tensorflow to \n# create a constant operation, nothing gets\n# executed until we start a session and run it\nhello = tf.constant('Hello, TensorFlow!')\nhello",
"_____no_output_____"
],
[
"# start the session and run the graph\nwith tf.Session() as sess:\n print(sess.run(hello))",
"b'Hello, TensorFlow!'\n"
]
],
[
[
"We can think of tensorflow as a system to define our computation, and using the operation that we've defined it will construct a computation graph (where each operation becomes a node in the graph). The computation graph that we've defined will not be `run` unless we give it some context and explicitly tell it to do so. In this case, we create the `Session` that encapsulates the environment in which the objects are evaluated (execute the operations that are defined in the graph).\n\nConsider another example that simply add and multiply two constant numbers.",
"_____no_output_____"
]
],
[
[
"a = tf.constant(2.0, tf.float32)\nb = tf.constant(3.0) # also tf.float32 implicitly\nc = a + b\n\nwith tf.Session() as sess:\n print('mutiply: ', sess.run(a * b))\n print('add: ', sess.run(c)) # note that we can define the add operation outside \n print('add: ', sess.run(a + b)) # or inside the .run()",
"mutiply: 6.0\nadd: 5.0\nadd: 5.0\n"
]
],
[
[
"The example above is not especially interesting because it always produces a constant result. A graph can be parameterized to accept external inputs, known as `placeholders`. Think of it as the input data we would give to machine learning algorithm at some point.\n\nWe can do the same operation as above by first defining a `placeholder` (note that we must specify the data type). Then `feed` in values using `feed_dict` when we `run` it.",
"_____no_output_____"
]
],
[
[
"a = tf.placeholder(tf.float32)\nb = tf.placeholder(tf.float32)\n\n# define some operations\nadd = a + b\nmul = a * b\n\nwith tf.Session() as sess:\n print('mutiply: ', sess.run(mul, feed_dict = {a: 2, b: 3}))\n print('add: ', sess.run(add, feed_dict = {a: 2, b: 3}))",
"mutiply: 6.0\nadd: 5.0\n"
]
],
[
[
"Some matrix operations are the same compared to numpy. e.g. \t",
"_____no_output_____"
]
],
[
[
"c = np.array([[3.,4], [5.,6], [6.,7]])\nprint(c)\nprint(np.mean(c, axis = 1))\nprint(np.argmax(c, axis = 1))\n\nwith tf.Session() as sess:\n result = sess.run(tf.reduce_mean(c, axis = 1))\n print(result)\n print(sess.run(tf.argmax(c, axis = 1)))",
"[[ 3. 4.]\n [ 5. 6.]\n [ 6. 7.]]\n[ 3.5 5.5 6.5]\n[1 1 1]\n[ 3.5 5.5 6.5]\n[1 1 1]\n"
]
],
[
[
"The functionality of `numpy.mean` and `tensorflow.reduce_mean` are the same. When axis argument parameter is 1, it computes mean across (3,4) and (5,6) and (6,7), so 1 defines across which axis the mean is computed (axis = 1, means the operation is along the column, so it will compute the mean for each row). When it is 0, the mean is computed across(3,5,6) and (4,6,7), and so on. The same can be applied to argmax which returns the index that contains the maximum value along an axis.\n\n## Linear Regression\n\nWe'll start off by writing a simple linear regression model. To do so, we first need to understand the difference between `tf.Variable` and `tf.placeholder`. \n\n> [Stackoverflow](http://stackoverflow.com/questions/36693740/whats-the-difference-between-tf-placeholder-and-tf-variable). The difference is that with `tf.Variable` you have to provide an initial value when you declare it. With `tf.placeholder` you don't have to provide an initial value and you can specify it at run time with the `feed_dict` argument inside `Session.run`.\n> In short, we will use `tf.Variable` for trainable variables such as weights (W) and biases (B) for our model. On the other hand, `tf.placeholder` is used to feed actual training examples.\n\nAlso note that, constants are automatically initialized when we call `tf.constant`, and their value can never change. By contrast, variables are not initialized when we call `tf.Variable`. To initialize all the variables in a TensorFlow program, we must explicitly call a special operation called `tf.global_variables_initializer()`. Things will become clearer with the example below.",
"_____no_output_____"
]
],
[
[
"# Parameters\nlearning_rate = 0.01 # learning rate for the optimizer (gradient descent)\nn_epochs = 1000 # number of iterations to train the model\ndisplay_epoch = 100 # display the cost for every display_step iteration",
"_____no_output_____"
],
[
"# make up some trainig data\nX_train = np.asarray([3.3,4.4,5.5,6.71,6.93,4.168,9.779,6.182,7.59,\n 2.167,7.042,10.791,5.313,7.997,5.654,9.27,3.1])\ny_train = np.asarray([1.7,2.76,2.09,3.19,1.694,1.573,3.366,2.596,2.53,\n 1.221,2.827,3.465,1.65,2.904,2.42,2.94,1.3])\n\n# placeholder for the input data\nX = tf.placeholder(tf.float32)\nY = tf.placeholder(tf.float32)\n\n# give the model's parameter a randomized initial value\nW = tf.Variable(np.random.randn(), tf.float32, name = 'weight')\nb = tf.Variable(np.random.randn(), tf.float32, name = 'bias')\n\n# Construct the formula for the linear model\n# we can also do\n# pred = tf.add(tf.multiply(X, W), b)\npred = W * X + b\n\n# we then define the loss function that the model is going to optimize on,\n# here we use the standard mean squared error, which is sums the squares of the\n# prediction and the true y divided by the number of observations, note\n# that we're computing the difference between the prediction and the y label\n# from the placeholder\ncost = tf.reduce_mean(tf.pow(pred - Y, 2))\n\n# after defining the model structure and the function to optimize on,\n# tensorflow provides several optimizers that can do optimization task\n# for us, the simplest one being gradient descent\noptimizer = tf.train.GradientDescentOptimizer(learning_rate)\ntrain = optimizer.minimize(cost)\n\n# initializing the variables\ninit = tf.global_variables_initializer()",
"_____no_output_____"
],
[
"# change default figure and font size\nplt.rcParams['figure.figsize'] = 8, 6 \nplt.rcParams['font.size'] = 12\n\n# Launch the graph\nwith tf.Session() as sess:\n sess.run(init)\n feed_dict = {X: X_train, Y: y_train}\n\n # Fit on all the training data\n for epoch in range(n_epochs):\n #for x, y in zip(X_train, y_train):\n sess.run(train, feed_dict = feed_dict)\n\n #Display logs per epoch step\n if (epoch + 1) % display_epoch == 0:\n # run the cost to obtain the value for the cost function at each step\n c = sess.run(cost, feed_dict = feed_dict)\n print(\"Epoch: {}, cost: {}\".format(epoch + 1, c))\n\n print(\"Optimization Finished!\")\n c = sess.run(cost, feed_dict = feed_dict)\n weight = sess.run(W)\n bias = sess.run(b)\n print(\"Training cost: {}, W: {}, b: {}\".format(c, weight, bias))\n\n # graphic display\n plt.plot(X_train, y_train, 'ro', label='Original data')\n plt.plot(X_train, weight * X_train + bias, label = 'Fitted line')\n plt.legend()\n plt.show()",
"Epoch: 100, cost: 0.18693093955516815\nEpoch: 200, cost: 0.1741979718208313\nEpoch: 300, cost: 0.1663670837879181\nEpoch: 400, cost: 0.16155104339122772\nEpoch: 500, cost: 0.15858913958072662\nEpoch: 600, cost: 0.15676751732826233\nEpoch: 700, cost: 0.15564727783203125\nEpoch: 800, cost: 0.15495829284191132\nEpoch: 900, cost: 0.15453457832336426\nEpoch: 1000, cost: 0.15427397191524506\nOptimization Finished!\nTraining cost: 0.15427397191524506, W: 0.24345557391643524, b: 0.856789231300354\n"
]
],
[
[
"## MNIST Using Softmax\n\nMNIST is a simple computer vision dataset. It consists of images of handwritten digits like these:\n\n<img src='images/mnist.png'>\n\nEach image is 28 pixels by 28 pixels, which is essentially a $28 \\times 28$ array of numbers. To use it in a context of a machine learning problem, we can flatten this array into a vector of $28 \\times 28 = 784$, this will be the number of features for each image. It doesn't matter how we flatten the array, as long as we're consistent between images. Note that, flattening the data throws away information about the 2D structure of the image. Isn't that bad? Well, the best computer vision methods do exploit this structure. But the simple method we will be using here, a softmax regression (defined below), won't.\n\nThe dataset also includes labels for each image, telling us the each image's label. For example, the labels for the above images are 5, 0, 4, and 1. Here we're going to train a softmax model to look at images and predict what digits they are. The possible label values in the MNIST dataset are numbers between 0 and 9, hence this will be a 10-class classification problem.",
"_____no_output_____"
]
],
[
[
"# convenient one-liner to load the dataset\nfrom tensorflow.examples.tutorials.mnist import input_data\nmnist = input_data.read_data_sets('MNIST_data/', one_hot = True)",
"Extracting MNIST_data/train-images-idx3-ubyte.gz\nExtracting MNIST_data/train-labels-idx1-ubyte.gz\nExtracting MNIST_data/t10k-images-idx3-ubyte.gz\nExtracting MNIST_data/t10k-labels-idx1-ubyte.gz\n"
]
],
[
[
"The downloaded data is split into three parts, 55,000 data points of training data (mnist.train), 10,000 points of test data (mnist.test), and 5,000 points of validation data (mnist.validation).\n\nEvery part of the dataset contains the data and label and we can access them via `.images` and `.labels`. e.g. the training images are mnist.train.images and the train labels are mnist.train.labels (one-hot encoded).",
"_____no_output_____"
]
],
[
[
"# pixels \nprint(mnist.train.images.shape)\nmnist.train.images",
"(55000, 784)\n"
],
[
"# one-hot encoded labels\nprint(mnist.train.labels.shape)\nmnist.train.labels",
"(55000, 10)\n"
]
],
[
[
"In the following code chunk, we define the overall computational graph/structure for the softmax classifier using the cross entropy cost function as the objective. Recall that the formula for this function can be denoted as:\n\n$$L = -\\sum_i y'_i \\log(y_i)$$\n\nWhere y is our predicted probability distribution, and y′ is the true distribution.",
"_____no_output_____"
]
],
[
[
"# define some global variables\nlearning_rate = 0.5 \nbatch_size = 100\nn_iterations = 1000\nn_features = mnist.train.images.shape[1]\nn_class = mnist.train.labels.shape[1]\n\n# define the input and output \n# here None means that a dimension can be of any length,\n# which is what we want, since the number of observations\n# we have can vary;\n# note that the shape argument to placeholder is optional, \n# but it allows TensorFlow to automatically catch bugs stemming \n# from inconsistent tensor shapes\nX = tf.placeholder(tf.float32, [None, n_features])\ny = tf.placeholder(tf.float32, [None, n_class])\n\n# initialize both W and b as tensors full of zeros. \n# these are parameters that the model is later going to learn,\n# Notice that W has a shape of [784, 10] because we want to multiply \n# the 784-dimensional image vectors by it to produce 10-dimensional \n# vectors of evidence for the difference classes. b has a shape of [10] \n# so we can add it to the output.\nW = tf.Variable(tf.zeros([n_features, n_class]))\nb = tf.Variable(tf.zeros([n_class]))",
"_____no_output_____"
]
],
[
[
"```python\n# to define the softmax classifier and cross entropy cost\n# we can do the following\n\n# matrix multiplication using the .matmul command\n# and add the softmax output\noutput = tf.nn.softmax( tf.matmul(X, W) + b )\n\n# cost function: cross entropy, the reduce mean is simply the average of the\n# cost function across all observations\ncross_entropy = tf.reduce_mean( -tf.reduce_sum(y * tf.log(output), axis = 1) )\n\n```",
"_____no_output_____"
]
],
[
[
"# but for numerical stability reason, the tensorflow documentation\n# suggests using the following function\noutput = tf.matmul(X, W) + b\ncross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels = y, logits = output))",
"_____no_output_____"
]
],
[
[
"Now that we defined the structure of our model, we'll:\n\n1. Define a optimization algorithm the train it. In this case, we ask TensorFlow to minimize our defined cross_entropy cost using the gradient descent algorithm with a learning rate of 0.5. There are also other off the shelf [optimizers](https://www.tensorflow.org/api_guides/python/train#optimizers) that we can use that are faster for more complex models.\n2. We'll also add an operation to initialize the variables we created\n3. Define helper \"function\" to evaluate the prediction accuracy",
"_____no_output_____"
]
],
[
[
"train_step = tf.train.GradientDescentOptimizer(learning_rate).minimize(cross_entropy)\ninit = tf.global_variables_initializer()\n\n# here we're return the predicted class of each observation using argmax\n# and see if the ouput (prediction) is equal to the target variable (y)\n# since equal is a boolean type tensor, we cast it to a float type to compute\n# the actual accuracy\ncorrect_prediction = tf.equal(tf.argmax(y, axis = 1), tf.argmax(output, axis = 1))\naccuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))",
"_____no_output_____"
]
],
[
[
"Now it's time to run it. During each step of the loop, we get a \"batch\" of one hundred random data points (defined by `batch_size`) from our training set. We run train_step feeding in the batches data to replace the placeholders.\n\nUsing small batches of random data is called stochastic training -- in this case, stochastic gradient descent. Ideally, we'd like to use all our data for every step of training because that would give us a better sense of what we should be doing, but that's expensive. So, instead, we use a different subset every time. Doing this is cheap and has much of the same benefit.",
"_____no_output_____"
]
],
[
[
"with tf.Session() as sess: \n # initialize the variable, train the \"batch\" gradient descent\n # for a specified number of iterations and evaluate on accuracy score\n # remember the key to the feed_dict dictionary must match the variable we use\n # as the placeholder for the data in the beginning\n sess.run(init)\n for i in range(n_iterations):\n X_batch, y_batch = mnist.train.next_batch(batch_size)\n _, acc = sess.run([train_step, accuracy], feed_dict = {X: X_batch, y: y_batch})\n \n # simply prints the training data's accuracy for every 100 iteration\n if i % 100 == 0:\n print(acc)\n \n # after training evaluate the accuracy on the testing data\n acc = sess.run(accuracy, feed_dict = {X: mnist.test.images, y: mnist.test.labels})\n print('test:', acc)",
"0.05\n0.89\n0.9\n0.91\n0.87\n0.93\n0.94\n0.9\n0.93\n0.92\ntest: 0.9166\n"
]
],
[
[
"Notice that we did not have to worry about computing the gradient to update the model, the nice thing about Tensorflow is that, once we've defined the structure of our model it has the capability to automatically differentiate mathematical expressions. This means we no longer need to compute the gradients ourselves! In this example, our softmax classifier obtained pretty nice result around 92%. But we can certainly do better with more advanced techniques such as convolutional deep learning.",
"_____no_output_____"
],
[
"# Reference\n\n- [Blog: What is a TensorFlow Session?](http://danijar.com/what-is-a-tensorflow-session/)\n- [Github: Tensorflow Examples - Linear Regression](https://github.com/aymericdamien/TensorFlow-Examples/blob/master/notebooks/2_BasicModels/linear_regression.ipynb)\n- [Tensorflow Documentation: Getting Started With TensorFlow](https://www.tensorflow.org/get_started/get_started)\n- [TensorFlow Documentation: MNIST For ML Beginners](https://www.tensorflow.org/get_started/mnist/beginners)",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown"
] | [
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
]
] |
ecadc1593c5b372af1e603650c8280f8711dea64 | 493,473 | ipynb | Jupyter Notebook | 01Mobjects_Basics.ipynb | Manim-Resources/mobject-gallery | 5fe6b4a71e67f97e68707354d1c0d971fe4c6ea3 | [
"MIT"
] | 11 | 2021-09-18T16:09:22.000Z | 2022-03-28T05:12:34.000Z | 01Mobjects_Basics.ipynb | Manim-Resources/mobject-gallery | 5fe6b4a71e67f97e68707354d1c0d971fe4c6ea3 | [
"MIT"
] | null | null | null | 01Mobjects_Basics.ipynb | Manim-Resources/mobject-gallery | 5fe6b4a71e67f97e68707354d1c0d971fe4c6ea3 | [
"MIT"
] | 5 | 2021-11-30T12:47:06.000Z | 2022-03-22T10:59:13.000Z | 230.164646 | 93,598 | 0.911868 | [
[
[
"import json\nimport time\nfrom base64 import b64decode\nfrom io import BytesIO, StringIO\nfrom IPython import get_ipython\nfrom IPython.core.magic import register_cell_magic\nfrom IPython.utils.capture import capture_output\nfrom IPython.core.interactiveshell import InteractiveShell\n\nfrom manim import *\nparams = f\" -v WARNING -r {80*4},{40*4} -s --disable_caching Example\"\nimport PIL\n\ncell_counter = 0\n\n@register_cell_magic\ndef capture_png(line, cell):\n global cell_counter\n cell_counter += 1\n # init capturing cell output\n get_ipython().run_cell_magic(\n 'capture',\n ' --no-stderr --no-stdout result',\n cell\n )\n argument_array = line.split('--style')\n post_path = argument_array[0].strip()\n chapter_name_underscore = chapter_name.replace(\" \", \"_\")\n\n path = f\"gallery_assets/{chapter_name_underscore}_{cell_counter:03}_{post_path}\"\n\n # path = path.split(\".png\")[0] + str(time.time_ns()) + \".png\" time stemps not needed\n if not path:\n raise ValueError('No path found!')\n\n style = str(*argument_array[1:])\n style = style.strip()\n style = style.strip('\"') # remove quotes\n\n default_style = \"\"\n\n style = default_style + style\n\n raw_code_block = cell\n code_block = \"\"\n\n for codeline in StringIO(raw_code_block):\n if \"#NOT\" in codeline:\n pass\n else:\n code_block += codeline\n \n new_codeblock = \"\"\n for codeline in StringIO(code_block):\n if \"#ONLY\" in codeline:\n codeline= codeline.replace(\"#ONLY\", \"\") \n if codeline.startswith(\" \"): # delete the indention for manim -> TODO this can be made prettier!\n codeline = codeline[8:]\n\n new_codeblock += codeline\n else:\n pass\n \n if new_codeblock: # checks if there are lines that include \"#ONLY\"\n code_block = new_codeblock\n\n code_block = code_block.replace(\"'\", \"'\") # make sure that javascript can read the single quote character\n code_block = code_block.strip(\"\\n\")\n\n with open(joson_file_path, \"r\") as jsonFile:\n data = json.load(jsonFile)\n\n if not chapter_name in data:\n data[chapter_name] = []\n\n chapter_content = data[chapter_name]\n chapter_content.append(\n {\"image_path\": path,\n \"celltype\": \"Normal\",\n \"css\": style,\n \"code\": code_block})\n\n data[chapter_name] = chapter_content\n with open(joson_file_path, \"w\") as jsonFile:\n json.dump(data, jsonFile, indent=2, sort_keys=False)\n\n shell = InteractiveShell.instance()\n # save the output\n with capture_output(stdout=False, stderr=False, display=True) as result:\n shell.run_cell(cell) # idea by @krassowski \n\n # save image\n for output in result.outputs:\n display(output)\n data = output.data\n if 'image/png' in data:\n png_bytes = data['image/png']\n if isinstance(png_bytes, str):\n png_bytes = b64decode(png_bytes)\n assert isinstance(png_bytes, bytes)\n bytes_io = BytesIO(png_bytes)\n image = PIL.Image.open(bytes_io)\n image.save(path, 'png')\n\njoson_file_path = \"gallery_assets/gallery_parameters.json\"\nchapter_name = \"Basic Shapes\"\nname_snippet_pairs = {}",
"_____no_output_____"
],
[
"%%capture_png Dot.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Dot(color = YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.width = mob.width + 2*SMALL_BUFF\n # self.camera.frame.scale(1/20)",
"_____no_output_____"
],
[
"%%capture_png Circle.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Circle(fill_opacity=1, fill_color= ORANGE, stroke_color=YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 3*SMALL_BUFF\n\n",
"_____no_output_____"
],
[
"%%capture_png Annulus.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Annulus(inner_radius=0.5, outer_radius=1.2,fill_color= DARK_BLUE, stroke_color=YELLOW, stroke_width=2) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 3*SMALL_BUFF\n\n",
"_____no_output_____"
],
[
"%%capture_png Ellipse.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Ellipse(color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 2*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png Sector.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Sector(inner_radius=0.5, outer_radius=1.2,fill_color= DARK_BLUE, stroke_color=YELLOW, stroke_width=2) #ONLY\n self.add(mob)\n mob.move_to(ORIGIN+UR*0.05)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 5*SMALL_BUFF\n\n",
"_____no_output_____"
],
[
"%%capture_png Arc.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Arc(radius=1.3, start_angle=-PI/8, angle=PI,color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 3*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png ArcBetweenPoints.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = ArcBetweenPoints(start=2 * RIGHT, end=2*LEFT, stroke_color=YELLOW) #ONLY\n mob = VGroup(mob, Dot(2 * RIGHT, radius=0.4), Dot(2*LEFT,radius=0.4) )\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 1*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png Line.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Line(color= YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 2*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png DashedLine.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = DashedLine(0.2*LEFT, 0.2*RIGHT,color= YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.width = mob.width + 2*SMALL_BUFF\n \n",
"_____no_output_____"
],
[
"%%capture_png DashedCircle.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n circ = Circle(stroke_color=YELLOW) #ONLY\n mob = DashedVMobject(circ, num_dashes=10) #ONLY\n\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 4*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png Square.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Square(color= YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 3.5*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png Rectangle.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Rectangle(width=3.5, height=2.0, color= YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.height = mob.height + 1*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png Rectangle_grid.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Rectangle(width=4, height=2.0,grid_xstep=2, grid_ystep=1,color= YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.width = mob.width + 1.5*SMALL_BUFF\n",
"_____no_output_____"
],
[
"%%capture_png RoundedRectangle1.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= RoundedRectangle(corner_radius=0.5, color= YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.scale(1/25)\n",
"_____no_output_____"
],
[
"%%capture_png RoundedRectangle2.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= RoundedRectangle(corner_radius=0.8, height=2.2, width=2.2,color= YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png Elbow.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Elbow(width=0.5, angle=0*DEGREES,color= YELLOW) #ONLY\n self.add(mob)\n mob.move_to(ORIGIN)\n self.camera.frame.scale(1/10)",
"_____no_output_____"
],
[
"%%capture_png RightAngle.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n line1 = Line( ORIGIN, RIGHT ) #ONLY\n line2 = Line( ORIGIN, UP ) #ONLY\n mob = RightAngle(line1, line2, color=YELLOW, stroke_width=7) #ONLY\n self.add(VGroup(mob,line1, line2).shift(DL*0.3)) #ONLY\n self.camera.frame.scale(1/6)",
"_____no_output_____"
],
[
"%%capture_png Angledot.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n line1 = Line( LEFT*0.2, RIGHT ) #ONLY\n line2 = Line( DOWN*0.2, UP ) #ONLY\n a= Angle(line1, line2, dot=True, color=YELLOW, dot_color=YELLOW) #ONLY\n self.add(VGroup(line1, line2, a).move_to(ORIGIN)) #ONLY\n self.camera.frame.scale(1/5)",
"_____no_output_____"
],
[
"%%capture_png Angle_get_value.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n line1 = Line((LEFT+(1/3)*UP)*0.1, RIGHT+(1/3)*DOWN) #ONLY\n line2 = Line((DOWN+(1/3)*RIGHT)*0.1, UP+(1/3)*LEFT) #ONLY\n angle = Angle(line1, line2, radius=0.3) #ONLY\n value = Integer(angle.get_value(degrees=True), unit=\"^{\\circ}\", color=YELLOW) #ONLY\n value.next_to(angle, UR,buff=0) #ONLY\n\n self.add(VGroup(line1, line2, angle, value).move_to(ORIGIN)) #ONLY\n self.camera.frame.scale(1/5)",
"_____no_output_____"
],
[
"%%capture_png Triangle.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Triangle(color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png Cross.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Cross(stroke_color = YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png Star.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= Star(color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.2)\n self.camera.frame.scale(1/14)",
"_____no_output_____"
],
[
"%%capture_png RegularPolygram5.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= RegularPolygram(5,color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.2)\n self.camera.frame.scale(1/15)\n",
"_____no_output_____"
],
[
"%%capture_png RegularPolygram6.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= RegularPolygram(6,color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.2)\n self.camera.frame.scale(1/15)",
"_____no_output_____"
],
[
"%%capture_png RegularPolygon5.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= RegularPolygon(5,color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png RegularPolygon6.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob= RegularPolygon(6,color= YELLOW) #ONLY\n mob.move_to(ORIGIN)\n self.add(mob)\n mob.scale(0.1)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png CutOut.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n s1 = Square().scale(2.5) #ONLY\n s2 = Star().shift(LEFT) #ONLY\n s3 = Circle().shift(RIGHT) #ONLY\n c = Cutout(s1, s2, s3, fill_opacity=1, color=YELLOW) #ONLY\n self.add(c)\n",
"_____no_output_____"
],
[
"%%capture_png TwoCircles.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.frame.scale(1/25) #ONLY\n mob = Circle(color= YELLOW, fill_opacity=1,stroke_width=0).scale(0.1) #ONLY\n mob2 = Circle(color= ORANGE, fill_opacity=1,stroke_width=0).scale(0.1) #ONLY\n x=VGroup(mob,mob2).arrange(RIGHT, buff=-0.1) #ONLY\n self.add(x)",
"_____no_output_____"
],
[
"%%capture_png TwoCirclesIntersection.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.frame.scale(1/25)\n mob = Circle(color= YELLOW, fill_opacity=1,stroke_width=0).scale(0.1)\n mob2 = Circle(color= ORANGE, fill_opacity=1,stroke_width=0).scale(0.1)\n x=VGroup(mob,mob2).arrange(RIGHT, buff=-0.1)\n bg=BackgroundRectangle(x, fill_opacity=0.8).scale(2)\n inter = Intersection(mob, mob2, color=YELLOW, fill_opacity=1,stroke_width=0) #ONLY\n self.add(mob,mob2,bg,inter)",
"_____no_output_____"
],
[
"%%capture_png TwoCirclesExclusion.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.frame.scale(1/25)\n mob = Circle(color= YELLOW, fill_opacity=1,stroke_width=0).scale(0.1)\n mob2 = Circle(color= ORANGE, fill_opacity=1,stroke_width=0).scale(0.1)\n x=VGroup(mob,mob2).arrange(RIGHT, buff=-0.1)\n bg=BackgroundRectangle(x, fill_opacity=0.8).scale(2)\n ex = Exclusion(mob2, mob, color=YELLOW, fill_opacity=1,stroke_width=0) #ONLY\n self.add(mob,mob2,bg,ex)\n ",
"_____no_output_____"
],
[
"%%capture_png TwoCirclesDifference.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.frame.scale(1/25)\n mob = Circle(color= YELLOW, fill_opacity=1,stroke_width=0).scale(0.1)\n mob2 = Circle(color= ORANGE, fill_opacity=1,stroke_width=0).scale(0.1)\n x=VGroup(mob,mob2).arrange(RIGHT, buff=-0.1)\n bg=BackgroundRectangle(x, fill_opacity=0.8).scale(2)\n diff = Difference(mob, mob2, color=YELLOW, fill_opacity=1,stroke_width=0) #ONLY\n self.add(mob,mob2,bg,diff)\n ",
"_____no_output_____"
],
[
"%%capture_png TwoCirclesUnion.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.frame.scale(1/25)\n mob = Circle(color= YELLOW, fill_opacity=1,stroke_width=0).scale(0.1)\n mob2 = Circle(color= ORANGE, fill_opacity=1,stroke_width=0).scale(0.1)\n x=VGroup(mob,mob2).arrange(RIGHT, buff=-0.1)\n bg=BackgroundRectangle(x, fill_opacity=0.8).scale(2)\n uni = Union(mob, mob2, color=YELLOW, fill_opacity=1,stroke_width=0) #ONLY\n self.add(mob,mob2,bg,uni)\n ",
"_____no_output_____"
],
[
"%%capture_png Arrow.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Arrow(0.2*LEFT, 0.2*RIGHT,color= YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png ArrowSquareTip.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Arrow(0.2*LEFT, 0.2*RIGHT,color= YELLOW, tip_shape=ArrowSquareTip) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png ArrowSquareFilledTip.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Arrow(0.2*LEFT, 0.2*RIGHT,color= YELLOW, tip_shape=ArrowSquareFilledTip) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png ArrowCircleTip.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Arrow(0.2*LEFT, 0.2*RIGHT,color= YELLOW, tip_shape=ArrowCircleTip) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png ArrowCircleFilledTip.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Arrow(0.2*LEFT, 0.2*RIGHT,color= YELLOW, tip_shape=ArrowCircleFilledTip) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png DoubleArrow.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = DoubleArrow(0.2*LEFT, 0.2*RIGHT,color= YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/25)",
"_____no_output_____"
],
[
"%%capture_png CurvedArrow.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = CurvedArrow(LEFT,RIGHT,color= YELLOW) #ONLY\n self.add(mob)\n mob.move_to(ORIGIN)\n self.camera.frame.scale(1/6)",
"_____no_output_____"
],
[
"%%capture_png ParametricFunction.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = ParametricFunction(lambda t: [t,0.2*np.sin(10*t),0],t_range = [-TAU, TAU],color= YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/10)",
"_____no_output_____"
],
[
"%%capture_png CubicBezier.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n p1 = [-3, 1, 0] #ONLY\n p1b= p1 + 5 * RIGHT + 2 * UP #ONLY\n p2 = [3, -1, 0] #ONLY\n p2b = p2 + 5 * LEFT #ONLY\n mob = CubicBezier(p1,p1b, p2b, p2, color=YELLOW) #ONLY\n self.add(mob)\n mob.scale(0.1)\n mob.move_to(ORIGIN)\n self.camera.frame.width = mob.width + 2*SMALL_BUFF",
"_____no_output_____"
],
[
"%%capture_png Brace.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Brace(Line(LEFT*0.5,RIGHT*0.5),color= YELLOW) #ONLY\n self.add(mob)\n mob.move_to(ORIGIN)\n self.camera.frame.width = mob.width + 3*SMALL_BUFF",
"_____no_output_____"
],
[
"%%capture_png BraceLabel.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n l=Line(ORIGIN, RIGHT*1.4) #ONLY\n mob= BraceLabel(l, text= r\"14 \\, \\text{cm}\", color= YELLOW, buff=0.1) #ONLY\n mob.submobjects[1].set_color(YELLOW) #ONLY\n self.add(VGroup(l,mob).move_to(ORIGIN)) #ONLY\n self.camera.frame.height = mob.height + 4*SMALL_BUFF ",
"_____no_output_____"
],
[
"%%capture_png ArcBrace.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n arc = Arc(radius=0.5,start_angle=0,angle=5*PI/6) #ONLY\n brace = ArcBrace(arc).set_color(YELLOW) #ONLY\n mob = VGroup(arc,brace) \n self.add(mob)\n mob.move_to(ORIGIN)\n self.camera.frame.scale(1/8)",
"_____no_output_____"
],
[
"%%capture_png AnnotationDot.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = AnnotationDot(stroke_color=YELLOW, fill_color=ORANGE) #ONLY\n self.add(mob)\n mob.move_to(ORIGIN)\n self.camera.frame.scale(1/15)",
"_____no_output_____"
],
[
"%%capture_png LabeledDot.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = LabeledDot(Tex(\"42\", color=BLACK), color=YELLOW) #ONLY\n self.add(mob)\n mob.move_to(ORIGIN)\n self.camera.frame.scale(1/10)",
"_____no_output_____"
],
[
"%%capture_png ManimBanner.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = ManimBanner() #ONLY\n self.add(mob)\n self.camera.frame.scale(1/1.5)",
"_____no_output_____"
],
[
"%%capture_png HTMLBanner.png\n%%manim $params\n#-v WARNING -r 80,80 -s --disable_caching Example\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.background_color = \"#ece6e2\" #HEREFROM\n logo_green = \"#87c2a5\"\n logo_blue = \"#525893\"\n logo_red = \"#e07a5f\"\n circle = Circle(color=logo_green, fill_opacity=1).shift(LEFT)\n square = Square(color=logo_blue, fill_opacity=1).shift(UP)\n triangle = Triangle(color=logo_red, fill_opacity=1).shift(RIGHT)\n logo = VGroup(triangle, square, circle).scale(1.3)#.scale(2.0) #HERETO\n logo.move_to(ORIGIN)\n self.add(logo)\n self.camera.frame.scale(1/1.5)",
"_____no_output_____"
],
[
"%%capture_png FlyingFramesBanner.png\n%%manim $params\n#-v WARNING -r 80,80 -s --disable_caching Example\n\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.background_color = \"#ece6e2\" #HEREFROM\n logo_green = \"#87c2a5\"\n logo_blue = \"#525893\"\n logo_red = \"#e07a5f\" \n logo_black = BLACK\n d= Dot(color= logo_green, radius=0.8).shift(UR*0.6)\n l = VGroup(*[Line(color=logo_blue, stroke_width=70/3) for _ in range(0,3)])\n l.arrange(DOWN,buff=0.45).next_to(d, LEFT).shift(0.3*LEFT)\n l[0::2].shift(0.3*RIGHT)\n l.rotate(30*DEGREES, about_point=d.get_center())\n arc= Arc(radius=1.0, color= logo_red, start_angle=PI/4, angle=PI, stroke_width=70)\n arc.shift(1.75*DOWN+1.15*RIGHT)\n self.add(arc, d,l) #HERETO\n self.camera.frame.width = 3 *2 # take this *2 out for logo creation",
"_____no_output_____"
],
[
"%%capture_png ImageMobject.png\n%%manim $params\n\nfrom PIL import Image\nimport requests\nimage = Image.open(requests.get(\"https://raw.githubusercontent.com/scikit-image/scikit-image/main/skimage/data/chelsea.png\", stream=True).raw)\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = ImageMobject(image).scale(2) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/1.5)",
"_____no_output_____"
],
[
"%%capture_png ImageMobject_nearest.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n np.random.seed(41)\n a= np.random.randint(0, 255, size=(3, 4)) #ONLY\n img = ImageMobject(np.uint8(a)) #ONLY\n img.height = 6 #ONLY\n img.set_resampling_algorithm(RESAMPLING_ALGORITHMS[\"nearest\"]) #ONLY\n self.add(img)",
"_____no_output_____"
],
[
"%%capture_png ImageMobject_cubic.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n np.random.seed(41) #ONLY\n a= np.random.randint(0, 255, size=(3, 4)) #ONLY\n img = ImageMobject(np.uint8(a)) #ONLY\n img.height = 6 #ONLY\n img.set_resampling_algorithm(RESAMPLING_ALGORITHMS[\"cubic\"]) #ONLY\n self.add(img)",
"_____no_output_____"
],
[
"%%capture_png SVGMobject.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = SVGMobject(\"svg_logo.svg\") #ONLY\n self.add(mob)\n self.camera.frame.scale(1/3)",
"_____no_output_____"
],
[
"%%capture_png Matrix.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = Matrix([[9, 3], [1, 5]]) #ONLY\n bra = mob.get_brackets() #ONLY\n bra.set_color(YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/4)",
"_____no_output_____"
],
[
"%%capture_png Matrix_SurroundingRectangle.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = Matrix([[\"\\pi\", 3], [1, 5]]) #ONLY\n mob.add(SurroundingRectangle(mob.get_columns()[1])) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/4)",
"_____no_output_____"
],
[
"%%capture_png MobjectMatrix.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n a = Circle(color=YELLOW).scale(0.3) #ONLY\n b = Square().scale(0.3) #ONLY\n c = MathTex(\"\\pi\").scale(2) #ONLY\n d = Star(color=YELLOW).scale(0.3) #ONLY\n mob = MobjectMatrix([[a, b], [c, d]]) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/3.5)",
"_____no_output_____"
],
[
"%%capture_png Matrix_bracket.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = Matrix([[2, 0, 4], [-1, 1, 5]], #ONLY\n v_buff=0.8, #ONLY\n h_buff=0.8, #ONLY\n bracket_h_buff=SMALL_BUFF, #ONLY\n bracket_v_buff=SMALL_BUFF, #ONLY\n left_bracket=\"\\{\", #ONLY\n right_bracket=\"\\}\") #ONLY\n mob.set_row_colors(YELLOW, YELLOW) #ONLY\n self.add(mob)\n self.camera.frame.scale(1/4)",
"_____no_output_____"
],
[
"%%capture_png Table_add_highlighted_cell.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n mob = Table( #ONLY\n [[\"12\", \"200\"], #ONLY\n [\"55\",\"393\"]], include_outer_lines=True) #ONLY\n mob.add_highlighted_cell((1,2), color=YELLOW) #ONLY\n mob.add_highlighted_cell((2,2), color=RED) #ONLY\n\n self.add(mob)\n self.camera.frame.scale(1/2.7)",
"_____no_output_____"
],
[
"%%capture_png Code.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.background_color = \"#ece6e2\" #HEREFROM\n code= \"\"\"j = 1 \nk = \"Hello\" \"\"\"\n rendered_code = Code(code=code, background_stroke_color= WHITE, tab_width=2, background=\"window\",\n language=\"Python\", font=\"Monospace\").scale(3.7) #HERETO\n rendered_code[2].set_color(YELLOW)\n rendered_code[2].set_stroke(width=5) \n self.add(rendered_code)",
"_____no_output_____"
],
[
"%%capture_png NumberPlane.png\n%%manim $params\nclass Example(ZoomedScene):\n def construct(self):\n number_plane = NumberPlane( #HEREFROM\n x_range=[-10, 10, 1],\n y_range=[-10, 10, 1],\n stroke_width=100,\n axis_config = {\n \"stroke_color\": YELLOW,\n \"stroke_width\": 20,\n },\n background_line_style={\n \"stroke_color\": GREY,\n \"stroke_width\": 15,\n \"stroke_opacity\": 1\n }\n )\n self.add(number_plane) #HERETO\n self.camera.frame.scale(1/2)",
"_____no_output_____"
],
[
"%%capture_png NumberLine.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = NumberLine( #HEREFROM\n x_range=[-4, 4, 2],\n length=2,\n color=YELLOW,\n include_numbers=True,\n label_direction=UP,\n )\n\n self.add(mob.move_to(ORIGIN)) #HERETO\n self.camera.frame.scale(1/5)",
"_____no_output_____"
],
[
"%%capture_png NumberLine_rotation.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = NumberLine( #HEREFROM\n x_range=[0, 4, 1],\n length=2,\n include_tip=True,\n color=YELLOW,\n include_numbers=True,\n rotation=10 * DEGREES,\n )\n self.add(mob.move_to(ORIGIN)) #HERETO\n self.camera.frame.scale(1/5)",
"_____no_output_____"
],
[
"%%capture_png NumberLine_decimal.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n mob = NumberLine( #HEREFROM\n x_range=[-4, 4, 2.5], \n length=3,\n decimal_number_config={\"num_decimal_places\": 2},\n include_numbers=True,\n )\n mob.numbers[2].set_color(YELLOW) #HERETO\n self.add(mob.move_to(ORIGIN))\n self.camera.frame.scale(1/5)",
"_____no_output_____"
],
[
"%%capture_png BarChart.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n vals = [1, 3, 2, 5] #HEREFROM\n labels = [\n \"foo\",\n \"bar\",\n \"foo3\",\n \"foo2\",\n ]\n colors = [\"#003f5c\", \"#58508d\", \"#bc5090\", \"#ff6361\"]\n bar = BarChart(\n vals,\n max_value=max(vals),\n bar_colors=colors,\n bar_names=labels,\n bar_label_scale_val=1,\n ) #HERETO\n self.add(bar) \n self.camera.frame.scale(1/1.4)",
"_____no_output_____"
],
[
"%%capture_png Light_change_default.png\n%%manim $params\n\nclass Example(ZoomedScene):\n def construct(self):\n self.camera.background_color = WHITE #HEREFROM\n Text.set_default(color=BLACK)\n Line.set_default(color=YELLOW)\n Line.set_default(stroke_width=20)\n\n mob = Text(\"Light Mode\") \n l=Line(2*LEFT,2*RIGHT).next_to(mob,DOWN)\n self.add(mob,l)\n\n Line.set_default()\n Text.set_default() #HERETO\n self.camera.frame.scale(1/4)",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecade4b4cb962d109a074dad9fd1ef051d4d92a1 | 319,861 | ipynb | Jupyter Notebook | notebooks/UK Population Analysis-checkpoint.ipynb | mjam03/corona | d55dcb4ac70c2b7c42af65cd1ab68482bbfe2e6c | [
"MIT"
] | null | null | null | notebooks/UK Population Analysis-checkpoint.ipynb | mjam03/corona | d55dcb4ac70c2b7c42af65cd1ab68482bbfe2e6c | [
"MIT"
] | null | null | null | notebooks/UK Population Analysis-checkpoint.ipynb | mjam03/corona | d55dcb4ac70c2b7c42af65cd1ab68482bbfe2e6c | [
"MIT"
] | null | null | null | 141.531416 | 102,940 | 0.808185 | [
[
[
"# What does the UK population and Mortality Look Like?",
"_____no_output_____"
]
],
[
[
"from IPython.core.display import HTML\n\nimport datetime as dt\nfrom io import StringIO\nimport json\nimport matplotlib as mpl\nimport matplotlib.pyplot as plt\nimport pandas as pd\nimport requests\nimport seaborn as sns\nimport warnings\n\nwarnings.filterwarnings('ignore')\n\npd.options.display.max_columns = None\npd.options.display.float_format = '{:,.2f}'.format\n%config Completer.use_jedi = False",
"_____no_output_____"
],
[
"# url to the ONS weekly death spreadsheet report\nDEATHS_URL = 'https://www.ons.gov.uk/file?uri=%2fpeoplepopulationandcommunity%2fbirthsdeathsandmarriages%2fdeaths%2fdatasets%2fweeklyprovisionalfiguresondeathsregisteredinenglandandwales%2f2020/publishedweek522020.xlsx'\n# url to the ONS population spreadsheet\nPOP_URL = 'https://www.ons.gov.uk/file?uri=%2fpeoplepopulationandcommunity%2fpopulationandmigration%2fpopulationestimates%2fdatasets%2fpopulationestimatesforukenglandandwalesscotlandandnorthernireland%2fmid2019april2020localauthoritydistrictcodes/ukmidyearestimates20192020ladcodes.xls'\n# url to the UK life tables\nLT_URL = 'https://www.ons.gov.uk/file?uri=%2fpeoplepopulationandcommunity%2fbirthsdeathsandmarriages%2flifeexpectancies%2fdatasets%2fnationallifetablesunitedkingdomreferencetables%2fcurrent/nationallifetables3yearuk.xlsx'",
"_____no_output_____"
]
],
[
[
"## 1. UK Population Estimate",
"_____no_output_____"
],
[
"Taking the UK as a whole, the population is estimated using 'stocks' and 'flows':\n - Census data at time _t_: This sets the 'stock' of people at each age group\n - Births and deaths since _t_: This gives the 'flow' of people between censuses\n - Potential immigration both ways: Another flow to be taken into account\n \nOnce we go within geographies then inter UK immigration then needs to be taken into account (not required here)",
"_____no_output_____"
],
[
"__Get the ONS Population Estimates__",
"_____no_output_____"
]
],
[
[
"res_pop = requests.get(POP_URL)\nif res_pop.status_code == 200:\n xl_pop = pd.ExcelFile(res_pop.content)",
"_____no_output_____"
]
],
[
[
"ONS Population Spreadsheet tab names",
"_____no_output_____"
]
],
[
[
"xl_pop.sheet_names",
"_____no_output_____"
]
],
[
[
"### 1a. Population Distribution of the UK by Age",
"_____no_output_____"
]
],
[
[
"df_uk_pop = pd.read_excel(xl_pop, sheet_name='MYE2 - Persons', header=4)\ndf_uk_pop = df_uk_pop[~df_uk_pop.Name.isna()]\ndf_uk_pop = df_uk_pop.rename(columns={'Geography1': 'Geography'})\ndf_uk_pop[df_uk_pop.Geography == 'Country']",
"_____no_output_____"
],
[
"all_ages = [x for x in df_uk_pop.columns if x not in ['Code', 'Name', 'Geography', 'All ages']]",
"_____no_output_____"
],
[
"df_pop_by_country = df_uk_pop[df_uk_pop.Geography == 'Country'][['Name'] + all_ages]\ndf_pop_by_country = df_pop_by_country[df_pop_by_country.Name.isin(['ENGLAND', 'SCOTLAND', 'WALES', 'NORTHERN IRELAND'])]",
"_____no_output_____"
],
[
"ax = df_pop_by_country.set_index('Name').T.plot(kind='area', figsize=(18,8), cmap='Blues_r');\nplt.title('UK 2019 Est Population Distribution by Constituent Country');\n\nplt.xlabel('Age');\n\nax.get_yaxis().set_major_formatter(mpl.ticker.FuncFormatter(lambda x, p: format(int(x), ',')))\nplt.ylabel('Number of People');",
"_____no_output_____"
]
],
[
[
"Few highlights explained well [here](https://www.ons.gov.uk/peoplepopulationandcommunity/populationandmigration/populationestimates/articles/ourpopulationwherearewehowdidwegetherewherearewegoing/2020-03-27):\n - UK exhibits population composition for a developed country with low infant mortality - i.e. not characterised by a pyramid structure\n - Population density declines >70 --> this is reflective of old people dying (the spike at the end is because those >=90 are grouped together)\n - 'Baby booms' have given rise to the bumps:\n - Bump at ~70: Post WWII baby boom, slightly diminshed vs other bumps due to life expectancy\n - Bump at ~50: 1960s baby boom due to cultural shift forward - beginning of breakdown of traditional female roles\n - Bump at ~30: 1980s/90s boom as more adults capable of children due to 1960s boom\n - Overall the populations of the constituent nations don't seem to differ much",
"_____no_output_____"
]
],
[
[
"df_country_dists = df_pop_by_country.set_index('Name').T / df_pop_by_country.set_index('Name').T.sum(axis=0)\n\nax = df_country_dists.plot(figsize=(18,8), cmap='Purples_r');\nplt.title('UK 2019 Est Population % By Individual Total Population');\n\nplt.xlabel('Age');\n\nvals = ax.get_yticks()\nax.set_yticklabels(['{:,.2%}'.format(x) for x in vals])\nplt.ylabel('% of People vs Each Country Population');",
"_____no_output_____"
]
],
[
[
"So we can confirm that the population distributions of the constituent countries are very similar",
"_____no_output_____"
]
],
[
[
"sns.",
"_____no_output_____"
],
[
"df_pop_by_country.set_index('Name').T.plot(kind='area');",
"_____no_output_____"
],
[
"df_uk_pop = df_uk_pop.melt(id_vars=['Code', 'Name', 'Geography'], value_name='Population', var_name='Age')",
"_____no_output_____"
],
[
"df_uk_pop[df_uk_pop.Geography == 'Country'][['Name'] + all_ages]",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
]
] |
ecade6cee5096c2cf215e17aab0dc29d759aa508 | 593,157 | ipynb | Jupyter Notebook | MachineLearning(Advanced)/p6_graduation_project/3. KNN.ipynb | StudyExchange/Udacity | b8deb014b0f0d56e403e75f1fddb215143b58a83 | [
"MIT"
] | null | null | null | MachineLearning(Advanced)/p6_graduation_project/3. KNN.ipynb | StudyExchange/Udacity | b8deb014b0f0d56e403e75f1fddb215143b58a83 | [
"MIT"
] | null | null | null | MachineLearning(Advanced)/p6_graduation_project/3. KNN.ipynb | StudyExchange/Udacity | b8deb014b0f0d56e403e75f1fddb215143b58a83 | [
"MIT"
] | null | null | null | 1,072.616637 | 579,866 | 0.944038 | [
[
[
"## 2. KNN",
"_____no_output_____"
],
[
"### References:\n1. https://github.com/ypwhs/dogs_vs_cats\n2. https://www.kaggle.com/yangpeiwen/keras-inception-xception-0-47",
"_____no_output_____"
],
[
"### Import pkgs",
"_____no_output_____"
]
],
[
[
"import cv2\nimport numpy as np\nfrom tqdm import tqdm\nimport pandas as pd\nimport os\nimport random\nimport matplotlib.pyplot as plt\nfrom IPython.display import SVG\nfrom keras.utils.vis_utils import model_to_dot",
"Using TensorFlow backend.\n"
],
[
"# from keras.preprocessing import image\n# from keras.models import Model\n# from keras.layers import Dense, GlobalAveragePooling2D\n# from keras import backend as K\n\n# from keras.layers import Input\n# from keras.layers.core import Lambda\n\n# from keras.applications.vgg16 import VGG16\n# from keras.applications.vgg19 import VGG19\n# from keras.applications.resnet50 import ResNet50\n# from keras.applications.inception_v3 import InceptionV3\n# from keras.applications.xception import Xception\n# from keras.applications.inception_resnet_v2 import InceptionResNetV2\n\n\nfrom keras.layers import *\nfrom keras.models import *\nfrom keras.applications import *\nfrom keras.optimizers import *\nfrom keras.regularizers import *\nfrom keras.applications.inception_v3 import preprocess_input",
"_____no_output_____"
]
],
[
[
"### Load data",
"_____no_output_____"
]
],
[
[
"cwd = os.getcwd()\ndf = pd.read_csv(os.path.join(cwd, 'input', 'labels.csv'))\nprint('lables amount: %d' %len(df))\ndf.head()",
"lables amount: 10222\n"
],
[
"n = len(df)\nbreed = set(df['breed'])\nn_class = len(breed)\nclass_to_num = dict(zip(breed, range(n_class)))\nnum_to_class = dict(zip(range(n_class), breed))",
"_____no_output_____"
],
[
"width = 299\nX = np.zeros((n, width, width, 3), dtype=np.uint8)\ny = np.zeros(n, dtype=np.uint8)\nfor i in tqdm(range(n)):\n X[i] = cv2.resize(cv2.imread('.\\\\input\\\\train\\\\%s.jpg' % df['id'][i]), (width, width))\n y[i] = class_to_num[df['breed'][i]]",
"100%|███████████████████████████████████| 10222/10222 [01:10<00:00, 144.26it/s]\n"
]
],
[
[
"### Preview images",
"_____no_output_____"
]
],
[
[
"plt.figure(figsize=(12, 6))\nfor i in range(8):\n random_index = random.randint(0, n-1)\n plt.subplot(2, 4, i+1)\n plt.imshow(X[random_index][:,:,::-1])\n plt.title(num_to_class[y[random_index].argmax()])\nplt.show()",
"_____no_output_____"
]
],
[
[
"## Shulfe and split data",
"_____no_output_____"
]
],
[
[
"print(X.shape)\nprint(y.shape)\nx_data = X.reshape(X.shape[0],-1)\nprint(x_data.shape)\nprint(y[0:10])",
"(10222, 299, 299, 3)\n(10222,)\n(10222, 268203)\n[61 10 28 85 56 8 8 3 86 4]\n"
],
[
"from sklearn.utils import shuffle\nx_data, y_data = shuffle(x_data, y)",
"_____no_output_____"
],
[
"from sklearn.model_selection import train_test_split\n\nx_train, x_val, y_train, y_val = train_test_split(x_data, y_data, test_size=0.05)\nprint(x_train.shape)\nprint(y_train.shape)\nprint(x_val.shape)\nprint(y_val.shape)",
"(9710, 268203)\n(9710,)\n(512, 268203)\n(512,)\n"
]
],
[
[
"### Staticstic method",
"_____no_output_____"
]
],
[
[
"from sklearn.model_selection import GridSearchCV\nfrom sklearn.metrics import accuracy_score\n\ndef my_GridSearchCV(model, parameters):\n if parameters:\n clf = GridSearchCV(model, parameters)\n else:\n clf = model\n clf.fit(x_train, y_train)\n return clf\n\ndef ny_train(models):\n clfs = {}\n for key, value in models.items():\n print('start ' + key)\n clf = my_GridSearchCV(value['model'], value['param'])\n clfs[key] = clf\n return clfs\n\ndef my_predict(clfs, x_val=x_val, y_val=y_val):\n for key, value in clfs.items():\n print(key, end=': ')\n y_pred = value.predict(x_val)\n print(accuracy_score(y_val, y_pred))",
"_____no_output_____"
],
[
"from sklearn.svm import SVC\nfrom sklearn.naive_bayes import GaussianNB\nfrom sklearn.ensemble import AdaBoostClassifier\nfrom sklearn.ensemble import RandomForestClassifier\nfrom sklearn.neighbors import KNeighborsClassifier\n\nmodels = {}\nmodels = {\n# 'SVC': {\n# 'model': SVC(),\n# 'param': {'kernel':('linear', 'rbf'), 'C':[1, 5, 10]}\n# },\n# 'GaussianNB':{\n# 'model': GaussianNB(),\n# 'param': {}\n# },\n# 'AdaBoostClassifier':{\n# 'model': AdaBoostClassifier(),\n# 'param': {}\n# },\n# 'RandomForestClassifier':{\n# 'model': RandomForestClassifier(),\n# 'param': {}\n# },\n 'KNeighborsClassifier':{\n 'model': KNeighborsClassifier(n_neighbors=3),\n 'param': {'n_neighbors':range(3, 7)}\n }\n}",
"_____no_output_____"
]
],
[
[
"### Train model",
"_____no_output_____"
]
],
[
[
"%%time\nclfs = ny_train(models)\nmy_predict(clfs)",
"start KNeighborsClassifier\n"
]
],
[
[
"## Cross validation",
"_____no_output_____"
]
],
[
[
"from sklearn.metrics import log_loss, accuracy_score\nprint('Val log_loss: {}'.format(log_loss(log_loss_y_val, val_proba)))\nval_proba_limit = np.clip(log_loss_y_val, 0.005, 0.995)\nprint('Val log_loss: {}'.format(log_loss(log_loss_y_val, val_proba_limit)))\nprint('Val accuracy_score: {}'.format(accuracy_score(y_val, val_preds)))",
"_____no_output_____"
]
],
[
[
"### Load test data",
"_____no_output_____"
]
],
[
[
"df2 = pd.read_csv('.\\\\input\\\\sample_submission.csv')\nn_test = len(df2)\nX_test = np.zeros((n_test, width, width, 3), dtype=np.uint8)\nfor i in tqdm(range(n_test)):\n X_test[i] = cv2.resize(cv2.imread('.\\\\input\\\\test\\\\%s.jpg' % df2['id'][i]), (width, width))",
"_____no_output_____"
]
],
[
[
"### Export test data feature",
"_____no_output_____"
]
],
[
[
"inception_features = get_features(InceptionV3, X_test)\nxception_features = get_features(Xception, X_test)\nfeatures_test = np.concatenate([inception_features, xception_features], axis=-1)",
"_____no_output_____"
]
],
[
[
"### Get test data prediction and output",
"_____no_output_____"
]
],
[
[
"y_pred = model.predict(features_test, batch_size=128)\nfor b in breed:\n df2[b] = y_pred[:,class_to_num[b]]\ndf2.to_csv('.\\\\output\\\\pred.csv', index=None)",
"_____no_output_____"
],
[
"print('Done !')",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
]
] |
ecade9c13cb30e2e963f3823390a0bfb498c8e68 | 9,131 | ipynb | Jupyter Notebook | xgboost/BikeSharingRegression/biketrain_data_preparation_rev2.ipynb | srinivas02/AmazonSageMakerCourse | 98d77dfea6cf5bb3ddd23c44a2adfb8be29b10b3 | [
"Apache-2.0"
] | 1 | 2021-07-03T04:35:45.000Z | 2021-07-03T04:35:45.000Z | xgboost/BikeSharingRegression/biketrain_data_preparation_rev2.ipynb | srinivas02/AmazonSageMakerCourse | 98d77dfea6cf5bb3ddd23c44a2adfb8be29b10b3 | [
"Apache-2.0"
] | null | null | null | xgboost/BikeSharingRegression/biketrain_data_preparation_rev2.ipynb | srinivas02/AmazonSageMakerCourse | 98d77dfea6cf5bb3ddd23c44a2adfb8be29b10b3 | [
"Apache-2.0"
] | 1 | 2020-08-17T17:58:31.000Z | 2020-08-17T17:58:31.000Z | 22.657568 | 400 | 0.533786 | [
[
[
"%matplotlib inline\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt",
"_____no_output_____"
]
],
[
[
"<h2>Kaggle Bike Sharing Demand Dataset</h2>\n<h4>New Feature Hour Added</h4>\n<h4>To download dataset, sign-in and download from this link: https://www.kaggle.com/c/bike-sharing-demand/data</h4>\n<br>\nInput Features: ['season', 'holiday', 'workingday', 'weather', 'temp',\n 'atemp', 'humidity', 'windspeed', 'year', 'month', 'day', 'dayofweek',<b>'hour'</b>]<br>\nTarget Feature: ['count']<br>\nObjective: <quote>You are provided hourly rental data spanning two years. For this competition, the training set is comprised of the first 19 days of each month, while the test set is the 20th to the end of the month. You must predict the total count of bikes rented during each hour covered by the test set, using only information available prior to the rental period (Ref: Kaggle.com)</quote>",
"_____no_output_____"
]
],
[
[
"columns = ['count', 'season', 'holiday', 'workingday', 'weather', 'temp',\n 'atemp', 'humidity', 'windspeed', 'year', 'month', 'day', 'dayofweek','hour']",
"_____no_output_____"
],
[
"df = pd.read_csv('train.csv', parse_dates=['datetime'])\ndf_test = pd.read_csv('test.csv', parse_dates=['datetime'])",
"_____no_output_____"
],
[
"df.head()",
"_____no_output_____"
],
[
"df_test.head()",
"_____no_output_____"
],
[
"# We need to convert datetime to numeric for training.\n# Let's extract key features into separate numeric columns\ndef add_features(df):\n df['year'] = df['datetime'].dt.year\n df['month'] = df['datetime'].dt.month\n df['day'] = df['datetime'].dt.day\n df['dayofweek'] = df['datetime'].dt.dayofweek\n df['hour'] = df['datetime'].dt.hour",
"_____no_output_____"
],
[
"add_features(df)\nadd_features(df_test)",
"_____no_output_____"
],
[
"df.dtypes",
"_____no_output_____"
],
[
"# Correlation will indicate how strongly features are related to the output\ndf.corr()['count']",
"_____no_output_____"
],
[
"group_hour = df.groupby(['hour'])\naverage_by_hour = group_hour['count'].mean()",
"_____no_output_____"
],
[
"plt.plot(average_by_hour.index,average_by_hour)\nplt.xlabel('hour')\nplt.ylabel('Count')\nplt.xticks(np.arange(24))\nplt.grid(True)\nplt.title('Rental Count Average by hour')",
"_____no_output_____"
],
[
"group_year_hour = df.groupby(['year','hour'])",
"_____no_output_____"
],
[
"average_year_hour = group_year_hour['count'].mean()",
"_____no_output_____"
],
[
"for year in average_year_hour.index.levels[0]:\n #print (year)\n #print(average_year_month[year])\n plt.plot(average_year_hour[year].index,average_year_hour[year],label=year)\n \nplt.legend() \nplt.xlabel('hour')\nplt.ylabel('Count')\nplt.xticks(np.arange(24))\nplt.grid(True)\nplt.title('Rental Count Average by Year,Hour')",
"_____no_output_____"
],
[
"group_workingday_hour = df.groupby(['workingday','hour'])",
"_____no_output_____"
],
[
"average_workingday_hour = group_workingday_hour['count'].mean()",
"_____no_output_____"
],
[
"for workingday in average_workingday_hour.index.levels[0]:\n #print (year)\n #print(average_year_month[year])\n plt.plot(average_workingday_hour[workingday].index,average_workingday_hour[workingday],label=workingday)\n \nplt.legend() \nplt.xlabel('hour')\nplt.ylabel('Count')\nplt.xticks(np.arange(24))\nplt.grid(True)\nplt.title('Rental Count Average by Working Day,Hour')",
"_____no_output_____"
],
[
"df.dtypes",
"_____no_output_____"
],
[
"# Save all data\ndf.to_csv('bike_all.csv',index=False,\n columns=columns)",
"_____no_output_____"
]
],
[
[
"## Training and Validation Set\n### Target Variable as first column followed by input features\n### Training, Validation files do not have a column header",
"_____no_output_____"
]
],
[
[
"# Training = 70% of the data\n# Validation = 30% of the data\n# Randomize the datset\nnp.random.seed(5)\nl = list(df.index)\nnp.random.shuffle(l)\ndf = df.iloc[l]",
"_____no_output_____"
],
[
"rows = df.shape[0]\ntrain = int(.7 * rows)\ntest = int(.3 * rows)",
"_____no_output_____"
],
[
"rows, train, test",
"_____no_output_____"
],
[
"columns",
"_____no_output_____"
],
[
"# Write Training Set\ndf[:train].to_csv('bike_train.csv'\n ,index=False,header=False\n ,columns=columns)",
"_____no_output_____"
],
[
"# Write Validation Set\ndf[train:].to_csv('bike_validation.csv'\n ,index=False,header=False\n ,columns=columns)",
"_____no_output_____"
],
[
"# Test Data has only input features\ndf_test.to_csv('bike_test.csv',index=False)",
"_____no_output_____"
],
[
"','.join(columns)",
"_____no_output_____"
],
[
"# Write Column List\nwith open('bike_train_column_list.txt','w') as f:\n f.write(','.join(columns))",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecadf32c6d8b4382349230ddf62e693fac3b0260 | 7,901 | ipynb | Jupyter Notebook | PartialEvaluation.ipynb | kyagrd/grad-compiler2020 | 019ce1629803a95bef2db1181abc1bb02939772c | [
"MIT"
] | 3 | 2020-09-02T07:32:40.000Z | 2020-12-03T06:22:21.000Z | PartialEvaluation.ipynb | hnu-pl/grad-compiler2020 | 019ce1629803a95bef2db1181abc1bb02939772c | [
"MIT"
] | null | null | null | PartialEvaluation.ipynb | hnu-pl/grad-compiler2020 | 019ce1629803a95bef2db1181abc1bb02939772c | [
"MIT"
] | null | null | null | 28.117438 | 155 | 0.499051 | [
[
[
":opt no-lint",
"_____no_output_____"
]
],
[
[
"# Partial Evaluation\n\n부분계산(partial evaluation)이라는 개념을 이용해 인터프리터가 있다면 이를 이용해 컴파일러를 생성해 낼 수 있다.\n\n이를 **후타무라 투영**(Futamura projection)이라고 한다. https://fi.ftmr.info/\n\n실제로 현업에서 활용되는 컴파일러로는 PyPy라는 파이썬으로부터 실행파일을 만들어내는 컴파일러를 작성하는 데 바로 이 아이디어가 활용된 것으로 알려져 있다.\n\n\n## Partial Evaluator\n일단 부분계산을 실행하는 부분계산기(partial evualuator, $\\textit{PE}\\,$)의 개념부터 알아보자\n\n$prog(I_S\\uplus I_D) = v$ 일 때\n\n$\\textit{PE}(prog, I_S) = prog^*$ 단, $prog^*(I_D) = v$\n\n예를 들어 $prog$가 $3 + x + y$에 해당하고 $I_S = \\{x\\mapsto 2\\}$라면\n\n$prog^*$는 $5 + y$에 해당한다.",
"_____no_output_____"
],
[
"-------\n지금까지는 언어 종류는 대략 두가지 정도 부류로 컴파일러를 어떻게 만들까 살펴봤는데, 많이 단순화해서 입력은 고려하지 않았음.\n\n입력(사용자 키보드 입력, 데이터베이스 읽어오기, 파일 읽어오기, 네트웍 등등)이 전혀 없으면 사실 인터프리터를 매번 돌릴 필요가 없다.\n\n1 ~ 100 까지 더하는 프로그램을 반복문을 돌려서 작성했다면 (그런데 입력이 없고 정해져 있다면)\n사실은 한번만 돌려보고 결과인 5050을 원래 프로그램 대신에 앞으로는 사용하면 되죠.\n아무리 복잡한 프로그램도 입력이 전혀 없으면 (확률적으로 랜덤하게 실행때마다 다른 값이 나와야 하는 게 아니라면)\n한번만 돌려보고 다음부터는 그 결과값을 바로 그냥 사용하면 굳이 계산을 매번 돌릴 필요가 없다는 거.\n\n그래서 사실은 입력이 없는 프로그램은 그냥 상수로 최적화가 되어버립니다.\n\n\n비유자하자면 입력이 없는 경우라면\n * 1 ~ 100 까지 더하는 프로그램을 반복문을 돌리는 <==== 인터프리터\n * 5050 <=== 컴파일한 실행파일이 내놓으면 되는 결과\n\n보통은 1 ~ $n$ 까지 더하는 프로그램을 작성해서 $n$은 \"입력\"으로 생각하죠.\n그 입력에 따라 다른 결과값을 프로그램을 실행해서 알아내는 게 보통 프로그램을 활용하는 방법.\n\n예를 들어 $m$ ~ $n$ 까지 더하는 프로그램이라면 해놓고 $m$은 프로그램 실행 전에 항상 똑같이 미리 정해 놓는 상수라면,\n$m$에 값을 지정하는 것이 정적 입력($I_S$)에 해당하고 나머지 $n$은 프로그램 실행 중에 입력받는 (혹은 실행할 때마다 다르게 지정할 수 있는) 동적 입력($I_D$)으로 처리한다고 보면 된다.",
"_____no_output_____"
]
],
[
[
"type Nm = String\n\ndata Exp = Var Nm -- x\n | Lit Int -- n\n | Add Exp Exp -- e1 + e2\n deriving Show\n\ntype Val = Int\ntype Env = [(Nm,Val)]",
"_____no_output_____"
],
[
"-- interpreter\neval :: Exp -> Env -> Val\neval (Var x) env = case lookup x env of\n Nothing -> error $ x ++ \" not found\"\n Just v -> v\neval (Lit n) env = n\neval (Add e1 e2) env = eval e1 env + eval e2 env",
"_____no_output_____"
],
[
"e1 = Add (Add (Lit 3) (Var \"x\")) (Var \"y\")\niS = [(\"x\",2)]\niD = [(\"y\",10)]\n\neval e1 (iS++iD)",
"_____no_output_____"
],
[
"-- partial evaluator\npe :: Exp -> Env -> Exp\npe (Var x) env = case lookup x env of\n Nothing -> Var x\n Just v -> Lit v\npe (Lit n) env = Lit n\npe (Add e1 e2) env = case (pe e1 env, pe e2 env) of\n (Lit n1, Lit n2) -> Lit (n1 + n2)\n (e1' , e2' ) -> Add e1' e2'",
"_____no_output_____"
],
[
"pe e1 iS",
"_____no_output_____"
]
],
[
[
"----\n이건 매무 매우 간단한 경우고, 함수를 처리할 수 있는 람다식이 포함되면 `pe`가 조금 더 생각해야 될 게 있다.\n왜냐하면 값(`Val`)이 단순히 정수가 아니고 클로저를 포함할 수 있게 되기 때문.\n\n후타무라 투영 이야기까지 가려면 우리가 다루는 언어(`Exp`)가 좀더 많은 기능을 가정해야 설명하기 좋다.\n\n예를 들면 `Exp` 언어의 인터프리터와 부분계산기를 `Exp` 언어로 작성 가능할 정도로 조금 더 본격적인 언어가 필요.\n\n예를 들면 문자열 같은 걸 입력받아서 \"3 + x + y\"라는 걸 입력받으면 이걸 처리해서 계산할 수 있는 인터프리터와 부분계산기를\n하스켈이 아니라 `Exp` 언어 자체로 작성할 수 있어야 한다.",
"_____no_output_____"
],
[
"------\n\n`Exp` 언어에 충분히 많은 기능을 추가해서\n`Exp` 자신의 언어에 대한 **인터프리터**와 **부분계산기**를 작성할 수 있다고 합시다.\n그러면 인터프리터와 부분계산기를 이용해 컴파일러를 유도해 낼 수 있다.\n이런 것을 발견한 사람이 후타무라 교수.\n\n* $P_i$ 인터프리터 프로그램\n* $PE$ 부분계산기 프로그램\n\n$P_i$는 소스코드와 그 소스코드를 실행하면서 받는 *소스코드에 대한 입력*를 입력으로 받아서 결과값을 계산하는 프로그램.\n그러니까 $P_i$ 입장에서는\n소스코드가 *정적 입력*에 해당하고\n그 소스코드를 실행하면서 소스코드에 넘기는 입력 부분을 *동적 입력*이라고 생각할 수 있다.\n\n$P_i(source \\uplus input) = result$\n\n인터프리터를 부분계산하는데 소스코드를 정적입력으로 넘긴다고 생각하면\n$PE(P_i, source) = exe$ 이렇게 나온 프로그램은 $exe(input) = result$ 가 나오는 실행파일에 해당한다.\n\n여기서 잘 생각해 보면 소스코드를 동적 입력으로 받아서 실행파일에 해당하는 것을 만드는 건 *컴파일러*잖아?\n\n그러니까 부분계산기 자체를 *인터프리터를 정적 입력으로 취급해서* 부분계산해 버리면 컴파일러가 나오겠네???!!!!\n\n$PE(PE, P_i) = P_c$ 그러면 이렇게 나온 프로그램은 $P_c(source) = exe$ 이런 식으로 동작한다.\n\n그러니까 $source$로부터 그 소스코드를 인터프리터로 실행했을 때와 같은 결과를 얻는 실행파일에 해당하는 $exe$를 만들어내는\n프로그램이 바로 $P_c$라는 것. 그런데 그렇게 동작하는 $P_c$라는 프로그램이 바로 컴파일러라는 것에 기대하는 것과 정확히 똑같은 일을 한다. ",
"_____no_output_____"
],
[
"---\n여기서 아 그렇구나 하고 넘어갈 수도 있지만 ...\n\n한가지 더 생각해야 되는 부분이 최초에는 인터프리터($P_i$)나 부분계산기를($PE$)를 어떻게 실행할까?\n\n자기 자신의 언어로 $PE$와 $P_i$를 작성했다는 거는 이게 정말 처음에는 이 언어의 구현이 존재하지 X.\n\n그러니까 최초에는 다른 언어로 작성할 수밖에 없다. <=== 부트스트랩\n\n컴파일러 유도를 위해서는 $PE$만 실행할 수 있으면 되지만 현실적으로 $P_i$도 제대로 작성했나 테스트를 해보려면 현실적으로는 실행을 안 해 볼 수는 없겠죠. 일단 실행가능한 인터프리터($P_i$)가 있으면 $PE$도 그 인터프리터를 이용해서 실행가능하겠죠.\n\n앞서 실제로 PyPy라는 파이썬 컴파일러가 이런 방식으로 만들어졌다고 했는데\n이것도 부트스트랩은 CPython이라는 C로 작성된 파이썬 인터프리터를 활용해서 부트스랩을 한 것.\n그 다음에 파이썬으로 파이썬의 인터프리터나 부분계산기를 작성해서 컴파일러 유도.",
"_____no_output_____"
],
[
"----\n\n----\n\n# 좀더 자세한 관련 내용은 다음 자료를 참고\n\nhttp://www.cs.ioc.ee/ewscs/2016/geuvers/geuvers-slides-lecture2.pdf\n\n - 강의노트 형식\n - 순수한 람다계산법만으로 람다계산법 자신의 인터프리터를 작성하는 방법을 설명\n\nhttps://www.cs.tufts.edu/comp/150FP/archive/neil-jones/mix-partial-evaluator.pdf\n - 논문\n - 앞서 대략 설명한 아이디어를 좀더 구체적으로 정리해 그대로 따라 구현할 수 있을 정도로 자세히 정리\n - 네 가지 다른 언어를 사용할 수 있을 가능성\n * L 언어로 인터프리터를 작성\n * P 언어로 부분계산기를 작성 (부분계산기의 입력으로 L 언어의 프로그램 소스코드가 들어감)\n * S 언어는 처리하고자 하는 대상 언어 (인터프리터, 컴파일러의 입력으로 S 언어 소스코드가 들어감)\n * T 언어는 컴파일러의 결과로 나오는 대상(혹은 목적) 코드의 언어. 논문에서는 T = L 로 놓고 진행함.\n \nL = S 일 때 self-interpretation 또는 metacircular interpreter라고 부르기도 한다.\n\n예를 들어 파이썬의 컴파일러를 이런 식으로 유도한다면 S언어는 당연히 파이썬일 거고,\nL언어는 C를 활용할 수도 있겠죠. C로 만든 CPython이라는 가장 대중적인 인터프리터가 이미 존재하니까.",
"_____no_output_____"
]
]
] | [
"code",
"markdown",
"code",
"markdown"
] | [
[
"code"
],
[
"markdown",
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown",
"markdown",
"markdown",
"markdown"
]
] |
ecadfb4309f894e5b1ce1174a58d4a10a690a137 | 8,958 | ipynb | Jupyter Notebook | S&P500.ipynb | murilobeltrame/algorithmic-trading-with-python | b54e836bb2bf4c12bc3123f4dd04b2bf01fe0bd6 | [
"MIT"
] | null | null | null | S&P500.ipynb | murilobeltrame/algorithmic-trading-with-python | b54e836bb2bf4c12bc3123f4dd04b2bf01fe0bd6 | [
"MIT"
] | null | null | null | S&P500.ipynb | murilobeltrame/algorithmic-trading-with-python | b54e836bb2bf4c12bc3123f4dd04b2bf01fe0bd6 | [
"MIT"
] | null | null | null | 23.951872 | 138 | 0.523666 | [
[
[
"## Library Imports",
"_____no_output_____"
]
],
[
[
"import sys\n!{sys.executable} -m pip install numpy\n!{sys.executable} -m pip install pandas\n!{sys.executable} -m pip install python-dotenv\n!{sys.executable} -m pip install requests\n!{sys.executable} -m pip install xlsxwriter",
"_____no_output_____"
],
[
"from dotenv import load_dotenv\nimport math\nimport numpy\nimport os\nimport pandas\nimport requests \nimport xlsxwriter\n\nload_dotenv()",
"_____no_output_____"
]
],
[
[
"## List of Stocks",
"_____no_output_____"
]
],
[
[
"stocks = pandas.read_csv('sp_500_stocks.csv')\nstocks",
"_____no_output_____"
]
],
[
[
"## Acquiring an API Token\n\nIt will use IEx Cloud API.",
"_____no_output_____"
]
],
[
[
"key = os.getenv(\"ACCESS_KEY\")",
"_____no_output_____"
]
],
[
[
"## Marking first API Call",
"_____no_output_____"
]
],
[
[
"symbol = 'AAPL'\napi_url = f'https://sandbox.iexapis.com/stable/stock/{symbol}/quote/?token={key}'\ndata = requests.get(api_url).json()",
"_____no_output_____"
]
],
[
[
"## Parsing API Result",
"_____no_output_____"
]
],
[
[
"price = data['latestPrice']\nmarket_cap = data['marketCap'] / 1000000000000",
"_____no_output_____"
]
],
[
[
"## Adding Stocks to Pandas Dataframe",
"_____no_output_____"
],
[
"### Creating result Dataframe",
"_____no_output_____"
]
],
[
[
"data_columns = ['Ticker', 'Stock Price', 'Market Capitalization', 'Number of Shares to Buy']\nresultDataFrame = pandas.DataFrame(columns = data_columns)",
"_____no_output_____"
]
],
[
[
"### Append The first row into the DataFrame",
"_____no_output_____"
]
],
[
[
"resultDataFrame.append(\n pandas.Series([\n symbol,\n price,\n market_cap,\n 'N/A'\n ], index= data_columns),\n ignore_index=True\n)",
"_____no_output_____"
]
],
[
[
"### Loopint through the Ticker of the Stocks",
"_____no_output_____"
]
],
[
[
"resultDataFrame = pandas.DataFrame(columns = data_columns)\nfor stock in stocks['Ticker'][:5]:\n api_url = f'https://sandbox.iexapis.com/stable/stock/{stock}/quote/?token={key}'\n data = requests.get(api_url).json()\n resultDataFrame = resultDataFrame.append(\n pandas.Series([\n stock,\n data['latestPrice'],\n data['marketCap'] / 1000000000000,\n 'N/A'\n ], index= data_columns),\n ignore_index=True\n )\n\nresultDataFrame",
"_____no_output_____"
]
],
[
[
"### Using Batch API",
"_____no_output_____"
]
],
[
[
"def chuncks(lst, n):\n for i in range(0, len(lst), n):\n yield lst[i:i + n]",
"_____no_output_____"
],
[
"symbol_groups = list(chuncks(stocks['Ticker'], 100))",
"_____no_output_____"
],
[
"symbol_strings = []\nfor i in range(0, len(symbol_groups)):\n symbol_strings.append(','.join(symbol_groups[i]))",
"_____no_output_____"
],
[
"resultDataFrame = pandas.DataFrame(columns = data_columns)\nfor symbol_string in symbol_strings:\n batch_api_call_url = f'https://sandbox.iexapis.com/stable/stock/market/batch?symbols={symbol_string}&types=quote&token={key}'\n data = requests.get(batch_api_call_url).json()\n for symbol in symbol_string.split(','):\n resultDataFrame = resultDataFrame.append(\n pandas.Series([\n symbol,\n data[symbol]['quote']['latestPrice'],\n data[symbol]['quote']['marketCap'] / 1000000000000,\n 'N/A'\n ], index= data_columns),\n ignore_index=True\n )\n\nresultDataFrame",
"_____no_output_____"
]
],
[
[
"## Calculating the Number of Shares to Buy",
"_____no_output_____"
]
],
[
[
"portfolio_size = input('Enter the value of you portfolio')\ntry:\n val = float(portfolio_size)\nexcept ValueError:\n print('portfolio_size should be a number')\n portfolio_size = input('Enter the value of you portfolio')\n val = float(portfolio_size)",
"_____no_output_____"
],
[
"position_size = val / len(resultDataFrame.index)",
"_____no_output_____"
],
[
"for i in range(0, len(resultDataFrame.index)):\n stockPrice = resultDataFrame.loc[i, 'Stock Price']\n resultDataFrame.loc[i, 'Number of Shares to Buy'] = math.floor(position_size / stockPrice)\n\nresultDataFrame",
"_____no_output_____"
]
],
[
[
"## Formating to Excel",
"_____no_output_____"
]
],
[
[
"writer = pandas.ExcelWriter('recommended trades.xlsx', engine = 'xlsxwriter')\nresultDataFrame.to_excel(writer, 'Recommended Trades', index = False)\n\nbackground_color = '#0E0A23'\nfont_color = '#FFFFFF'\n\nstring_format = writer.book.add_format({\n 'font_color': font_color,\n 'bg_color': background_color,\n 'border': 1\n})\n\ndollar_format = writer.book.add_format({\n 'num_format': '$ 0.00',\n 'font_color': font_color,\n 'bg_color': background_color,\n 'border': 1\n})\n\nint_format = writer.book.add_format({\n 'num_format': '0',\n 'font_color': font_color,\n 'bg_color': background_color,\n 'border': 1\n})\n\ncolumn_formats = {\n 'A': ['Ticker', string_format],\n 'B': ['Stock Price', dollar_format],\n 'C': ['Market Capitalization', dollar_format],\n 'D': ['Number of Shares to Buy', int_format]\n}\n\nfor column in column_formats.keys():\n writer.sheets['Recommended Trades'].set_column(f'{column}:{column}', 18, column_formats[column][1])\n writer.sheets['Recommended Trades'].write(f'{column}1', column_formats[column][0], string_format)\n\nwriter.save()",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecae0b5772fc49549a6bcc6d0b845e9bad2eafdf | 3,798 | ipynb | Jupyter Notebook | MODULO 1/Problemas Diversos.ipynb | PATRICIACUSI/CURSOPYTHOND | 8243271d2d17a265d787fa060c3ab7fad46c5828 | [
"Apache-2.0"
] | null | null | null | MODULO 1/Problemas Diversos.ipynb | PATRICIACUSI/CURSOPYTHOND | 8243271d2d17a265d787fa060c3ab7fad46c5828 | [
"Apache-2.0"
] | null | null | null | MODULO 1/Problemas Diversos.ipynb | PATRICIACUSI/CURSOPYTHOND | 8243271d2d17a265d787fa060c3ab7fad46c5828 | [
"Apache-2.0"
] | null | null | null | 25.32 | 239 | 0.557399 | [
[
[
"# PROBLEMAS DIVERSOS",
"_____no_output_____"
],
[
"<h3>1.</h3>\nEscribí un programa que solicite al usuario ingresar la cantidad de kilómetros recorridos por una motocicleta y la cantidad de litros de combustible que consumió durante ese recorrido. Mostrar el consumo de combustible por kilómetro.",
"_____no_output_____"
],
[
"<code>Kilómetros recorridos: 260\nLitros de combustible gastados: 12.5\nEl consumo por kilómetro es de 20.8<code>",
"_____no_output_____"
]
],
[
[
"Kilometros = float (input(\"kilómetros recorridos:\"))\nCombustible = float(input(\"Litros de combustible:\"))\nprint(\"Consumo de combustible x kilómetro:\",\" \",Kilometros/Combustible)",
"kilómetros recorridos: 260\nLitros de combustible: 12.5\n"
]
],
[
[
"### 2.\nEscriba un programa que pida los coeficientes de una ecuación de segundo grado <code>(a x² + b x + c = 0)</code> y escriba la solución.\n\nSe recuerda que una ecuación de segundo grado puede no tener solución, tener una solución única, tener dos soluciones o que todos los números sean solución.",
"_____no_output_____"
],
[
"<img src='https://i.pinimg.com/originals/d3/f7/01/d3f701528ad56ce0f5a98d7c91722fd7.png'>",
"_____no_output_____"
],
[
"Su programa debe indicar:\n- En caso la ecuación cuadrática tenga solución real, su programa debe brindar la solución\n- En caso su ecuación no tenga solución real, su programa debe brindar un mensaje que diga \"Ecuación no presenta solución real\"",
"_____no_output_____"
]
],
[
[
"from math import sqrt \na = float(input(\"Ingrese el primer coeficiente\"))\nb = float(input(\"Ingrese el segundo coeficiente\"))\nc = float(input(\"Ingrese el tercer coeficiente\"))\nx1 = 0\nx2 = 0\n\nif (b**2-(4*a*c)) < 0: \n print(\"La ecuación no presenta solución real\")\nelse : \n x1 = (-b+sqrt(b**2-4*a*c))/(2*a)\n x2 = (-b-sqrt(b**2-4*a*c))/(2*a)\n print(\"Soluciones de la ecuación\")\n print(x1)\n print(x2)",
"Ingrese el primer coeficiente 4\nIngrese el segundo coeficiente 3\nIngrese el tercer coeficiente 8\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown",
"markdown"
],
[
"code"
]
] |
ecae0c564d2f547a37e05d7607df13de011d42b7 | 38,677 | ipynb | Jupyter Notebook | archive/scripts/experiment_2/1_train_vae.ipynb | ajlee21/Batch_effects_simulation | d707321346de48de5e63cf251280bdf9372be59c | [
"BSD-3-Clause"
] | 6 | 2020-05-04T15:16:32.000Z | 2021-02-28T04:49:21.000Z | archive/scripts/experiment_2/1_train_vae.ipynb | ajlee21/Batch_effects_simulation | d707321346de48de5e63cf251280bdf9372be59c | [
"BSD-3-Clause"
] | 12 | 2020-02-27T20:12:36.000Z | 2021-04-07T20:28:35.000Z | archive/scripts/experiment_2/1_train_vae.ipynb | ajlee21/Batch_effects_simulation | d707321346de48de5e63cf251280bdf9372be59c | [
"BSD-3-Clause"
] | 2 | 2019-06-02T18:29:17.000Z | 2020-02-13T09:33:37.000Z | 80.242739 | 17,884 | 0.693306 | [
[
[
"# Train VAE",
"_____no_output_____"
]
],
[
[
"%load_ext autoreload\n%autoreload 2\n\nimport os\nimport sys\nimport ast\nimport pandas as pd\nimport numpy as np\nimport random\nimport warnings\nwarnings.filterwarnings(action='ignore')\n\nsys.path.append(\"../\")\nfrom functions import vae\n\nfrom numpy.random import seed\nrandomState = 123\nseed(randomState)",
"Using TensorFlow backend.\n"
],
[
"# Create list of base directories\n\nbase_dir = os.path.abspath(os.path.join(os.getcwd(),\"../..\"))\n\nbase_dirs = [os.path.join(base_dir, \"data\"),\n os.path.join(base_dir, \"models\"),\n os.path.join(base_dir, \"output\"),\n os.path.join(base_dir, \"data\", \"encoded\"),\n os.path.join(base_dir, \"output\", \"stats\"),\n os.path.join(base_dir, \"output\", \"viz\")\n ]\n\n# Check if analysis directory exist otherwise create\n\nfor each_dir in base_dirs:\n\n if os.path.exists(each_dir):\n print('directory already exists: {}'.format(each_dir))\n else:\n print('creating new directory: {}'.format(each_dir))\n os.makedirs(each_dir, exist_ok=True)",
"directory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/data\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/models\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/output\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/data/encoded\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/output/stats\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/output/viz\n"
],
[
"# Load config params\nconfig_file = \"config_exp_2.txt\"\n\nd = {}\nfloat_params = [\"learning_rate\", \"kappa\", \"epsilon_std\"]\nstr_params = [\"analysis_name\", \"NN_architecture\"]\nlst_params = [\"num_batches\"]\nwith open(config_file) as f:\n for line in f:\n (name, val) = line.split()\n if name in float_params:\n d[name] = float(val)\n elif name in str_params:\n d[name] = str(val)\n elif name in lst_params:\n d[name] = ast.literal_eval(val)\n else:\n d[name] = int(val)",
"_____no_output_____"
],
[
"# Parameters\nnum_dims = d[\"num_dims\"]",
"_____no_output_____"
],
[
"# Load arguments\nnormalized_data_file = os.path.join(\n os.path.abspath(os.path.join(os.getcwd(),\"../..\")),\n \"data\",\n \"input\",\n \"train_set_normalized.pcl\")",
"_____no_output_____"
],
[
"# Read data\nnormalized_data = pd.read_table(\n normalized_data_file,\n header=0,\n sep='\\t',\n index_col=0).T\n\nprint(normalized_data.shape)",
"(950, 5549)\n"
],
[
"# Parameters \nlearning_rate = d['learning_rate']\nbatch_size = d['batch_size']\nepochs = d['epochs']\nkappa = d['kappa']\nintermediate_dim = d['intermediate_dim']\nlatent_dim = d['latent_dim']\nepsilon_std = d['epsilon_std']\nnum_PCs = latent_dim\ntrain_architecture = \"NN_{}_{}\".format(intermediate_dim, latent_dim)",
"_____no_output_____"
],
[
"# Create output directories\n\noutput_dirs = [os.path.join(base_dir, \"data\", \"encoded\"),\n os.path.join(base_dir, \"models\"),\n os.path.join(base_dir, \"output\", \"stats\"),\n os.path.join(base_dir, \"output\", \"viz\")\n ]\n\n# Check if analysis directory exist otherwise create\n\nfor each_dir in output_dirs:\n new_dir = os.path.join(each_dir, train_architecture)\n \n if os.path.exists(new_dir):\n print('directory already exists: {}'.format(new_dir))\n else:\n print('creating new directory: {}'.format(new_dir))\n os.makedirs(new_dir, exist_ok=True)",
"directory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/data/encoded/NN_2500_30\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/models/NN_2500_30\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/output/stats/NN_2500_30\ndirectory already exists: /home/alexandra/Documents/Repos/Batch_effects_simulation/output/viz/NN_2500_30\n"
],
[
"# Train nonlinear (VAE)\nvae.tybalt_2layer_model(learning_rate,\n batch_size,\n epochs, \n kappa, \n intermediate_dim,\n latent_dim, \n epsilon_std,\n normalized_data,\n base_dir, \n train_architecture \n )",
"Train on 855 samples, validate on 95 samples\nEpoch 1/100\n855/855 [==============================] - 7s 8ms/step - loss: 3611.1525 - val_loss: 3816.1125\nEpoch 2/100\n855/855 [==============================] - 6s 6ms/step - loss: 3495.2920 - val_loss: 3551.1631\nEpoch 3/100\n855/855 [==============================] - 6s 7ms/step - loss: 3473.2418 - val_loss: 3482.1953\nEpoch 4/100\n855/855 [==============================] - 6s 6ms/step - loss: 3456.7678 - val_loss: 3456.3940\nEpoch 5/100\n855/855 [==============================] - 5s 6ms/step - loss: 3444.9030 - val_loss: 3459.7307\nEpoch 6/100\n855/855 [==============================] - 5s 6ms/step - loss: 3436.7637 - val_loss: 3416.9893\nEpoch 7/100\n855/855 [==============================] - 5s 6ms/step - loss: 3431.3799 - val_loss: 3434.4470\nEpoch 8/100\n855/855 [==============================] - 5s 6ms/step - loss: 3427.3698 - val_loss: 3411.0513\nEpoch 9/100\n855/855 [==============================] - 6s 7ms/step - loss: 3419.9824 - val_loss: 3410.5171\nEpoch 10/100\n855/855 [==============================] - 6s 6ms/step - loss: 3415.9700 - val_loss: 3404.3218\nEpoch 11/100\n855/855 [==============================] - 6s 7ms/step - loss: 3416.2802 - val_loss: 3403.4036\nEpoch 12/100\n855/855 [==============================] - 6s 7ms/step - loss: 3411.1866 - val_loss: 3401.8889\nEpoch 13/100\n855/855 [==============================] - 6s 7ms/step - loss: 3407.4503 - val_loss: 3393.6938\nEpoch 14/100\n855/855 [==============================] - 6s 7ms/step - loss: 3406.3521 - val_loss: 3394.1853\nEpoch 15/100\n855/855 [==============================] - 5s 6ms/step - loss: 3402.1354 - val_loss: 3398.5710\nEpoch 16/100\n855/855 [==============================] - 6s 7ms/step - loss: 3398.7678 - val_loss: 3387.9973\nEpoch 17/100\n855/855 [==============================] - 6s 7ms/step - loss: 3392.9006 - val_loss: 3390.2500\nEpoch 18/100\n855/855 [==============================] - 5s 6ms/step - loss: 3393.4382 - val_loss: 3394.5674\nEpoch 19/100\n855/855 [==============================] - 5s 6ms/step - loss: 3390.7812 - val_loss: 3390.8088\nEpoch 20/100\n855/855 [==============================] - 5s 6ms/step - loss: 3387.2417 - val_loss: 3386.5652\nEpoch 21/100\n855/855 [==============================] - 5s 6ms/step - loss: 3388.4475 - val_loss: 3382.1531\nEpoch 22/100\n855/855 [==============================] - 5s 6ms/step - loss: 3384.6557 - val_loss: 3392.9460\nEpoch 23/100\n855/855 [==============================] - 6s 6ms/step - loss: 3384.2207 - val_loss: 3371.8027\nEpoch 24/100\n855/855 [==============================] - 6s 7ms/step - loss: 3379.0954 - val_loss: 3374.3967\nEpoch 25/100\n855/855 [==============================] - 6s 7ms/step - loss: 3378.7492 - val_loss: 3382.1201\nEpoch 26/100\n855/855 [==============================] - 5s 6ms/step - loss: 3377.1324 - val_loss: 3371.3918\nEpoch 27/100\n855/855 [==============================] - 5s 6ms/step - loss: 3376.2099 - val_loss: 3366.2043\nEpoch 28/100\n855/855 [==============================] - 5s 6ms/step - loss: 3373.7145 - val_loss: 3373.8674\nEpoch 29/100\n855/855 [==============================] - 5s 6ms/step - loss: 3371.5058 - val_loss: 3363.1316\nEpoch 30/100\n855/855 [==============================] - 5s 6ms/step - loss: 3368.7515 - val_loss: 3365.1526\nEpoch 31/100\n855/855 [==============================] - 5s 6ms/step - loss: 3368.3223 - val_loss: 3358.7625\nEpoch 32/100\n855/855 [==============================] - 5s 6ms/step - loss: 3366.2654 - val_loss: 3359.6509\nEpoch 33/100\n855/855 [==============================] - 5s 6ms/step - loss: 3362.6108 - val_loss: 3359.0671\nEpoch 34/100\n855/855 [==============================] - 5s 6ms/step - loss: 3360.8647 - val_loss: 3356.6375\nEpoch 35/100\n855/855 [==============================] - 5s 6ms/step - loss: 3360.1895 - val_loss: 3358.7507\nEpoch 36/100\n855/855 [==============================] - 5s 6ms/step - loss: 3359.6459 - val_loss: 3352.0322\nEpoch 37/100\n855/855 [==============================] - 5s 6ms/step - loss: 3358.1640 - val_loss: 3358.1504\nEpoch 38/100\n855/855 [==============================] - 5s 6ms/step - loss: 3359.3125 - val_loss: 3361.4226\nEpoch 39/100\n855/855 [==============================] - 5s 6ms/step - loss: 3354.2152 - val_loss: 3361.4690\nEpoch 40/100\n855/855 [==============================] - 5s 6ms/step - loss: 3355.1488 - val_loss: 3352.0862\nEpoch 41/100\n855/855 [==============================] - 6s 7ms/step - loss: 3350.8853 - val_loss: 3352.0505\nEpoch 42/100\n855/855 [==============================] - 6s 7ms/step - loss: 3352.2767 - val_loss: 3354.8279\nEpoch 43/100\n855/855 [==============================] - 6s 7ms/step - loss: 3352.1681 - val_loss: 3348.0120\nEpoch 44/100\n855/855 [==============================] - 5s 6ms/step - loss: 3346.9439 - val_loss: 3345.2312\nEpoch 45/100\n855/855 [==============================] - 5s 6ms/step - loss: 3345.0559 - val_loss: 3343.7517\nEpoch 46/100\n855/855 [==============================] - 5s 6ms/step - loss: 3345.5782 - val_loss: 3341.2114\nEpoch 47/100\n855/855 [==============================] - 5s 6ms/step - loss: 3343.4898 - val_loss: 3339.5859\nEpoch 48/100\n855/855 [==============================] - 5s 6ms/step - loss: 3342.3118 - val_loss: 3340.1978\nEpoch 49/100\n855/855 [==============================] - 5s 6ms/step - loss: 3339.2598 - val_loss: 3335.8904\nEpoch 50/100\n855/855 [==============================] - 5s 6ms/step - loss: 3340.1402 - val_loss: 3339.4487\nEpoch 51/100\n855/855 [==============================] - 5s 6ms/step - loss: 3339.4786 - val_loss: 3334.0637\nEpoch 52/100\n855/855 [==============================] - 5s 6ms/step - loss: 3340.0821 - val_loss: 3335.1003\nEpoch 53/100\n855/855 [==============================] - 5s 6ms/step - loss: 3339.0124 - val_loss: 3335.1655\nEpoch 54/100\n855/855 [==============================] - 5s 6ms/step - loss: 3337.5843 - val_loss: 3332.3411\nEpoch 55/100\n855/855 [==============================] - 6s 6ms/step - loss: 3335.8808 - val_loss: 3329.6599\nEpoch 56/100\n855/855 [==============================] - 5s 6ms/step - loss: 3334.3341 - val_loss: 3328.8118\nEpoch 57/100\n855/855 [==============================] - 6s 7ms/step - loss: 3333.5022 - val_loss: 3326.2810\nEpoch 58/100\n855/855 [==============================] - 5s 6ms/step - loss: 3331.7643 - val_loss: 3321.8445\nEpoch 59/100\n855/855 [==============================] - 5s 6ms/step - loss: 3331.5002 - val_loss: 3328.5710\nEpoch 60/100\n855/855 [==============================] - 5s 6ms/step - loss: 3328.0937 - val_loss: 3322.7188\nEpoch 61/100\n855/855 [==============================] - 5s 6ms/step - loss: 3329.5366 - val_loss: 3319.4250\nEpoch 62/100\n855/855 [==============================] - 6s 7ms/step - loss: 3329.0135 - val_loss: 3322.3164\nEpoch 63/100\n855/855 [==============================] - 5s 6ms/step - loss: 3327.9080 - val_loss: 3319.1584\nEpoch 64/100\n855/855 [==============================] - 5s 6ms/step - loss: 3326.2012 - val_loss: 3323.1682\nEpoch 65/100\n855/855 [==============================] - 6s 7ms/step - loss: 3325.5615 - val_loss: 3317.9329\nEpoch 66/100\n855/855 [==============================] - 6s 7ms/step - loss: 3324.5384 - val_loss: 3318.2307\nEpoch 67/100\n855/855 [==============================] - 6s 7ms/step - loss: 3325.4764 - val_loss: 3315.2583\nEpoch 68/100\n855/855 [==============================] - 6s 7ms/step - loss: 3323.2634 - val_loss: 3316.4932\nEpoch 69/100\n855/855 [==============================] - 6s 7ms/step - loss: 3321.6376 - val_loss: 3316.7112\nEpoch 70/100\n855/855 [==============================] - 6s 6ms/step - loss: 3322.4927 - val_loss: 3316.6938\nEpoch 71/100\n855/855 [==============================] - 6s 7ms/step - loss: 3320.9720 - val_loss: 3318.5056\nEpoch 72/100\n855/855 [==============================] - 6s 7ms/step - loss: 3321.2227 - val_loss: 3314.7500\nEpoch 73/100\n855/855 [==============================] - 6s 6ms/step - loss: 3317.7966 - val_loss: 3313.7090\nEpoch 74/100\n855/855 [==============================] - 5s 6ms/step - loss: 3317.4775 - val_loss: 3315.4575\nEpoch 75/100\n855/855 [==============================] - 5s 6ms/step - loss: 3317.7560 - val_loss: 3316.9973\nEpoch 76/100\n"
]
]
] | [
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecae0ef19a581369b6cafab605a63d777e101832 | 1,552 | ipynb | Jupyter Notebook | jupyter/Testing the crawler.ipynb | chinodyt/usp_dl_crawler | 96b0edd9f6a5c2c9189b0fdffbbe19ffa95d0894 | [
"MIT"
] | null | null | null | jupyter/Testing the crawler.ipynb | chinodyt/usp_dl_crawler | 96b0edd9f6a5c2c9189b0fdffbbe19ffa95d0894 | [
"MIT"
] | null | null | null | jupyter/Testing the crawler.ipynb | chinodyt/usp_dl_crawler | 96b0edd9f6a5c2c9189b0fdffbbe19ffa95d0894 | [
"MIT"
] | null | null | null | 23.164179 | 121 | 0.553479 | [
[
[
"%load_ext autoreload\n%autoreload 2\n\nimport sys\nsys.path.append('../')\n\nfrom usp_dl.crawler import ThesisHTMLParser\nfrom usp_dl.crawler import Crawler",
"_____no_output_____"
],
[
"keyword_list = ['processamento de imagens', 'educação', 'blockchain', 'jogos', 'gamificação',\n 'mineração de dados', 'imagens médicas', 'arte', 'psicologia', 'filosofia']\n\ncrawler = Crawler()\ncrawler.run(keyword_list, entries_per_keyword=20)",
"_____no_output_____"
],
[
"crawler.save_as_csv('thesis_full.csv', ['query','keywords','url', 'date','author','title','pdf_url','abstract'])\ncrawler.save_as_csv('thesis.csv', ['query','keywords','title','pdf_url','abstract'])",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code"
]
] |
ecae111d2a19339d3b08d7520115f809f253dfc6 | 46,259 | ipynb | Jupyter Notebook | jupyter_examples/example_2_three_izhikevich_neurons.ipynb | colinator/spikeflow | 109aea58c3d2c7b2da8680ddd98fa99bdaf20579 | [
"MIT"
] | 32 | 2019-01-31T16:50:57.000Z | 2022-01-18T09:55:22.000Z | jupyter_examples/example_2_three_izhikevich_neurons.ipynb | colinator/spikeflow | 109aea58c3d2c7b2da8680ddd98fa99bdaf20579 | [
"MIT"
] | null | null | null | jupyter_examples/example_2_three_izhikevich_neurons.ipynb | colinator/spikeflow | 109aea58c3d2c7b2da8680ddd98fa99bdaf20579 | [
"MIT"
] | 6 | 2019-05-26T14:55:05.000Z | 2022-01-14T08:54:27.000Z | 294.643312 | 42,562 | 0.92382 | [
[
[
"# Print 3 Izhikevich neuron traces",
"_____no_output_____"
]
],
[
[
"import numpy as np\nfrom spikeflow import BPNNModel, IzhikevichNeuronLayer\nimport spikeflow.drawing_utils.trace_renderers as rend",
"/Applications/Anaconda/anaconda/envs/mlbook/lib/python3.6/site-packages/h5py/__init__.py:34: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.\n from ._conv import register_converters as _register_converters\n"
]
],
[
[
"# Create a model layer with 3 neurons in a single layer",
"_____no_output_____"
]
],
[
[
"model_input_shape = (3,)\n\nnl = IzhikevichNeuronLayer.layer_from_tuples('n1', [\n IzhikevichNeuronLayer.C(a=0.010, b=0.2, c=-65.0, d=6.0, t=30.0, v0=0.0),\n IzhikevichNeuronLayer.C(a=0.015, b=0.2, c=-65.0, d=6.0, t=30.0, v0=0.0),\n IzhikevichNeuronLayer.C(a=0.020, b=0.2, c=-65.0, d=6.0, t=30.0, v0=0.0)\n])\n\nmodel = BPNNModel.compiled_model(model_input_shape, [nl], [])",
"_____no_output_____"
]
],
[
[
"# Run the model for 2000 timesteps",
"_____no_output_____"
]
],
[
[
"traces = []\n\ndef end_time_step_callback(i, graph, sess, results):\n traces.append(results)\n \ndata = (np.ones(3,)*(7 if i > 1200 else 0) for i in range(0, 2000))\n \nmodel.run_time(data, end_time_step_callback)",
"_____no_output_____"
]
],
[
[
"# Extract the data we want and display (after 1000 timestep settle-down period)",
"_____no_output_____"
]
],
[
[
"neuron_layer_0_traces = np.array([r['n1'] for r in traces])\n\nrend.render_figure([rend.IzhikevichNeuronTraceRenderer(neuron_layer_0_traces, 'Layer 0 Neuron')], 1000, 2000)",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecae1804c18884535ff48ba08ff0204c926d6d51 | 16,507 | ipynb | Jupyter Notebook | 01_Getting_&_Knowing_Your_Data/Chipotle/Exercises.ipynb | ae-chan/pandas_exercises | 16a911e7b05a94f386e34e5f058d224d53c79c60 | [
"BSD-3-Clause"
] | null | null | null | 01_Getting_&_Knowing_Your_Data/Chipotle/Exercises.ipynb | ae-chan/pandas_exercises | 16a911e7b05a94f386e34e5f058d224d53c79c60 | [
"BSD-3-Clause"
] | null | null | null | 01_Getting_&_Knowing_Your_Data/Chipotle/Exercises.ipynb | ae-chan/pandas_exercises | 16a911e7b05a94f386e34e5f058d224d53c79c60 | [
"BSD-3-Clause"
] | null | null | null | 22.70564 | 135 | 0.430666 | [
[
[
"# Ex2 - Getting and Knowing your Data",
"_____no_output_____"
],
[
"This time we are going to pull data directly from the internet.\nSpecial thanks to: https://github.com/justmarkham for sharing the dataset and materials.\n\n### Step 1. Import the necessary libraries",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nimport requests",
"_____no_output_____"
]
],
[
[
"### Step 2. Import the dataset from this [address](https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv). ",
"_____no_output_____"
],
[
"### Step 3. Assign it to a variable called chipo.",
"_____no_output_____"
]
],
[
[
"url = 'https://raw.githubusercontent.com/justmarkham/DAT8/master/data/chipotle.tsv'\nchipo = pd.read_csv(url, delimiter='\\t')",
"_____no_output_____"
]
],
[
[
"### Step 4. See the first 10 entries",
"_____no_output_____"
]
],
[
[
"chipo.head(10)",
"_____no_output_____"
]
],
[
[
"### Step 5. What is the number of observations in the dataset?",
"_____no_output_____"
]
],
[
[
"# Solution 1\nchipo.shape[0]",
"_____no_output_____"
],
[
"# Solution 2\nmax(chipo.count())\n",
"_____no_output_____"
]
],
[
[
"### Step 6. What is the number of columns in the dataset?",
"_____no_output_____"
]
],
[
[
"chipo.shape[1]",
"_____no_output_____"
]
],
[
[
"### Step 7. Print the name of all the columns.",
"_____no_output_____"
]
],
[
[
"print(list(chipo.columns))",
"['order_id', 'quantity', 'item_name', 'choice_description', 'item_price']\n"
]
],
[
[
"### Step 8. How is the dataset indexed?",
"_____no_output_____"
]
],
[
[
"chipo.index",
"_____no_output_____"
]
],
[
[
"### Step 9. Which was the most-ordered item? ",
"_____no_output_____"
]
],
[
[
"chipo.groupby(['item_name']).sum().sort_values('quantity').tail(1)[['order_id']].index[0]",
"_____no_output_____"
]
],
[
[
"### Step 10. For the most-ordered item, how many items were ordered?",
"_____no_output_____"
]
],
[
[
"chipo.groupby(['item_name']).sum().sort_values('quantity').tail(1)[['quantity']]['quantity'][0]",
"_____no_output_____"
]
],
[
[
"### Step 11. What was the most ordered item in the choice_description column?",
"_____no_output_____"
]
],
[
[
"chipo.groupby('choice_description').sum().sort_values('quantity').tail(1).index[0]",
"_____no_output_____"
]
],
[
[
"### Step 12. How many items were orderd in total?",
"_____no_output_____"
]
],
[
[
"chipo.groupby('choice_description').sum().sort_values('quantity').tail(1)['quantity'][0]",
"_____no_output_____"
]
],
[
[
"### Step 13. Turn the item price into a float",
"_____no_output_____"
],
[
"#### Step 13.a. Check the item price type",
"_____no_output_____"
]
],
[
[
"chipo.info()",
"<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 4622 entries, 0 to 4621\nData columns (total 5 columns):\n # Column Non-Null Count Dtype \n--- ------ -------------- ----- \n 0 order_id 4622 non-null int64 \n 1 quantity 4622 non-null int64 \n 2 item_name 4622 non-null object\n 3 choice_description 3376 non-null object\n 4 item_price 4622 non-null object\ndtypes: int64(2), object(3)\nmemory usage: 180.7+ KB\n"
]
],
[
[
"#### Step 13.b. Create a lambda function and change the type of item price",
"_____no_output_____"
]
],
[
[
"#item_price_float = pd.Series(float(price.replace('$', '')) for price in chipo['item_price'])\n#item_price_float.name = 'item_price_float'\n\nxvert = lambda price: float(price.replace('$',''))\nitem_price = pd.Series(map(xvert, chipo['item_price']))",
"_____no_output_____"
]
],
[
[
"#### Step 13.c. Check the item price type",
"_____no_output_____"
]
],
[
[
"chipo['item_price'] = item_price\nchipo['item_price'].dtypes",
"_____no_output_____"
]
],
[
[
"### Step 14. How much was the revenue for the period in the dataset?",
"_____no_output_____"
]
],
[
[
"chipo['sales'] = chipo['quantity'] * chipo['item_price']\nchipo['sales'].sum()",
"_____no_output_____"
]
],
[
[
"### Step 15. How many orders were made in the period?",
"_____no_output_____"
]
],
[
[
"len(chipo['order_id'].unique())",
"_____no_output_____"
]
],
[
[
"### Step 16. What is the average revenue amount per order?",
"_____no_output_____"
]
],
[
[
"# Solution 1\nchipo.groupby('order_id').sum().mean()['sales']",
"_____no_output_____"
],
[
"# Solution 2\n\n",
"_____no_output_____"
]
],
[
[
"### Step 17. How many different items are sold?",
"_____no_output_____"
]
],
[
[
"len(chipo['item_name'].unique())",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecae1a28b9f43b4a2cb561e6dc4b8b8b23b88027 | 683,928 | ipynb | Jupyter Notebook | Digital-Signal-Processing/waveform_sinusoidal.ipynb | diegoinacio/computer-vision-notebooks | a86c63ab7d4e3cf0397d9962dd09e06151d9ad69 | [
"MIT"
] | 81 | 2020-02-17T22:02:49.000Z | 2022-03-21T16:28:23.000Z | Digital-Signal-Processing/waveform_sinusoidal.ipynb | Banhkun/computer-vision-notebooks | a86c63ab7d4e3cf0397d9962dd09e06151d9ad69 | [
"MIT"
] | 10 | 2020-09-03T19:39:12.000Z | 2021-06-22T12:26:02.000Z | Digital-Signal-Processing/waveform_sinusoidal.ipynb | Banhkun/computer-vision-notebooks | a86c63ab7d4e3cf0397d9962dd09e06151d9ad69 | [
"MIT"
] | 22 | 2020-05-13T05:56:26.000Z | 2022-02-25T04:20:19.000Z | 1,758.169666 | 352,952 | 0.958244 | [
[
[
"# Sinusoidal Periodic Waveform\n---\n- Author: Diego Inácio\n- GitHub: [github.com/diegoinacio](https://github.com/diegoinacio)\n- Notebook: [waveform_sinusoidal.ipynb](https://github.com/diegoinacio/computer-vision-notebooks/blob/master/Digital-Signal-Processing/waveform_sinusoidal.ipynb)\n---\nOverview about *sinusoidal periodic waveform* or *sine wave* function.",
"_____no_output_____"
]
],
[
[
"%matplotlib inline\nimport matplotlib.pyplot as plt\nfrom IPython.display import Audio\nimport numpy as np\n\nfrom _utils import *",
"_____no_output_____"
],
[
"fs = 44100 # Sampling rate\ndur = 3 # Duration in seconds\nt = np.linspace(0, dur, fs*dur) # Time vector",
"_____no_output_____"
]
],
[
[
"## 1. Sine wave\n---\n$$ \\large\nx(t)=A sin(2\\pi f t + \\phi)=A sin(\\omega t + \\phi)\n$$\n\nwhere,\n\n- $A$ = The aplitude;\n- $f$ = The ordinary frequency;\n- $\\omega$ = The angular frequency;\n- $\\phi$ = The phase.",
"_____no_output_____"
]
],
[
[
"A = 1\nf = 220\nomega = 2*np.pi*f\nphi = 0\n\nx = A*np.sin(omega*t + phi)",
"_____no_output_____"
],
[
"Audio(x, rate=fs)",
"_____no_output_____"
],
[
"summary(x)",
"\n min: -1.0000\n 1st Quar: -0.7071\n median: 0.0000\n mean: 0.0000\n 3rd Quar: 0.7071\n max: 1.0000\n sigma: 0.7071\n"
],
[
"audiovis(x, tlim=[0, 0.1])",
"audio mono\n"
],
[
"spectrogram(x, flim=[0,1000])",
"audio mono\n"
]
],
[
[
"## 2. Changing the parameters\n---",
"_____no_output_____"
]
],
[
[
"plt.rcParams['figure.figsize'] = (16, 4)",
"_____no_output_____"
]
],
[
[
"### 2.1. Amplitude\n---",
"_____no_output_____"
]
],
[
[
"A1 = 1\nA2 = 0.5\nx1 = A1*np.sin(2*np.pi*2*t + 0)\nx2 = A2*np.sin(2*np.pi*2*t + 0)",
"_____no_output_____"
],
[
"plt.plot(t, x1, label=r'$A_1={:.02f}$'.format(A1))\nplt.plot(t, x2, label=r'$A_2={:.02f}$'.format(A2))\nplt.legend()\nplt.show()",
"_____no_output_____"
]
],
[
[
"### 2.2. Frequency\n---",
"_____no_output_____"
]
],
[
[
"f1 = 220\nf2 = 440\nx1 = np.sin(2*np.pi*f1*t + 0)\nx2 = np.sin(2*np.pi*f2*t + 0)",
"_____no_output_____"
],
[
"plt.plot(t, x1, label=r'$f_1={0} \\quad Hz$'.format(f1))\nplt.plot(t, x2, label=r'$f_2={0} \\quad Hz$'.format(f2))\nplt.legend(fontsize=12); plt.xlim([0, 0.01])\nplt.show()",
"_____no_output_____"
],
[
"spectrogram(x1 + x2, flim=[0, 1000])",
"audio mono\n"
]
],
[
[
"### 2.3. Phase\n---",
"_____no_output_____"
]
],
[
[
"phi1 = 0\nphi2 = 2*np.pi/5\nx1 = np.sin(2*np.pi*1*t + phi1)\nx2 = np.sin(2*np.pi*1*t + phi2)",
"_____no_output_____"
],
[
"plt.plot(t, x1, label=r'$\\phi_1=0 \\quad rad \\cdot s^{-1}$')\nplt.plot(t, x2, label=r'$\\phi_2=\\frac{2\\pi}{5} \\quad rad \\cdot s^{-1}$')\nplt.legend(fontsize=12)\nplt.show()",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code"
]
] |
ecae2142b5233ae03f05aa541a4902647a8f9bfe | 9,266 | ipynb | Jupyter Notebook | Course-IntroToMachineLearining/course2.ipynb | xkcao/Kaggle | 2fef8f11ec42dadbf2a8deca9c668b6fa4e1aa3d | [
"Apache-2.0"
] | null | null | null | Course-IntroToMachineLearining/course2.ipynb | xkcao/Kaggle | 2fef8f11ec42dadbf2a8deca9c668b6fa4e1aa3d | [
"Apache-2.0"
] | null | null | null | Course-IntroToMachineLearining/course2.ipynb | xkcao/Kaggle | 2fef8f11ec42dadbf2a8deca9c668b6fa4e1aa3d | [
"Apache-2.0"
] | null | null | null | 35.776062 | 91 | 0.412584 | [
[
[
"import pandas as pd",
"_____no_output_____"
],
[
"# save filepath to variable for easier access\nmelbourne_file_path = 'data/melb_data.csv'\n# read the data and store data in DataFrame titled melbourne_data\nmelbourne_data = pd.read_csv(melbourne_file_path) \n# print a summary of the data in Melbourne data\nmelbourne_data.describe()",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code"
]
] |
ecae28b1b1e7f6df3816deb624ec17fe93ccfeed | 39,102 | ipynb | Jupyter Notebook | t81_558_class_14_04_ids_kdd99.ipynb | AritraJana1810/t81_558_deep_learning | 184d84d202b54990be8c927499ce0a01a3662e6f | [
"Apache-2.0"
] | 1 | 2020-09-01T11:31:29.000Z | 2020-09-01T11:31:29.000Z | t81_558_class_14_04_ids_kdd99.ipynb | joaquinmorenoa/t81_558_deep_learning | 569ed623cb225a5d410fda6f49e1a15073b247ea | [
"Apache-2.0"
] | null | null | null | t81_558_class_14_04_ids_kdd99.ipynb | joaquinmorenoa/t81_558_deep_learning | 569ed623cb225a5d410fda6f49e1a15073b247ea | [
"Apache-2.0"
] | 1 | 2020-09-21T15:11:35.000Z | 2020-09-21T15:11:35.000Z | 49.684879 | 1,213 | 0.506624 | [
[
[
"# T81-558: Applications of Deep Neural Networks\n**Module 14: Other Neural Network Techniques**\n* Instructor: [Jeff Heaton](https://sites.wustl.edu/jeffheaton/), McKelvey School of Engineering, [Washington University in St. Louis](https://engineering.wustl.edu/Programs/Pages/default.aspx)\n* For more information visit the [class website](https://sites.wustl.edu/jeffheaton/t81-558/).",
"_____no_output_____"
],
[
"# Module 14 Video Material\n\n* Part 14.1: What is AutoML [[Video]](https://www.youtube.com/watch?v=TFUysIR5AB0&list=PLjy4p-07OYzulelvJ5KVaT2pDlxivl_BN) [[Notebook]](t81_558_class_14_01_automl.ipynb)\n* Part 14.2: Using Denoising AutoEncoders in Keras [[Video]](https://www.youtube.com/watch?v=4bTSu6_fucc&list=PLjy4p-07OYzulelvJ5KVaT2pDlxivl_BN) [[Notebook]](t81_558_class_14_02_auto_encode.ipynb)\n* Part 14.3: Training an Intrusion Detection System with KDD99 [[Video]](https://www.youtube.com/watch?v=1ySn6h2A68I&list=PLjy4p-07OYzulelvJ5KVaT2pDlxivl_BN) [[Notebook]](t81_558_class_14_03_anomaly.ipynb)\n* **Part 14.4: Anomaly Detection in Keras** [[Video]](https://www.youtube.com/watch?v=VgyKQ5MTDFc&list=PLjy4p-07OYzulelvJ5KVaT2pDlxivl_BN) [[Notebook]](t81_558_class_14_04_ids_kdd99.ipynb)\n* Part 14.5: The Deep Learning Technologies I am Excited About [[Video]]() [[Notebook]](t81_558_class_14_05_new_tech.ipynb)\n\n",
"_____no_output_____"
],
[
"# Part 14.4: Training an Intrusion Detection System with KDD99\n\nThe [KDD-99 dataset](http://kdd.ics.uci.edu/databases/kddcup99/kddcup99.html) is very famous in the security field and almost a \"hello world\" of Intrusion Detection Systems (IDS) in machine learning. An intrusion detection system (IDS) is program that monitors computers and network systems for malicious activity or policy violations. Any intrusion activity or violation is typically reported either to an administrator or collected centrally. IDS types range in scope from single computers to large networks. Although KDD99 dataset is over 20 years old, it is still widely used to demonstrate Intrusion Detection Systems (IDS). KDD99 is the data set used for The Third International Knowledge Discovery and Data Mining Tools Competition, which was held in conjunction with KDD-99 The Fifth International Conference on Knowledge Discovery and Data Mining. The competition task was to build a network intrusion detector, a predictive model capable of distinguishing between \"bad\" connections, called intrusions or attacks, and \"good\" normal connections. This database contains a standard set of data to be audited, including a wide variety of intrusions simulated in a military network environment.\n\n\n### Read in Raw KDD-99 Dataset\n\nThe following code reads the KDD99 CSV dataset into a Pandas data frame. The standard format of KDD99 does not include column names. Because of that, the program adds them.",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nfrom tensorflow.keras.utils import get_file\n\ntry:\n path = get_file('kddcup.data_10_percent.gz', origin='http://kdd.ics.uci.edu/databases/kddcup99/kddcup.data_10_percent.gz')\nexcept:\n print('Error downloading')\n raise\n \nprint(path) \n\n# This file is a CSV, just no CSV extension or headers\n# Download from: http://kdd.ics.uci.edu/databases/kddcup99/kddcup99.html\ndf = pd.read_csv(path, header=None)\n\nprint(\"Read {} rows.\".format(len(df)))\n# df = df.sample(frac=0.1, replace=False) # Uncomment this line to sample only 10% of the dataset\ndf.dropna(inplace=True,axis=1) # For now, just drop NA's (rows with missing values)\n\n# The CSV file has no column heads, so add them\ndf.columns = [\n 'duration',\n 'protocol_type',\n 'service',\n 'flag',\n 'src_bytes',\n 'dst_bytes',\n 'land',\n 'wrong_fragment',\n 'urgent',\n 'hot',\n 'num_failed_logins',\n 'logged_in',\n 'num_compromised',\n 'root_shell',\n 'su_attempted',\n 'num_root',\n 'num_file_creations',\n 'num_shells',\n 'num_access_files',\n 'num_outbound_cmds',\n 'is_host_login',\n 'is_guest_login',\n 'count',\n 'srv_count',\n 'serror_rate',\n 'srv_serror_rate',\n 'rerror_rate',\n 'srv_rerror_rate',\n 'same_srv_rate',\n 'diff_srv_rate',\n 'srv_diff_host_rate',\n 'dst_host_count',\n 'dst_host_srv_count',\n 'dst_host_same_srv_rate',\n 'dst_host_diff_srv_rate',\n 'dst_host_same_src_port_rate',\n 'dst_host_srv_diff_host_rate',\n 'dst_host_serror_rate',\n 'dst_host_srv_serror_rate',\n 'dst_host_rerror_rate',\n 'dst_host_srv_rerror_rate',\n 'outcome'\n]\n\n# display 5 rows\ndf[0:5]",
"/Users/jheaton/.keras/datasets/kddcup.data_10_percent.gz\nRead 494021 rows.\n"
]
],
[
[
"### Analyzing a Dataset\n\nBefore we preprocess the KDD99 dataset let's have a look at the individual columns and distributions. You can use the following script to give a high-level overview of how a dataset appears.",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nimport os\nimport numpy as np\nfrom sklearn import metrics\nfrom scipy.stats import zscore\n\ndef expand_categories(values):\n result = []\n s = values.value_counts()\n t = float(len(values))\n for v in s.index:\n result.append(\"{}:{}%\".format(v,round(100*(s[v]/t),2)))\n return \"[{}]\".format(\",\".join(result))\n \ndef analyze(df):\n print()\n cols = df.columns.values\n total = float(len(df))\n\n print(\"{} rows\".format(int(total)))\n for col in cols:\n uniques = df[col].unique()\n unique_count = len(uniques)\n if unique_count>100:\n print(\"** {}:{} ({}%)\".format(col,unique_count,int(((unique_count)/total)*100)))\n else:\n print(\"** {}:{}\".format(col,expand_categories(df[col])))\n expand_categories(df[col])",
"_____no_output_____"
]
],
[
[
"The analysis looks at how many unique values are present. For example, duration, which is a numeric value, has 2495 unique values, and there is a 0% overlap. A text/categorical value such as protocol_type only has a few unique values, and the program shows the percentages of each. Columns with a large number of unique values do not have their item counts shown to save display space.",
"_____no_output_____"
]
],
[
[
"# Analyze KDD-99\nanalyze(df)",
"\n494021 rows\n** duration:2495 (0%)\n** protocol_type:[icmp:57.41%,tcp:38.47%,udp:4.12%]\n** service:[ecr_i:56.96%,private:22.45%,http:13.01%,smtp:1.97%,other:1.46%,domain_u:1.19%,ftp_data:0.96%,eco_i:0.33%,ftp:0.16%,finger:0.14%,urp_i:0.11%,telnet:0.1%,ntp_u:0.08%,auth:0.07%,pop_3:0.04%,time:0.03%,csnet_ns:0.03%,remote_job:0.02%,gopher:0.02%,imap4:0.02%,discard:0.02%,domain:0.02%,systat:0.02%,iso_tsap:0.02%,shell:0.02%,echo:0.02%,rje:0.02%,whois:0.02%,sql_net:0.02%,printer:0.02%,nntp:0.02%,courier:0.02%,sunrpc:0.02%,mtp:0.02%,netbios_ssn:0.02%,uucp_path:0.02%,bgp:0.02%,klogin:0.02%,uucp:0.02%,vmnet:0.02%,supdup:0.02%,ssh:0.02%,nnsp:0.02%,login:0.02%,hostnames:0.02%,efs:0.02%,daytime:0.02%,netbios_ns:0.02%,link:0.02%,ldap:0.02%,pop_2:0.02%,exec:0.02%,netbios_dgm:0.02%,http_443:0.02%,kshell:0.02%,name:0.02%,ctf:0.02%,netstat:0.02%,Z39_50:0.02%,IRC:0.01%,urh_i:0.0%,X11:0.0%,tim_i:0.0%,tftp_u:0.0%,red_i:0.0%,pm_dump:0.0%]\n** flag:[SF:76.6%,S0:17.61%,REJ:5.44%,RSTR:0.18%,RSTO:0.12%,SH:0.02%,S1:0.01%,S2:0.0%,RSTOS0:0.0%,S3:0.0%,OTH:0.0%]\n** src_bytes:3300 (0%)\n** dst_bytes:10725 (2%)\n** land:[0:100.0%,1:0.0%]\n** wrong_fragment:[0:99.75%,3:0.2%,1:0.05%]\n** urgent:[0:100.0%,1:0.0%,3:0.0%,2:0.0%]\n** hot:[0:99.35%,2:0.44%,28:0.06%,1:0.05%,4:0.02%,6:0.02%,5:0.01%,3:0.01%,14:0.01%,30:0.01%,22:0.01%,19:0.0%,18:0.0%,24:0.0%,20:0.0%,7:0.0%,17:0.0%,12:0.0%,15:0.0%,16:0.0%,10:0.0%,9:0.0%]\n** num_failed_logins:[0:99.99%,1:0.01%,2:0.0%,5:0.0%,4:0.0%,3:0.0%]\n** logged_in:[0:85.18%,1:14.82%]\n** num_compromised:[0:99.55%,1:0.44%,2:0.0%,4:0.0%,3:0.0%,6:0.0%,5:0.0%,7:0.0%,12:0.0%,9:0.0%,11:0.0%,767:0.0%,238:0.0%,16:0.0%,18:0.0%,275:0.0%,21:0.0%,22:0.0%,281:0.0%,38:0.0%,102:0.0%,884:0.0%,13:0.0%]\n** root_shell:[0:99.99%,1:0.01%]\n** su_attempted:[0:100.0%,2:0.0%,1:0.0%]\n** num_root:[0:99.88%,1:0.05%,9:0.03%,6:0.03%,2:0.0%,5:0.0%,4:0.0%,3:0.0%,119:0.0%,7:0.0%,993:0.0%,268:0.0%,14:0.0%,16:0.0%,278:0.0%,39:0.0%,306:0.0%,54:0.0%,857:0.0%,12:0.0%]\n** num_file_creations:[0:99.95%,1:0.04%,2:0.01%,4:0.0%,16:0.0%,9:0.0%,5:0.0%,7:0.0%,8:0.0%,28:0.0%,25:0.0%,12:0.0%,14:0.0%,15:0.0%,20:0.0%,21:0.0%,22:0.0%,10:0.0%]\n** num_shells:[0:99.99%,1:0.01%,2:0.0%]\n** num_access_files:[0:99.91%,1:0.09%,2:0.01%,3:0.0%,8:0.0%,6:0.0%,4:0.0%]\n** num_outbound_cmds:[0:100.0%]\n** is_host_login:[0:100.0%]\n** is_guest_login:[0:99.86%,1:0.14%]\n** count:490 (0%)\n** srv_count:470 (0%)\n** serror_rate:[0.0:81.94%,1.0:17.52%,0.99:0.06%,0.08:0.03%,0.05:0.03%,0.07:0.03%,0.06:0.03%,0.14:0.02%,0.04:0.02%,0.01:0.02%,0.09:0.02%,0.1:0.02%,0.03:0.02%,0.11:0.02%,0.13:0.02%,0.5:0.02%,0.12:0.02%,0.2:0.01%,0.25:0.01%,0.02:0.01%,0.17:0.01%,0.33:0.01%,0.15:0.01%,0.22:0.01%,0.18:0.01%,0.23:0.01%,0.16:0.01%,0.21:0.01%,0.19:0.0%,0.27:0.0%,0.98:0.0%,0.44:0.0%,0.29:0.0%,0.24:0.0%,0.97:0.0%,0.96:0.0%,0.31:0.0%,0.26:0.0%,0.67:0.0%,0.36:0.0%,0.65:0.0%,0.94:0.0%,0.28:0.0%,0.79:0.0%,0.95:0.0%,0.53:0.0%,0.81:0.0%,0.62:0.0%,0.85:0.0%,0.6:0.0%,0.64:0.0%,0.88:0.0%,0.68:0.0%,0.52:0.0%,0.66:0.0%,0.71:0.0%,0.93:0.0%,0.57:0.0%,0.63:0.0%,0.83:0.0%,0.78:0.0%,0.75:0.0%,0.51:0.0%,0.58:0.0%,0.56:0.0%,0.55:0.0%,0.3:0.0%,0.76:0.0%,0.86:0.0%,0.74:0.0%,0.35:0.0%,0.38:0.0%,0.54:0.0%,0.72:0.0%,0.84:0.0%,0.69:0.0%,0.61:0.0%,0.59:0.0%,0.42:0.0%,0.32:0.0%,0.82:0.0%,0.77:0.0%,0.7:0.0%,0.91:0.0%,0.92:0.0%,0.4:0.0%,0.73:0.0%,0.9:0.0%,0.34:0.0%,0.8:0.0%,0.89:0.0%,0.87:0.0%]\n** srv_serror_rate:[0.0:82.12%,1.0:17.62%,0.03:0.03%,0.04:0.02%,0.05:0.02%,0.06:0.02%,0.02:0.02%,0.5:0.02%,0.08:0.01%,0.07:0.01%,0.25:0.01%,0.33:0.01%,0.17:0.01%,0.09:0.01%,0.1:0.01%,0.2:0.01%,0.11:0.01%,0.12:0.01%,0.14:0.01%,0.01:0.0%,0.67:0.0%,0.92:0.0%,0.18:0.0%,0.94:0.0%,0.95:0.0%,0.58:0.0%,0.88:0.0%,0.75:0.0%,0.19:0.0%,0.4:0.0%,0.76:0.0%,0.83:0.0%,0.91:0.0%,0.15:0.0%,0.22:0.0%,0.93:0.0%,0.85:0.0%,0.27:0.0%,0.86:0.0%,0.44:0.0%,0.35:0.0%,0.51:0.0%,0.36:0.0%,0.38:0.0%,0.21:0.0%,0.8:0.0%,0.9:0.0%,0.45:0.0%,0.16:0.0%,0.37:0.0%,0.23:0.0%]\n** rerror_rate:[0.0:94.12%,1.0:5.46%,0.86:0.02%,0.87:0.02%,0.92:0.02%,0.25:0.02%,0.95:0.02%,0.9:0.02%,0.5:0.02%,0.91:0.02%,0.88:0.01%,0.96:0.01%,0.33:0.01%,0.2:0.01%,0.93:0.01%,0.94:0.01%,0.01:0.01%,0.89:0.01%,0.85:0.01%,0.99:0.01%,0.82:0.01%,0.77:0.01%,0.17:0.01%,0.97:0.01%,0.02:0.01%,0.98:0.01%,0.03:0.01%,0.8:0.01%,0.78:0.01%,0.76:0.01%,0.75:0.0%,0.79:0.0%,0.84:0.0%,0.14:0.0%,0.05:0.0%,0.73:0.0%,0.81:0.0%,0.06:0.0%,0.71:0.0%,0.83:0.0%,0.67:0.0%,0.56:0.0%,0.08:0.0%,0.04:0.0%,0.1:0.0%,0.09:0.0%,0.12:0.0%,0.07:0.0%,0.11:0.0%,0.69:0.0%,0.74:0.0%,0.64:0.0%,0.4:0.0%,0.72:0.0%,0.7:0.0%,0.6:0.0%,0.29:0.0%,0.22:0.0%,0.62:0.0%,0.65:0.0%,0.21:0.0%,0.68:0.0%,0.37:0.0%,0.19:0.0%,0.43:0.0%,0.58:0.0%,0.35:0.0%,0.24:0.0%,0.31:0.0%,0.23:0.0%,0.27:0.0%,0.28:0.0%,0.26:0.0%,0.36:0.0%,0.34:0.0%,0.66:0.0%,0.32:0.0%]\n** srv_rerror_rate:[0.0:93.99%,1.0:5.69%,0.33:0.05%,0.5:0.04%,0.25:0.04%,0.2:0.03%,0.17:0.03%,0.14:0.01%,0.04:0.01%,0.03:0.01%,0.12:0.01%,0.02:0.01%,0.06:0.01%,0.05:0.01%,0.07:0.01%,0.4:0.01%,0.67:0.01%,0.08:0.01%,0.11:0.01%,0.29:0.01%,0.09:0.0%,0.1:0.0%,0.75:0.0%,0.6:0.0%,0.01:0.0%,0.22:0.0%,0.71:0.0%,0.86:0.0%,0.83:0.0%,0.73:0.0%,0.81:0.0%,0.88:0.0%,0.96:0.0%,0.92:0.0%,0.18:0.0%,0.43:0.0%,0.79:0.0%,0.93:0.0%,0.13:0.0%,0.27:0.0%,0.38:0.0%,0.94:0.0%,0.95:0.0%,0.37:0.0%,0.85:0.0%,0.8:0.0%,0.62:0.0%,0.82:0.0%,0.69:0.0%,0.21:0.0%,0.87:0.0%]\n** same_srv_rate:[1.0:77.34%,0.06:2.27%,0.05:2.14%,0.04:2.06%,0.07:2.03%,0.03:1.93%,0.02:1.9%,0.01:1.77%,0.08:1.48%,0.09:1.01%,0.1:0.8%,0.0:0.73%,0.12:0.73%,0.11:0.67%,0.13:0.66%,0.14:0.51%,0.15:0.35%,0.5:0.29%,0.16:0.25%,0.17:0.17%,0.33:0.12%,0.18:0.1%,0.2:0.08%,0.19:0.07%,0.67:0.05%,0.25:0.04%,0.21:0.04%,0.99:0.03%,0.22:0.03%,0.24:0.02%,0.23:0.02%,0.4:0.02%,0.98:0.02%,0.75:0.02%,0.27:0.02%,0.26:0.01%,0.8:0.01%,0.29:0.01%,0.38:0.01%,0.86:0.01%,0.3:0.01%,0.31:0.01%,0.44:0.01%,0.83:0.01%,0.36:0.01%,0.28:0.01%,0.43:0.01%,0.6:0.01%,0.42:0.01%,0.97:0.01%,0.32:0.01%,0.35:0.01%,0.45:0.01%,0.47:0.01%,0.88:0.0%,0.48:0.0%,0.39:0.0%,0.52:0.0%,0.46:0.0%,0.37:0.0%,0.41:0.0%,0.89:0.0%,0.34:0.0%,0.92:0.0%,0.54:0.0%,0.53:0.0%,0.94:0.0%,0.95:0.0%,0.57:0.0%,0.96:0.0%,0.64:0.0%,0.71:0.0%,0.56:0.0%,0.62:0.0%,0.78:0.0%,0.9:0.0%,0.49:0.0%,0.91:0.0%,0.55:0.0%,0.65:0.0%,0.73:0.0%,0.58:0.0%,0.59:0.0%,0.93:0.0%,0.76:0.0%,0.51:0.0%,0.77:0.0%,0.82:0.0%,0.81:0.0%,0.74:0.0%,0.69:0.0%,0.79:0.0%,0.72:0.0%,0.7:0.0%,0.85:0.0%,0.68:0.0%,0.61:0.0%,0.63:0.0%,0.87:0.0%]\n** diff_srv_rate:[0.0:77.33%,0.06:10.69%,0.07:5.83%,0.05:3.89%,0.08:0.66%,1.0:0.48%,0.04:0.19%,0.67:0.13%,0.5:0.12%,0.09:0.08%,0.6:0.06%,0.12:0.05%,0.1:0.04%,0.11:0.04%,0.14:0.03%,0.4:0.02%,0.13:0.02%,0.29:0.02%,0.01:0.02%,0.15:0.02%,0.03:0.02%,0.33:0.02%,0.17:0.02%,0.25:0.02%,0.75:0.01%,0.2:0.01%,0.18:0.01%,0.16:0.01%,0.19:0.01%,0.02:0.01%,0.22:0.01%,0.21:0.01%,0.27:0.01%,0.96:0.01%,0.31:0.01%,0.38:0.01%,0.24:0.01%,0.23:0.01%,0.43:0.0%,0.52:0.0%,0.95:0.0%,0.44:0.0%,0.53:0.0%,0.36:0.0%,0.8:0.0%,0.57:0.0%,0.42:0.0%,0.3:0.0%,0.26:0.0%,0.28:0.0%,0.56:0.0%,0.99:0.0%,0.54:0.0%,0.62:0.0%,0.37:0.0%,0.55:0.0%,0.35:0.0%,0.41:0.0%,0.47:0.0%,0.89:0.0%,0.32:0.0%,0.71:0.0%,0.58:0.0%,0.46:0.0%,0.39:0.0%,0.51:0.0%,0.45:0.0%,0.97:0.0%,0.83:0.0%,0.7:0.0%,0.69:0.0%,0.78:0.0%,0.74:0.0%,0.64:0.0%,0.73:0.0%,0.82:0.0%,0.88:0.0%,0.86:0.0%]\n** srv_diff_host_rate:[0.0:92.99%,1.0:1.64%,0.12:0.31%,0.5:0.29%,0.67:0.29%,0.33:0.25%,0.11:0.24%,0.25:0.23%,0.1:0.22%,0.14:0.21%,0.17:0.21%,0.08:0.2%,0.15:0.2%,0.18:0.19%,0.2:0.19%,0.09:0.19%,0.4:0.19%,0.07:0.17%,0.29:0.17%,0.13:0.16%,0.22:0.16%,0.06:0.14%,0.02:0.1%,0.05:0.1%,0.01:0.08%,0.21:0.08%,0.19:0.08%,0.16:0.07%,0.75:0.07%,0.27:0.06%,0.04:0.06%,0.6:0.06%,0.3:0.06%,0.38:0.05%,0.43:0.05%,0.23:0.05%,0.03:0.03%,0.24:0.02%,0.36:0.02%,0.31:0.02%,0.8:0.02%,0.57:0.01%,0.44:0.01%,0.28:0.01%,0.26:0.01%,0.42:0.0%,0.45:0.0%,0.62:0.0%,0.83:0.0%,0.71:0.0%,0.56:0.0%,0.35:0.0%,0.32:0.0%,0.37:0.0%,0.41:0.0%,0.47:0.0%,0.86:0.0%,0.55:0.0%,0.54:0.0%,0.88:0.0%,0.64:0.0%,0.46:0.0%,0.7:0.0%,0.77:0.0%]\n** dst_host_count:256 (0%)\n** dst_host_srv_count:256 (0%)\n** dst_host_same_srv_rate:101 (0%)\n** dst_host_diff_srv_rate:101 (0%)\n** dst_host_same_src_port_rate:101 (0%)\n** dst_host_srv_diff_host_rate:[0.0:89.45%,0.02:2.38%,0.01:2.13%,0.04:1.35%,0.03:1.34%,0.05:0.94%,0.06:0.39%,0.07:0.31%,0.5:0.15%,0.08:0.14%,0.09:0.13%,0.15:0.09%,0.11:0.09%,0.16:0.08%,0.13:0.08%,0.1:0.08%,0.14:0.07%,1.0:0.07%,0.17:0.07%,0.2:0.07%,0.12:0.07%,0.18:0.07%,0.25:0.05%,0.22:0.05%,0.19:0.05%,0.21:0.05%,0.24:0.03%,0.23:0.02%,0.26:0.02%,0.27:0.02%,0.33:0.02%,0.29:0.02%,0.51:0.02%,0.4:0.01%,0.28:0.01%,0.3:0.01%,0.67:0.01%,0.52:0.01%,0.31:0.01%,0.32:0.01%,0.38:0.01%,0.53:0.0%,0.43:0.0%,0.44:0.0%,0.34:0.0%,0.6:0.0%,0.36:0.0%,0.57:0.0%,0.35:0.0%,0.54:0.0%,0.37:0.0%,0.56:0.0%,0.55:0.0%,0.42:0.0%,0.46:0.0%,0.45:0.0%,0.41:0.0%,0.48:0.0%,0.39:0.0%,0.8:0.0%,0.7:0.0%,0.47:0.0%,0.62:0.0%,0.75:0.0%,0.58:0.0%]\n** dst_host_serror_rate:[0.0:80.93%,1.0:17.56%,0.01:0.74%,0.02:0.2%,0.03:0.09%,0.09:0.05%,0.04:0.04%,0.05:0.04%,0.07:0.03%,0.08:0.03%,0.06:0.02%,0.14:0.02%,0.15:0.02%,0.11:0.02%,0.13:0.02%,0.16:0.02%,0.1:0.02%,0.12:0.01%,0.18:0.01%,0.25:0.01%,0.2:0.01%,0.17:0.01%,0.33:0.01%,0.99:0.01%,0.19:0.01%,0.31:0.01%,0.27:0.01%,0.5:0.0%,0.22:0.0%,0.98:0.0%,0.35:0.0%,0.28:0.0%,0.53:0.0%,0.24:0.0%,0.96:0.0%,0.3:0.0%,0.26:0.0%,0.97:0.0%,0.29:0.0%,0.94:0.0%,0.42:0.0%,0.32:0.0%,0.56:0.0%,0.55:0.0%,0.95:0.0%,0.6:0.0%,0.23:0.0%,0.93:0.0%,0.34:0.0%,0.85:0.0%,0.89:0.0%,0.21:0.0%,0.92:0.0%,0.58:0.0%,0.43:0.0%,0.9:0.0%,0.57:0.0%,0.91:0.0%,0.49:0.0%,0.82:0.0%,0.36:0.0%,0.87:0.0%,0.45:0.0%,0.62:0.0%,0.65:0.0%,0.46:0.0%,0.38:0.0%,0.61:0.0%,0.47:0.0%,0.76:0.0%,0.81:0.0%,0.54:0.0%,0.64:0.0%,0.44:0.0%,0.48:0.0%,0.72:0.0%,0.39:0.0%,0.52:0.0%,0.51:0.0%,0.67:0.0%,0.84:0.0%,0.73:0.0%,0.4:0.0%,0.69:0.0%,0.79:0.0%,0.41:0.0%,0.68:0.0%,0.88:0.0%,0.77:0.0%,0.75:0.0%,0.7:0.0%,0.8:0.0%,0.59:0.0%,0.71:0.0%,0.37:0.0%,0.86:0.0%,0.66:0.0%,0.78:0.0%,0.74:0.0%,0.83:0.0%]\n** dst_host_srv_serror_rate:[0.0:81.16%,1.0:17.61%,0.01:0.99%,0.02:0.14%,0.03:0.03%,0.04:0.02%,0.05:0.01%,0.06:0.01%,0.08:0.0%,0.5:0.0%,0.07:0.0%,0.1:0.0%,0.09:0.0%,0.11:0.0%,0.17:0.0%,0.14:0.0%,0.12:0.0%,0.96:0.0%,0.33:0.0%,0.67:0.0%,0.97:0.0%,0.25:0.0%,0.98:0.0%,0.4:0.0%,0.75:0.0%,0.48:0.0%,0.83:0.0%,0.16:0.0%,0.93:0.0%,0.69:0.0%,0.2:0.0%,0.91:0.0%,0.78:0.0%,0.95:0.0%,0.8:0.0%,0.92:0.0%,0.68:0.0%,0.29:0.0%,0.38:0.0%,0.88:0.0%,0.3:0.0%,0.32:0.0%,0.94:0.0%,0.57:0.0%,0.63:0.0%,0.62:0.0%,0.31:0.0%,0.85:0.0%,0.56:0.0%,0.81:0.0%,0.74:0.0%,0.86:0.0%,0.13:0.0%,0.23:0.0%,0.18:0.0%,0.64:0.0%,0.46:0.0%,0.52:0.0%,0.66:0.0%,0.6:0.0%,0.84:0.0%,0.55:0.0%,0.9:0.0%,0.15:0.0%,0.79:0.0%,0.82:0.0%,0.87:0.0%,0.47:0.0%,0.53:0.0%,0.45:0.0%,0.42:0.0%,0.24:0.0%]\n** dst_host_rerror_rate:101 (0%)\n** dst_host_srv_rerror_rate:101 (0%)\n** outcome:[smurf.:56.84%,neptune.:21.7%,normal.:19.69%,back.:0.45%,satan.:0.32%,ipsweep.:0.25%,portsweep.:0.21%,warezclient.:0.21%,teardrop.:0.2%,pod.:0.05%,nmap.:0.05%,guess_passwd.:0.01%,buffer_overflow.:0.01%,land.:0.0%,warezmaster.:0.0%,imap.:0.0%,rootkit.:0.0%,loadmodule.:0.0%,ftp_write.:0.0%,multihop.:0.0%,phf.:0.0%,perl.:0.0%,spy.:0.0%]\n"
]
],
[
[
"# Encode the feature vector\n\n\nWe use the same two functions provided earlier to preprocess the data. The first encodes Z-Scores, and the second creates dummy variables from categorical columns.",
"_____no_output_____"
]
],
[
[
"# Encode a numeric column as zscores\ndef encode_numeric_zscore(df, name, mean=None, sd=None):\n if mean is None:\n mean = df[name].mean()\n\n if sd is None:\n sd = df[name].std()\n\n df[name] = (df[name] - mean) / sd\n \n# Encode text values to dummy variables(i.e. [1,0,0],[0,1,0],[0,0,1] for red,green,blue)\ndef encode_text_dummy(df, name):\n dummies = pd.get_dummies(df[name])\n for x in dummies.columns:\n dummy_name = f\"{name}-{x}\"\n df[dummy_name] = dummies[x]\n df.drop(name, axis=1, inplace=True)\n",
"_____no_output_____"
]
],
[
[
"Again, just as we did for anomaly detection, we preprocess the data set. We convert all numeric values to Z-Score, and we translate all categorical to dummy variables.",
"_____no_output_____"
]
],
[
[
"# Now encode the feature vector\n\nencode_numeric_zscore(df, 'duration')\nencode_text_dummy(df, 'protocol_type')\nencode_text_dummy(df, 'service')\nencode_text_dummy(df, 'flag')\nencode_numeric_zscore(df, 'src_bytes')\nencode_numeric_zscore(df, 'dst_bytes')\nencode_text_dummy(df, 'land')\nencode_numeric_zscore(df, 'wrong_fragment')\nencode_numeric_zscore(df, 'urgent')\nencode_numeric_zscore(df, 'hot')\nencode_numeric_zscore(df, 'num_failed_logins')\nencode_text_dummy(df, 'logged_in')\nencode_numeric_zscore(df, 'num_compromised')\nencode_numeric_zscore(df, 'root_shell')\nencode_numeric_zscore(df, 'su_attempted')\nencode_numeric_zscore(df, 'num_root')\nencode_numeric_zscore(df, 'num_file_creations')\nencode_numeric_zscore(df, 'num_shells')\nencode_numeric_zscore(df, 'num_access_files')\nencode_numeric_zscore(df, 'num_outbound_cmds')\nencode_text_dummy(df, 'is_host_login')\nencode_text_dummy(df, 'is_guest_login')\nencode_numeric_zscore(df, 'count')\nencode_numeric_zscore(df, 'srv_count')\nencode_numeric_zscore(df, 'serror_rate')\nencode_numeric_zscore(df, 'srv_serror_rate')\nencode_numeric_zscore(df, 'rerror_rate')\nencode_numeric_zscore(df, 'srv_rerror_rate')\nencode_numeric_zscore(df, 'same_srv_rate')\nencode_numeric_zscore(df, 'diff_srv_rate')\nencode_numeric_zscore(df, 'srv_diff_host_rate')\nencode_numeric_zscore(df, 'dst_host_count')\nencode_numeric_zscore(df, 'dst_host_srv_count')\nencode_numeric_zscore(df, 'dst_host_same_srv_rate')\nencode_numeric_zscore(df, 'dst_host_diff_srv_rate')\nencode_numeric_zscore(df, 'dst_host_same_src_port_rate')\nencode_numeric_zscore(df, 'dst_host_srv_diff_host_rate')\nencode_numeric_zscore(df, 'dst_host_serror_rate')\nencode_numeric_zscore(df, 'dst_host_srv_serror_rate')\nencode_numeric_zscore(df, 'dst_host_rerror_rate')\nencode_numeric_zscore(df, 'dst_host_srv_rerror_rate')\n\n# display 5 rows\n\ndf.dropna(inplace=True,axis=1)\ndf[0:5]\n# This is the numeric feature vector, as it goes to the neural net\n\n\n# Convert to numpy - Classification\nx_columns = df.columns.drop('outcome')\nx = df[x_columns].values\ndummies = pd.get_dummies(df['outcome']) # Classification\noutcomes = dummies.columns\nnum_classes = len(outcomes)\ny = dummies.values",
"_____no_output_____"
]
],
[
[
"We will attempt to predict what type of attack is underway. The outcome column specifies the attack type. A value of normal indicates that there is no attack underway. We display the outcomes; some attack types are much rarer than others.",
"_____no_output_____"
]
],
[
[
"df.groupby('outcome')['outcome'].count()",
"_____no_output_____"
]
],
[
[
"# Train the Neural Network\n\nWe now train the neural network to classify the different KDD99 outcomes. The code provided here implements a relatively simple neural with two hidden layers. We train it with the provided KDD99 data.",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nimport io\nimport requests\nimport numpy as np\nimport os\nfrom sklearn.model_selection import train_test_split\nfrom sklearn import metrics\nfrom tensorflow.keras.models import Sequential\nfrom tensorflow.keras.layers import Dense, Activation\nfrom tensorflow.keras.callbacks import EarlyStopping\n\n# Create a test/train split. 25% test\n# Split into train/test\nx_train, x_test, y_train, y_test = train_test_split(\n x, y, test_size=0.25, random_state=42)\n\n# Create neural net\nmodel = Sequential()\nmodel.add(Dense(10, input_dim=x.shape[1], activation='relu'))\nmodel.add(Dense(50, input_dim=x.shape[1], activation='relu'))\nmodel.add(Dense(10, input_dim=x.shape[1], activation='relu'))\nmodel.add(Dense(1, kernel_initializer='normal'))\nmodel.add(Dense(y.shape[1],activation='softmax'))\nmodel.compile(loss='categorical_crossentropy', optimizer='adam')\nmonitor = EarlyStopping(monitor='val_loss', min_delta=1e-3, \n patience=5, verbose=1, mode='auto')\nmodel.fit(x_train,y_train,validation_data=(x_test,y_test),\n callbacks=[monitor],verbose=2,epochs=1000)\n ",
"WARNING: Logging before flag parsing goes to stderr.\nW0810 23:45:15.921615 140735657337728 deprecation.py:323] From /Users/jheaton/miniconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow_core/python/ops/math_grad.py:1366: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\nInstructions for updating:\nUse tf.where in 2.0, which has the same broadcast rule as np.where\nW0810 23:45:16.019797 140735657337728 deprecation.py:323] From /Users/jheaton/miniconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow_core/python/keras/optimizer_v2/optimizer_v2.py:468: BaseResourceVariable.constraint (from tensorflow.python.ops.resource_variable_ops) is deprecated and will be removed in a future version.\nInstructions for updating:\nApply a constraint manually following the optimizer update step.\n"
]
],
[
[
"We can now evaluate the neural network. As you can see, the neural network achieves a 99% accuracy rate.",
"_____no_output_____"
]
],
[
[
"# Measure accuracy\npred = model.predict(x_test)\npred = np.argmax(pred,axis=1)\ny_eval = np.argmax(y_test,axis=1)\nscore = metrics.accuracy_score(y_eval, pred)\nprint(\"Validation score: {}\".format(score))",
"Validation score: 0.9971418392628698\n"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown",
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
],
[
"markdown"
],
[
"code"
]
] |
ecae306ee25778b1ff64e45ef7f5663499f8f86b | 25,220 | ipynb | Jupyter Notebook | deep-learning/CapsNET/Keras_Implementation/CapsNets Keras Implementation Cifar10 --NEED TO FIX THIS.ipynb | AadityaGupta/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 352dd6d9a785e22fde0ce53a6b0c2e56f4964950 | [
"Apache-2.0"
] | 3,266 | 2017-08-06T16:51:46.000Z | 2022-03-30T07:34:24.000Z | deep-learning/CapsNET/Keras_Implementation/CapsNets Keras Implementation Cifar10 --NEED TO FIX THIS.ipynb | AadityaGupta/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 352dd6d9a785e22fde0ce53a6b0c2e56f4964950 | [
"Apache-2.0"
] | 150 | 2017-08-28T14:59:36.000Z | 2022-03-11T23:21:35.000Z | deep-learning/CapsNET/Keras_Implementation/CapsNets Keras Implementation Cifar10 --NEED TO FIX THIS.ipynb | AadityaGupta/Artificial-Intelligence-Deep-Learning-Machine-Learning-Tutorials | 352dd6d9a785e22fde0ce53a6b0c2e56f4964950 | [
"Apache-2.0"
] | 1,449 | 2017-08-06T17:40:59.000Z | 2022-03-31T12:03:24.000Z | 41.617162 | 169 | 0.561063 | [
[
[
"import tensorflow as tf\nfrom keras import layers, models, optimizers, initializers\nfrom keras.utils import to_categorical\nimport numpy as np\nfrom keras.layers import Input, Conv2D, Activation, Dense, Flatten, Reshape, Dropout\nfrom keras.layers.merge import add\nfrom keras.regularizers import l2\nfrom keras.models import Model\n#from models.capsule_layers import CapsuleLayer, PrimaryCapsule, Length,Mask\nfrom keras.layers.normalization import BatchNormalization\nimport keras.backend as K\nfrom dataLoader import load_cifar_10, load_cifar_100\nimport os\nfrom keras.preprocessing.image import ImageDataGenerator\nfrom keras import callbacks\nfrom keras.utils.vis_utils import plot_model\nimport argparse",
"Using TensorFlow backend.\n"
]
],
[
[
"## Elements of Capsule Layers\n\nDefinitions will emerge here for all parts of Capsule Layer\n\n- Class Length\n- Class Mask\n- Squashing Function\n- Class Capsule Layer",
"_____no_output_____"
]
],
[
[
"#Define class Length\nclass Length(layers.Layer):\n \"\"\"\n Compute the length of vectors. This is used to compute a Tensor that has the same shape with y_true in margin_loss\n inputs: shape=[dim_1, ..., dim_{n-1}, dim_n]\n output: shape=[dim_1, ..., dim_{n-1}]\n \"\"\"\n def call(self, inputs, **kwargs):\n return K.sqrt(K.sum(K.square(inputs), -1))\n\n def compute_output_shape(self, input_shape):\n return input_shape[:-1]",
"_____no_output_____"
],
[
"# Class Mask\nclass Mask(layers.Layer):\n \"\"\"\n Mask Tensor layer by the max value in first axis\n Input shape: [None,d1,d2]\n Output shape: [None,d2]\n \"\"\"\n clip_value = (0,1)\n\n def Mask(self,clip_value=(0,1),**kwargs):\n self.clip_value = clip_value # what if clip value is not 0 and 1?\n\n def call(self,inputs,**kwargs):\n if type(inputs) is list:\n assert len(inputs) == 2\n inputs,mask = inputs\n else:\n x = inputs\n # enlarge range of values in x by mapping max(new_x) = 1, others \n x = (x - K.max(x,1,True)) / K.epsilon() + 1\n mask = K.clip(x,self.clip_value[0],self.clip_value[1]) # clip value beween 0 and 1\n masked_input = K.batch_dot(inputs, mask, [1,1])\n return masked_input\n\n def compute_output_shape(self, input_shape):\n if type(input_shape[0]) is tuple:\n return tuple([None,input_shape[0][-1]])\n \n else:\n return tuple([None, input_shape[-1]])",
"_____no_output_____"
],
[
"def squashing(vector, axis=-1):\n \"\"\"\n The non-linear activation used in Capsule. It drives the length of a large vector to near 1 and small vector to 0\n :param vectors: some vectors to be squashed, N-dim tensor\n :param axis: the axis to squash\n :return: a Tensor with same shape as input vectors\n \"\"\"\n s_squared_norm = K.sum(K.square(vector), axis, keepdims=True)\n scale = s_squared_norm/(1+s_squared_norm)/K.sqrt(s_squared_norm)\n return scale*vector",
"_____no_output_____"
],
[
"# Class Capsule Layer\nclass CapsuleLayer(layers.Layer):\n \"\"\"\n The capsule layer. It is similar to Dense layer. Dense layer has `in_num` inputs, each is a scalar, the output of the \n neuron from the former layer, and it has `out_num` output neurons. CapsuleLayer just expand the output of the neuron\n from scalar to vector. So its input shape = [None, input_num_capsule, input_dim_vector] and output shape = \\\n [None, num_capsule, dim_vector]. For Dense Layer, input_dim_vector = dim_vector = 1.\n \n :param num_capsule: number of capsules in this layer\n :param dim_vector: dimension of the output vectors of the capsules in this layer\n :param num_routings: number of iterations for the routing algorithm\n \"\"\"\n def __init__(self, num_capsule, dim_vector, num_routing=3,\n kernel_initializer='glorot_uniform',\n bias_initializer='zeros',\n **kwargs):\n super(CapsuleLayer, self).__init__(**kwargs)\n self.num_capsule = num_capsule\n self.dim_vector = dim_vector\n self.num_routing = num_routing\n self.kernel_initializer = initializers.get(kernel_initializer)\n self.bias_initializer = initializers.get(bias_initializer)\n\n def build(self,input_shape):\n assert len(input_shape) >= 3, \"Input tensor must have shape=[None, input_num_capsule,input_dim_vector]\"\n self.input_num_capsule = input_shape[1]\n self.input_dim_vector = input_shape[2]\n\n self.W = self.add_weight(shape=[self.input_num_capsule,self.num_capsule,self.input_dim_vector,self.dim_vector],\n initializer=self.kernel_initializer,\n name='W')\n self.bias = self.add_weight(shape=[1,self.input_num_capsule,self.num_capsule,1,1],\n initializer=self.bias_initializer,\n name='bias',trainable=False)\n self.built = True\n\n def call(self,inputs,training=None):\n # inputs.shape=[None, input_num_capsule, input_dim_vector]\n # Expand dims to [None, input_num_capsule, 1, 1, input_dim_vector]\n inputs_expand = K.expand_dims(K.expand_dims(inputs, 2), 2)\n\n # Replicate num_capsule dimension to prepare being multiplied by W\n # Now it has shape = [None, input_num_capsule, num_capsule, 1, input_dim_vector]\n inputs_tiled = K.tile(inputs_expand, [1, 1, self.num_capsule, 1, 1])\n\n \"\"\" \n # Compute `inputs * W` by expanding the first dim of W. More time-consuming and need batch_size.\n # Now W has shape = [batch_size, input_num_capsule, num_capsule, input_dim_vector, dim_vector]\n w_tiled = K.tile(K.expand_dims(self.W, 0), [self.batch_size, 1, 1, 1, 1])\n \n # Transformed vectors, inputs_hat.shape = [None, input_num_capsule, num_capsule, 1, dim_vector]\n inputs_hat = K.batch_dot(inputs_tiled, w_tiled, [4, 3])\n \"\"\"\n # Compute `inputs * W` by scanning inputs_tiled on dimension 0. This is faster but requires Tensorflow.\n # inputs_hat.shape = [None, input_num_capsule, num_capsule, 1, dim_vector]\n inputs_hat = tf.scan(lambda ac, x: K.batch_dot(x, self.W, [3, 2]),\n elems=inputs_tiled,\n initializer=K.zeros([self.input_num_capsule, self.num_capsule, 1, self.dim_vector]))\n \"\"\"\n # Routing algorithm V1. Use tf.while_loop in a dynamic way.\n def body(i, b, outputs):\n c = tf.nn.softmax(self.bias, dim=2) # dim=2 is the num_capsule dimension\n outputs = squash(K.sum(c * inputs_hat, 1, keepdims=True))\n b = b + K.sum(inputs_hat * outputs, -1, keepdims=True)\n return [i-1, b, outputs]\n cond = lambda i, b, inputs_hat: i > 0\n loop_vars = [K.constant(self.num_routing), self.bias, K.sum(inputs_hat, 1, keepdims=True)]\n _, _, outputs = tf.while_loop(cond, body, loop_vars)\n \"\"\"\n # Routing algorithm V2. Use iteration. V2 and V1 both work without much difference on performance\n\n assert self.num_routing > 0, 'The num_routing should be > 0.'\n for i in range(self.num_routing):\n c = tf.nn.softmax(self.bias, dim=2) # dim=2 is the num_capsule dimension\n # outputs.shape=[None, 1, num_capsule, 1, dim_vector]\n outputs = squash(K.sum(c * inputs_hat, 1, keepdims=True))\n\n # last iteration needs not compute bias which will not be passed to the graph any more anyway.\n if i != self.num_routing - 1:\n # self.bias = K.update_add(self.bias, K.sum(inputs_hat * outputs, [0, -1], keepdims=True))\n self.bias += K.sum(inputs_hat * outputs, -1, keepdims=True)\n # tf.summary.histogram('BigBee', self.bias) # for debugging\n\n return K.reshape(outputs, [-1, self.num_capsule, self.dim_vector])\n\n def compute_output_shape(self, input_shape):\n return tuple([None, self.num_capsule, self.dim_vector])",
"_____no_output_____"
],
[
"# Class Primary Capsule\ndef PrimaryCapsule(inputs, dim_vector, n_channels, kernel_size, strides, padding):\n \"\"\"\n Apply Conv2D `n_channels` times and concatenate all capsules\n :param inputs: 4D tensor, shape=[None, width, height, channels]\n :param dim_vector: the dim of the output vector of capsule\n :param n_channels: the number of types of capsules\n :return: output tensor, shape=[None, num_capsule, dim_vector]\n \"\"\"\n output = layers.Conv2D(filters=dim_vector*n_channels, kernel_size=kernel_size, strides=strides, padding=padding)(inputs)\n outputs = layers.Reshape(target_shape=[-1, dim_vector])(output)\n return layers.Lambda(squash)(outputs)",
"_____no_output_____"
]
],
[
[
"## Capsule Network Section\n\nMore details will emerge here on definition, choices, architecture and eventual code explanations.\n\n- Function Convolutional Block\n- Two versions of CapsNet (details to come later)\n- Function Margin Loss\n- Function to Train and to Test",
"_____no_output_____"
]
],
[
[
"def convolution_block(input,kernel_size=8,filters=16,kernel_regularizer=l2(1.e-4)):\n conv2 = Conv2D(filters=filters,kernel_size=kernel_size,kernel_regularizer=kernel_regularizer,\n kernel_initializer=\"he_normal\",padding=\"same\")(input)\n norm = BatchNormalization(axis=3)(conv2)\n activation = Activation(\"relu\")(norm)\n return activation",
"_____no_output_____"
],
[
"def CapsNet(input_shape,n_class,n_route,n_prime_caps=32,dense_size = (512,1024)):\n conv_filter = 256\n n_kernel = 24\n primary_channel =64\n primary_vector = 9\n vector_dim = 9\n\n target_shape = input_shape\n\n input = Input(shape=input_shape)\n\n # TODO: try leaky relu next time\n conv1 = Conv2D(filters=conv_filter,kernel_size=n_kernel, strides=1, padding='valid', activation='relu',name='conv1',kernel_initializer=\"he_normal\")(input)\n\n primary_cap = PrimaryCapsule(conv1,dim_vector=8, n_channels=64,kernel_size=9,strides=2,padding='valid')\n\n routing_layer = CapsuleLayer(num_capsule=n_class, dim_vector=vector_dim, num_routing=n_route,name='routing_layer')(primary_cap)\n\n output = Length(name='output')(routing_layer)\n\n y = Input(shape=(n_class,))\n masked = Mask()([routing_layer,y])\n \n x_recon = Dense(dense_size[0],activation='relu')(masked)\n\n for i in range(1,len(dense_size)):\n x_recon = Dense(dense_size[i],activation='relu')(x_recon)\n # Is there any other way to do \n x_recon = Dense(target_shape[0]*target_shape[1]*target_shape[2],activation='relu')(x_recon)\n x_recon = Reshape(target_shape=target_shape,name='output_recon')(x_recon)\n\n return Model([input,y],[output,x_recon])",
"_____no_output_____"
],
[
"# why using 512, 1024 Maybe to mimic original 10M params?\ndef CapsNetv2(input_shape,n_class,n_route,n_prime_caps=32,dense_size = (512,1024)):\n conv_filter = 64\n n_kernel = 16\n primary_channel =64\n primary_vector = 12\n capsule_dim_size = 8\n\n target_shape = input_shape\n\n input = Input(shape=input_shape)\n\n # TODO: try leaky relu next time\n conv_block_1 = convolution_block(input,kernel_size=16,filters=64)\n primary_cap = PrimaryCapsule(conv_block_1,dim_vector=capsule_dim_size,n_channels=primary_channel,kernel_size=9,strides=2,padding='valid') \n # Suppose this act like a max pooling \n routing_layer = CapsuleLayer(num_capsule=n_class,dim_vector=capsule_dim_size*2,num_routing=n_route,name='routing_layer_1')(primary_cap)\n output = Length(name='output')(routing_layer)\n\n y = Input(shape=(n_class,))\n masked = Mask()([routing_layer,y])\n \n x_recon = Dense(dense_size[0],activation='relu')(masked)\n\n for i in range(1,len(dense_size)):\n x_recon = Dense(dense_size[i],activation='relu')(x_recon)\n # Is there any other way to do \n x_recon = Dense(np.prod(target_shape),activation='relu')(x_recon)\n x_recon = Reshape(target_shape=target_shape,name='output_recon')(x_recon)\n\n # conv_block_2 = convolution_block(routing_layer)\n # b12_sum = add([conv_block_2,conv_block_1])\n\n return Model([input,y],[output,x_recon])",
"_____no_output_____"
],
[
"def margin_loss(y_true, y_pred):\n \"\"\"\n Margin loss for Eq.(4). When y_true[i, :] contains not just one `1`, this loss should work too. Not test it.\n :param y_true: [None, n_classes]\n :param y_pred: [None, num_capsule]\n :return: a scalar loss value.\n \"\"\"\n L = y_true * K.square(K.maximum(0., 0.9 - y_pred)) + \\\n 0.5 * (1 - y_true) * K.square(K.maximum(0., y_pred - 0.1))\n\n return K.mean(K.sum(L, 1))",
"_____no_output_____"
],
[
"def train(model, data, args):\n \"\"\"\n Training a CapsuleNet\n :param model: the CapsuleNet model\n :param data: a tuple containing training and testing data, like `((x_train, y_train), (x_test, y_test))`\n :param args: arguments\n :return: The trained model\n \"\"\"\n # unpacking the data\n (x_train, y_train), (x_test, y_test) = data\n\n # callbacks\n log = callbacks.CSVLogger(args.save_dir + '/log.csv')\n tb = callbacks.TensorBoard(log_dir=args.save_dir + '/tensorboard-logs',\n batch_size=args.batch_size, histogram_freq=args.debug)\n checkpoint = callbacks.ModelCheckpoint(args.save_dir + '/weights-{epoch:02d}.h5',\n save_best_only=True, save_weights_only=True, verbose=1)\n lr_decay = callbacks.LearningRateScheduler(schedule=lambda epoch: args.lr * (0.9 ** epoch))\n\n # compile the model\n model.compile(optimizer=optimizers.Adam(lr=args.lr),\n loss=[margin_loss, 'mse'],\n loss_weights=[1., args.lam_recon],\n metrics={'out_caps': 'accuracy'})\n\n \"\"\"\n # Training without data augmentation:\n model.fit([x_train, y_train], [y_train, x_train], batch_size=args.batch_size, epochs=args.epochs,\n validation_data=[[x_test, y_test], [y_test, x_test]], callbacks=[log, tb, checkpoint, lr_decay])\n \"\"\"\n\n # Begin: Training with data augmentation ---------------------------------------------------------------------#\n def train_generator(x, y, batch_size, shift_fraction=0.):\n train_datagen = ImageDataGenerator(width_shift_range=shift_fraction,\n height_shift_range=shift_fraction) # shift up to 2 pixel for MNIST\n generator = train_datagen.flow(x, y, batch_size=batch_size)\n while 1:\n x_batch, y_batch = generator.next()\n yield ([x_batch, y_batch], [y_batch, x_batch])\n\n # Training with data augmentation. If shift_fraction=0., also no augmentation.\n model.fit_generator(generator=train_generator(x_train, y_train, args.batch_size, args.shift_fraction),\n steps_per_epoch=int(y_train.shape[0] / args.batch_size),\n epochs=args.epochs,\n validation_data=[[x_test, y_test], [y_test, x_test]],\n callbacks=[log, tb, checkpoint, lr_decay])\n # End: Training with data augmentation -----------------------------------------------------------------------#\n\n model.save_weights(args.save_dir + '/trained_model.h5')\n print('Trained model saved to \\'%s/trained_model.h5\\'' % args.save_dir)\n\n from utils import plot_log\n plot_log(args.save_dir + '/log.csv', show=True)\n\n return model",
"_____no_output_____"
],
[
"def test(model, data):\n x_test, y_test = data\n y_pred, x_recon = model.predict([x_test, y_test], batch_size=100)\n print('-'*50)\n print('Test acc:', np.sum(np.argmax(y_pred, 1) == np.argmax(y_test, 1))/y_test.shape[0])\n\n import matplotlib.pyplot as plt\n from utils import combine_images\n from PIL import Image\n\n img = combine_images(np.concatenate([x_test[:50],x_recon[:50]]))\n image = img * 255\n Image.fromarray(image.astype(np.uint8)).save(\"real_and_recon.png\")\n print()\n print('Reconstructed images are saved to ./real_and_recon.png')\n print('-'*50)\n plt.imshow(plt.imread(\"real_and_recon.png\", ))\n plt.show()",
"_____no_output_____"
],
[
"def load_mnist():\n # the data, shuffled and split between train and test sets\n from keras.datasets import mnist\n (x_train, y_train), (x_test, y_test) = mnist.load_data()\n\n x_train = x_train.reshape(-1, 28, 28, 1).astype('float32') / 255.\n x_test = x_test.reshape(-1, 28, 28, 1).astype('float32') / 255.\n y_train = to_categorical(y_train.astype('float32'))\n y_test = to_categorical(y_test.astype('float32'))\n return (x_train, y_train), (x_test, y_test)",
"_____no_output_____"
],
[
"parser = argparse.ArgumentParser()\nparser.add_argument('--batch_size', default=100, type=int)\nparser.add_argument('--epochs', default=30, type=int)\nparser.add_argument('--lam_recon', default=0.392, type=float) # 784 * 0.0005, paper uses sum of SE, here uses MSE\nparser.add_argument('--num_routing', default=3, type=int) # num_routing should > 0\nparser.add_argument('--shift_fraction', default=0.1, type=float)\nparser.add_argument('--debug', default=0, type=int) # debug>0 will save weights by TensorBoard\nparser.add_argument('--save_dir', default='./result')\nparser.add_argument('--is_training', default=1, type=int)\nparser.add_argument('--weights', default=None)\nparser.add_argument('--lr', default=0.001, type=float)\nargs = parser.parse_args()\nprint(args)\nif not os.path.exists(args.save_dir):\n os.makedirs(args.save_dir)\n\n# load data\n(x_train, y_train), (x_test, y_test) = load_mnist()\n\n# define model\nmodel = CapsNet(input_shape=[28, 28, 1],\n n_class=len(np.unique(np.argmax(y_train, 1))),\n num_routing=args.num_routing)\nmodel.summary()\n\nplot_model(model, to_file=args.save_dir+'/model.png', show_shapes=True)\n\n# train or test\nif args.weights is not None: # init the model weights with provided one\n model.load_weights(args.weights)\n if args.is_training:\n train(model=model, data=((x_train, y_train), (x_test, y_test)), args=args)\n else: # as long as weights are given, will run testing\n if args.weights is None:\n print('No weights are provided. Will test using random initialized weights.')\n test(model=model, data=(x_test, y_test))",
"usage: ipykernel_launcher.py [-h] [--batch_size BATCH_SIZE] [--epochs EPOCHS]\n [--lam_recon LAM_RECON]\n [--num_routing NUM_ROUTING]\n [--shift_fraction SHIFT_FRACTION] [--debug DEBUG]\n [--save_dir SAVE_DIR] [--is_training IS_TRAINING]\n [--weights WEIGHTS] [--lr LR]\nipykernel_launcher.py: error: unrecognized arguments: -f /run/user/1000/jupyter/kernel-eeae7dd5-21d1-4216-8d68-9e7b23ac97e5.json\n"
]
]
] | [
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecae39b3c45c52ad4a170768e8494864f1484018 | 855 | ipynb | Jupyter Notebook | setup.ipynb | skleinbo/StatPhys2016 | 076507efe050f841968fda58e4096ded23a43044 | [
"MIT"
] | null | null | null | setup.ipynb | skleinbo/StatPhys2016 | 076507efe050f841968fda58e4096ded23a43044 | [
"MIT"
] | null | null | null | setup.ipynb | skleinbo/StatPhys2016 | 076507efe050f841968fda58e4096ded23a43044 | [
"MIT"
] | null | null | null | 17.44898 | 80 | 0.511111 | [
[
[
"empty"
]
]
] | [
"empty"
] | [
[
"empty"
]
] |
ecae4f6f674cf75cc8f243e7b5ac2276fe3b3993 | 9,888 | ipynb | Jupyter Notebook | PartIII.ipynb | riconaef/Airbnb_Seattle | 0bf77629c524c55817e5389c1eff3a8b50606067 | [
"FTL",
"CNRI-Python"
] | null | null | null | PartIII.ipynb | riconaef/Airbnb_Seattle | 0bf77629c524c55817e5389c1eff3a8b50606067 | [
"FTL",
"CNRI-Python"
] | null | null | null | PartIII.ipynb | riconaef/Airbnb_Seattle | 0bf77629c524c55817e5389c1eff3a8b50606067 | [
"FTL",
"CNRI-Python"
] | null | null | null | 41.029046 | 130 | 0.570388 | [
[
[
"# Question 3\nimport numpy as np\nimport pandas as pd\nimport matplotlib.pyplot as plt\nfrom sklearn.linear_model import LinearRegression\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import r2_score, mean_squared_error\nimport seaborn as sns\n%matplotlib\n\ndf = pd.read_csv('listings.csv')\n\ndef separator(df):\n '''\n Input: pandas dataframe with a column called \"amenities\"\n \n Output: A new pandas dataframe which only includes the amenities column\n \n This function checks the different amenities and returns a new dataframe with all different amenities:\n \n 1. Cleaning the strings and split the amenities in different rows.\n 2. Checking which amenities exist, which are available in the whole column.\n 3. Creates a new dataframe with the amenities in the columns.\n '''\n \n ## Cleaning the strings and splitting each amenity into a different column\n df['amenities'] = df['amenities'].replace('{|}| |\"', '', regex=True)\n df['amenities'] = df['amenities'].replace(',', ' ', regex=True)\n df_ame = pd.DataFrame(df['amenities'].str.split(expand=True))\n \n ## Checking which amenities exist and save them in a list \"amenities\"\n amenities = []\n for u in range(df_ame.shape[0]):\n for uu in range(df_ame.shape[1]):\n if (df_ame[uu][u] in amenities):\n True\n else:\n amenities += [df_ame[uu][u]]\n amenities = list(filter(None,amenities)) # delete None\n df_ame = df_ame.fillna(value=np.nan)\n \n ## Creates a new dataframe df_new with all amenities in a separate column (1 for given, 0 for not available) \n df_new = pd.DataFrame(index=range(len(df_ame)), columns=amenities)\n for i in range(len(df_new)):\n for ii in range(df_ame.shape[1]):\n var = df_ame.iloc[i][ii]\n if (df_ame.iloc[i][ii] in amenities):\n df_new[var].iloc[i] = 1\n else:\n False\n df_new = df_new.fillna(0)\n df_new = df_new.astype(int)\n \n return df_new\n\ndef clean_data(df, flag):\n '''\n INPUT\n df - pandas dataframe \n\n OUTPUT\n X - A matrix holding all of the variables you want to consider when predicting the response\n y - the corresponding response vector\n\n This function cleans df using the following steps to produce X and y:\n 1. Optional: Use the separator function to split the amenities column if you are interested in these features\n 2. Change all columns which contain \"t\" and \"f\" into 1 and 0\n 3. Change the price columns to float variables\n 4. Change the percent columns to float variables\n 5. Drop all rows in which all rows have the same value\n 6. Drop all the object columns. (Many of them are individual for each row and disturb the processing later)\n 7. Drop rows with missing price values, create y\n 8. Drop columns which have NAN in more than 75%\n 9. Drop the columns, which include prices, additionally the \"host_listings_count\" and \"host_total_listings_count\"\n are dropped because these columns have few outliers and disturb the processing later. \n 10. For each numeric variable in X, fill all NAN of the column with the mean value of the column.\n '''\n\n # Split the amenities column into the different variables with the separator function\n # The amenities can be excluded by setting the flag to 0\n # The separator function needs some time to run\n if flag == 1:\n df_ame = separator(df)\n df = pd.concat([df,df_ame],axis=1)\n \n # Change the columns with \"t\" and \"f\" into 1 and 0\n df = df.replace('t',1).replace('f',0)\n\n # Change the dollar prices from string to float\n dollar_column = ['price','weekly_price','monthly_price']\n for dollar_count in dollar_column:\n df[dollar_count] = df[dollar_count].str.replace('$', '').str.replace(',', '').astype(float)\n\n # Change the columns with percent from string to float\n percent_column = df.select_dtypes(include=['object']).columns\n for percent_count in percent_column:\n try:\n df[percent_count] = df[percent_count].str.replace('%', '').astype(float)\n except:\n True\n\n # Drop all columns in which all rows have the same value\n nunique = df.apply(pd.Series.nunique)\n cols_to_drop = nunique[nunique == 1].index\n df = df.drop(cols_to_drop, axis=1)\n\n # Drop object columns\n cat_vars = df.select_dtypes(include=['object'])\n df = df.drop(cat_vars,axis=1)\n \n # Drop rows with missing price values\n if (df['price'].isnull().mean() != 0):\n df = df.dropna(subset=['price'], axis=0)\n y = df['price']\n\n # Drop columns with more than 75% zeros\n too_many_NAN = list(df.columns[df.isnull().mean() > 0.75])\n for count_2 in too_many_NAN:\n df = df.drop([count_2], axis=1)\n\n # Drop price columns\n df = df.drop(['price','weekly_price','monthly_price'], axis=1)\n df = df.drop(['host_listings_count','host_total_listings_count'],axis=1)\n \n # Fill numeric columns with the mean\n num_vars = df.select_dtypes(include=['float', 'int32']).columns\n for col in num_vars:\n df[col].fillna((df[col].mean()), inplace=True) \n\n X = df\n return X, y\n\ndef coef_weights(coefficients, X_train):\n '''\n INPUT:\n coefficients - the coefficients of the linear model \n X_train - the training data, so the column names can be used\n OUTPUT:\n coefs_df - a dataframe holding the coefficient, estimate, and abs(estimate)\n \n Provides a dataframe that can be used to understand the most influential coefficients\n in a linear model by providing the coefficient estimates along with the name of the \n variable attached to the coefficient.\n '''\n coefs_df = pd.DataFrame()\n coefs_df['est_int'] = X_train.columns\n coefs_df['coefs'] = lm_model.coef_\n coefs_df['abs_coefs'] = np.abs(lm_model.coef_)\n coefs_df = coefs_df.sort_values('abs_coefs', ascending=False)\n return coefs_df\n\n# Say if amenities should be included or not\nflag = 0 # 1 for yes, 0 for no\n\n# Use the Clean_data function to create X and y\nX, y = clean_data(df, flag)\n\n# Split the data in a test and training set\nX_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.3,random_state = 6)\n\n# Create a LinearRegression model with normalized data\nlm_model = LinearRegression(normalize=True)\n\n# Fit our model with the training data\nlm_model.fit(X_train,y_train)\n\n# Predict our data using our test set\ny_pred = lm_model.predict(X_test)\n\n# Compare the predicted with the test data and return the r-value\nrsquared_score = r2_score(y_test,y_pred)\n\n# Use the function\ncoef_df = coef_weights(lm_model.coef_, X_train)\n\n# A quick look at the top results and the r-squared-Value\nprint('The r-squared-score is: ' + str(rsquared_score))\n\n# Plot the results in a bar plot\nfeatures = 20\nax = plt.bar(coef_df['est_int'][:features],coef_df['abs_coefs'][:features])\ny_pos = range(len(coef_df['est_int'][:features]))\nplt.xticks(y_pos, coef_df['est_int'][:features], rotation=90)\nif flag == 0:\n plt.title('Important features on the airbnb price\\n',fontsize = 20)\nelif flag == 1:\n plt.title('Important features on the airbnb price (ammenities included)\\n',fontsize = 20)\nplt.ylabel('absolute coefficient')\nplt.subplots_adjust(bottom=0.4)",
"Using matplotlib backend: Qt5Agg\nThe r-squared-score is: 0.5672529232782865\n"
]
]
] | [
"code"
] | [
[
"code"
]
] |
ecae606edf42aebb22eb905f67b1a18595221638 | 3,590 | ipynb | Jupyter Notebook | demos/Results.ipynb | krassowski/jupyter-helpers | 9feb0af6563b56d02688c18e1a9a415d15d9b1a2 | [
"MIT"
] | 45 | 2019-03-18T11:13:01.000Z | 2021-03-21T18:59:06.000Z | demos/Results.ipynb | krassowski/jupyter-helpers | 9feb0af6563b56d02688c18e1a9a415d15d9b1a2 | [
"MIT"
] | 6 | 2019-04-04T08:12:06.000Z | 2021-01-29T06:37:24.000Z | demos/Results.ipynb | krassowski/jupyter-helpers | 9feb0af6563b56d02688c18e1a9a415d15d9b1a2 | [
"MIT"
] | 5 | 2019-03-19T07:15:14.000Z | 2019-12-18T19:25:48.000Z | 26.014493 | 445 | 0.431755 | [
[
[
"from jupyter_helpers.selective_import import notebooks_importer",
"_____no_output_____"
],
[
"# this is intended to work\nfrom Data import data\ndata",
"Importing Jupyter notebook from Data.ipynb\n"
],
[
"# and this should fail\nfrom Data import vis",
"_____no_output_____"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code"
]
] |
ecae627c1bbe43a157407f711ff016d9227d4e73 | 23,606 | ipynb | Jupyter Notebook | notebooks/base_play_deep.ipynb | AloneGu/armin_kaggle_mnist | 85757d186d24ae9c561d026da3ed0a691ca4cda1 | [
"MIT"
] | null | null | null | notebooks/base_play_deep.ipynb | AloneGu/armin_kaggle_mnist | 85757d186d24ae9c561d026da3ed0a691ca4cda1 | [
"MIT"
] | null | null | null | notebooks/base_play_deep.ipynb | AloneGu/armin_kaggle_mnist | 85757d186d24ae9c561d026da3ed0a691ca4cda1 | [
"MIT"
] | null | null | null | 43.155393 | 352 | 0.577734 | [
[
[
"import pandas as pd\nimport numpy as np\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\n\n\nfrom sklearn.model_selection import train_test_split\nfrom sklearn.metrics import confusion_matrix\nimport itertools\n\nfrom keras.utils.np_utils import to_categorical # convert to one-hot-encoding\nfrom keras.models import Sequential\nfrom keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPool2D\nfrom keras.optimizers import RMSprop, Adam\nfrom keras.preprocessing.image import ImageDataGenerator\nfrom keras.callbacks import ReduceLROnPlateau",
"Using Theano backend.\nWARNING (theano.sandbox.cuda): The cuda backend is deprecated and will be removed in the next release (v0.10). Please switch to the gpuarray backend. You can get more information about how to switch at this URL:\n https://github.com/Theano/Theano/wiki/Converting-to-the-new-gpu-back-end%28gpuarray%29\n\nUsing gpu device 0: GeForce GTX 970M (CNMeM is disabled, cuDNN not available)\n"
],
[
"train = pd.read_csv(\"../input/train.csv\")\ntest = pd.read_csv(\"../input/test.csv\")",
"_____no_output_____"
],
[
"Y_train = train[\"label\"]\n\n# Drop 'label' column\nX_train = train.drop(labels = [\"label\"],axis = 1) \n\n# free some space\ndel train ",
"_____no_output_____"
],
[
"# Normalize the data\nX_train = X_train / 255.0\ntest = test / 255.0\n# Reshape image in 3 dimensions (height = 28px, width = 28px , canal = 1)\nX_train = X_train.values.reshape(-1,1,28,28)\ntest = test.values.reshape(-1,1,28,28)",
"_____no_output_____"
],
[
"Y_train = to_categorical(Y_train, num_classes = 10)\n\n# set random seed for network, maybe not useful\nfrom numpy.random import seed \nseed(42)\n\n# Split the train and the validation set for the fitting\nX_train, X_val, Y_train, Y_val = train_test_split(X_train, Y_train, test_size = 0.1, random_state=2)\nprint(X_train.shape, Y_train.shape)",
"(37800, 1, 28, 28) (37800, 10)\n"
],
[
"model = Sequential()\n\n# conv1\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu', input_shape = (1,28,28)))\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu'))\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu'))\nmodel.add(MaxPool2D(pool_size=(2,2)))\n\n# conv2\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu', input_shape = (1,28,28)))\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu'))\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu'))\nmodel.add(MaxPool2D(pool_size=(2,2)))\n\n# conv3\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu', input_shape = (1,28,28)))\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu'))\nmodel.add(Conv2D(filters = 8, kernel_size = (3,3),padding = 'same', \n activation ='relu'))\nmodel.add(MaxPool2D(pool_size=(2,2)))\n\n\n# flatten\nmodel.add(Flatten())\nmodel.add(Dense(512, activation = \"relu\"))\nmodel.add(Dropout(0.3))\nmodel.add(Dense(256, activation = \"relu\"))\nmodel.add(Dropout(0.3))\nmodel.add(Dense(10, activation = \"softmax\"))\n# Compile the model\n\nopt = Adam(lr=0.001)\nmodel.compile(optimizer = opt , loss = \"categorical_crossentropy\", metrics=[\"accuracy\"])\nprint(\"compile done\")",
"compile done\n"
],
[
"datagen = ImageDataGenerator(\n featurewise_center=False, # set input mean to 0 over the dataset\n samplewise_center=False, # set each sample mean to 0\n featurewise_std_normalization=False, # divide inputs by std of the dataset\n samplewise_std_normalization=False, # divide each input by its std\n zca_whitening=False, # apply ZCA whitening\n rotation_range=10, # randomly rotate images in the range (degrees, 0 to 180)\n zoom_range = 0.1, # Randomly zoom image \n width_shift_range=0.1, # randomly shift images horizontally (fraction of total width)\n height_shift_range=0.1, # randomly shift images vertically (fraction of total height)\n horizontal_flip=False, # randomly flip images\n vertical_flip=False) # randomly flip images\n\n\ndatagen.fit(X_train)",
"/home/jac/.local/lib/python3.5/site-packages/keras/preprocessing/image.py:653: UserWarning: Expected input to be images (as Numpy array) following the data format convention \"channels_first\" (channels on axis 1), i.e. expected either 1, 3 or 4 channels on axis 1. However, it was passed an array with shape (37800, 1, 28, 28) (1 channels).\n ' (' + str(x.shape[self.channel_axis]) + ' channels).')\n"
],
[
"from keras.callbacks import CSVLogger, ModelCheckpoint, LearningRateScheduler, ReduceLROnPlateau\nfrom keras.models import load_model\n\nlearning_rate_reduction = ReduceLROnPlateau(monitor='val_acc', \n patience=5, \n verbose=1, \n factor=0.6, \n min_lr=0.00001)\n \nbest_model_path = 'deep_best_m_v2.h5'\nbest_model = ModelCheckpoint(filepath=best_model_path, monitor='val_loss', save_best_only=True, verbose=1)\nepochs = 80\nsteps_per_epoch = 100\nbatch_size = 64\nmodel.fit_generator(datagen.flow(X_train,Y_train, batch_size=batch_size),\n epochs = epochs, validation_data = (X_val,Y_val),\n verbose = 2, steps_per_epoch=steps_per_epoch,\n callbacks=[best_model,learning_rate_reduction])",
"Epoch 1/80\nEpoch 00000: val_loss improved from inf to 0.53503, saving model to best_m_v2.h5\n10s - loss: 1.7223 - acc: 0.3739 - val_loss: 0.5350 - val_acc: 0.8181\nEpoch 2/80\nEpoch 00001: val_loss improved from 0.53503 to 0.29625, saving model to best_m_v2.h5\n10s - loss: 0.6501 - acc: 0.7853 - val_loss: 0.2962 - val_acc: 0.9086\nEpoch 3/80\nEpoch 00002: val_loss improved from 0.29625 to 0.19683, saving model to best_m_v2.h5\n9s - loss: 0.4460 - acc: 0.8600 - val_loss: 0.1968 - val_acc: 0.9343\nEpoch 4/80\nEpoch 00003: val_loss improved from 0.19683 to 0.17636, saving model to best_m_v2.h5\n10s - loss: 0.3525 - acc: 0.8852 - val_loss: 0.1764 - val_acc: 0.9433\nEpoch 5/80\nEpoch 00004: val_loss did not improve\n9s - loss: 0.3209 - acc: 0.9009 - val_loss: 0.1887 - val_acc: 0.9367\nEpoch 6/80\nEpoch 00005: val_loss improved from 0.17636 to 0.13464, saving model to best_m_v2.h5\n10s - loss: 0.3115 - acc: 0.9000 - val_loss: 0.1346 - val_acc: 0.9564\nEpoch 7/80\nEpoch 00006: val_loss did not improve\n9s - loss: 0.2698 - acc: 0.9152 - val_loss: 0.1389 - val_acc: 0.9552\nEpoch 8/80\nEpoch 00007: val_loss improved from 0.13464 to 0.12412, saving model to best_m_v2.h5\n10s - loss: 0.2439 - acc: 0.9253 - val_loss: 0.1241 - val_acc: 0.9607\nEpoch 9/80\nEpoch 00008: val_loss improved from 0.12412 to 0.11392, saving model to best_m_v2.h5\n9s - loss: 0.2267 - acc: 0.9313 - val_loss: 0.1139 - val_acc: 0.9636\nEpoch 10/80\nEpoch 00009: val_loss improved from 0.11392 to 0.10843, saving model to best_m_v2.h5\n9s - loss: 0.2193 - acc: 0.9327 - val_loss: 0.1084 - val_acc: 0.9671\nEpoch 11/80\nEpoch 00010: val_loss did not improve\n9s - loss: 0.2096 - acc: 0.9364 - val_loss: 0.1116 - val_acc: 0.9643\nEpoch 12/80\nEpoch 00011: val_loss did not improve\n9s - loss: 0.2088 - acc: 0.9333 - val_loss: 0.1114 - val_acc: 0.9664\nEpoch 13/80\nEpoch 00012: val_loss improved from 0.10843 to 0.08724, saving model to best_m_v2.h5\n10s - loss: 0.2008 - acc: 0.9373 - val_loss: 0.0872 - val_acc: 0.9717\nEpoch 14/80\nEpoch 00013: val_loss did not improve\n9s - loss: 0.1834 - acc: 0.9447 - val_loss: 0.1070 - val_acc: 0.9681\nEpoch 15/80\nEpoch 00014: val_loss did not improve\n10s - loss: 0.1728 - acc: 0.9498 - val_loss: 0.0931 - val_acc: 0.9710\nEpoch 16/80\nEpoch 00015: val_loss did not improve\n9s - loss: 0.1712 - acc: 0.9473 - val_loss: 0.0960 - val_acc: 0.9700\nEpoch 17/80\nEpoch 00016: val_loss improved from 0.08724 to 0.08405, saving model to best_m_v2.h5\n10s - loss: 0.1599 - acc: 0.9513 - val_loss: 0.0840 - val_acc: 0.9740\nEpoch 18/80\nEpoch 00017: val_loss did not improve\n9s - loss: 0.1703 - acc: 0.9472 - val_loss: 0.0905 - val_acc: 0.9724\nEpoch 19/80\nEpoch 00018: val_loss improved from 0.08405 to 0.07993, saving model to best_m_v2.h5\n10s - loss: 0.1643 - acc: 0.9509 - val_loss: 0.0799 - val_acc: 0.9748\nEpoch 20/80\nEpoch 00019: val_loss improved from 0.07993 to 0.07485, saving model to best_m_v2.h5\n8s - loss: 0.1600 - acc: 0.9522 - val_loss: 0.0748 - val_acc: 0.9764\nEpoch 21/80\nEpoch 00020: val_loss did not improve\n8s - loss: 0.1371 - acc: 0.9583 - val_loss: 0.0789 - val_acc: 0.9786\nEpoch 22/80\nEpoch 00021: val_loss improved from 0.07485 to 0.07321, saving model to best_m_v2.h5\n9s - loss: 0.1515 - acc: 0.9544 - val_loss: 0.0732 - val_acc: 0.9781\nEpoch 23/80\nEpoch 00022: val_loss did not improve\n10s - loss: 0.1368 - acc: 0.9591 - val_loss: 0.0796 - val_acc: 0.9750\nEpoch 24/80\nEpoch 00023: val_loss improved from 0.07321 to 0.06619, saving model to best_m_v2.h5\n9s - loss: 0.1330 - acc: 0.9606 - val_loss: 0.0662 - val_acc: 0.9779\nEpoch 25/80\nEpoch 00024: val_loss did not improve\n9s - loss: 0.1374 - acc: 0.9584 - val_loss: 0.0683 - val_acc: 0.9795\nEpoch 26/80\nEpoch 00025: val_loss did not improve\n9s - loss: 0.1335 - acc: 0.9580 - val_loss: 0.0766 - val_acc: 0.9745\nEpoch 27/80\nEpoch 00026: val_loss did not improve\n9s - loss: 0.1322 - acc: 0.9606 - val_loss: 0.0721 - val_acc: 0.9774\nEpoch 28/80\nEpoch 00027: val_loss improved from 0.06619 to 0.06498, saving model to best_m_v2.h5\n10s - loss: 0.1377 - acc: 0.9567 - val_loss: 0.0650 - val_acc: 0.9807\nEpoch 29/80\nEpoch 00028: val_loss did not improve\n9s - loss: 0.1350 - acc: 0.9575 - val_loss: 0.0651 - val_acc: 0.9781\nEpoch 30/80\nEpoch 00029: val_loss improved from 0.06498 to 0.06378, saving model to best_m_v2.h5\n10s - loss: 0.1236 - acc: 0.9614 - val_loss: 0.0638 - val_acc: 0.9810\nEpoch 31/80\nEpoch 00030: val_loss did not improve\n9s - loss: 0.1276 - acc: 0.9597 - val_loss: 0.0739 - val_acc: 0.9755\nEpoch 32/80\nEpoch 00031: val_loss did not improve\n10s - loss: 0.1207 - acc: 0.9620 - val_loss: 0.0810 - val_acc: 0.9764\nEpoch 33/80\nEpoch 00032: val_loss improved from 0.06378 to 0.05380, saving model to best_m_v2.h5\n9s - loss: 0.1150 - acc: 0.9667 - val_loss: 0.0538 - val_acc: 0.9843\nEpoch 34/80\nEpoch 00033: val_loss improved from 0.05380 to 0.05203, saving model to best_m_v2.h5\n10s - loss: 0.1087 - acc: 0.9677 - val_loss: 0.0520 - val_acc: 0.9836\nEpoch 35/80\nEpoch 00034: val_loss did not improve\n9s - loss: 0.1249 - acc: 0.9619 - val_loss: 0.0597 - val_acc: 0.9812\nEpoch 36/80\nEpoch 00035: val_loss did not improve\n9s - loss: 0.1070 - acc: 0.9689 - val_loss: 0.0609 - val_acc: 0.9807\nEpoch 37/80\nEpoch 00036: val_loss did not improve\n10s - loss: 0.1095 - acc: 0.9653 - val_loss: 0.0601 - val_acc: 0.9814\nEpoch 38/80\nEpoch 00037: val_loss did not improve\n9s - loss: 0.1249 - acc: 0.9619 - val_loss: 0.0667 - val_acc: 0.9800\nEpoch 39/80\nEpoch 00038: val_loss did not improve\n\nEpoch 00038: reducing learning rate to 0.0006000000284984708.\n10s - loss: 0.0996 - acc: 0.9688 - val_loss: 0.0578 - val_acc: 0.9812\nEpoch 40/80\nEpoch 00039: val_loss did not improve\n9s - loss: 0.1016 - acc: 0.9686 - val_loss: 0.0538 - val_acc: 0.9812\nEpoch 41/80\nEpoch 00040: val_loss improved from 0.05203 to 0.04468, saving model to best_m_v2.h5\n10s - loss: 0.0966 - acc: 0.9714 - val_loss: 0.0447 - val_acc: 0.9852\nEpoch 42/80\nEpoch 00041: val_loss did not improve\n9s - loss: 0.0896 - acc: 0.9729 - val_loss: 0.0529 - val_acc: 0.9829\nEpoch 43/80\nEpoch 00042: val_loss did not improve\n9s - loss: 0.0973 - acc: 0.9706 - val_loss: 0.0547 - val_acc: 0.9855\nEpoch 44/80\nEpoch 00043: val_loss did not improve\n9s - loss: 0.0781 - acc: 0.9734 - val_loss: 0.0456 - val_acc: 0.9855\nEpoch 45/80\nEpoch 00044: val_loss did not improve\n9s - loss: 0.0840 - acc: 0.9736 - val_loss: 0.0466 - val_acc: 0.9852\nEpoch 46/80\nEpoch 00045: val_loss improved from 0.04468 to 0.04293, saving model to best_m_v2.h5\n9s - loss: 0.0989 - acc: 0.9703 - val_loss: 0.0429 - val_acc: 0.9879\nEpoch 47/80\nEpoch 00046: val_loss did not improve\n9s - loss: 0.0932 - acc: 0.9734 - val_loss: 0.0457 - val_acc: 0.9850\nEpoch 48/80\nEpoch 00047: val_loss did not improve\n10s - loss: 0.0951 - acc: 0.9737 - val_loss: 0.0458 - val_acc: 0.9876\nEpoch 49/80\nEpoch 00048: val_loss did not improve\n9s - loss: 0.0749 - acc: 0.9748 - val_loss: 0.0455 - val_acc: 0.9874\nEpoch 50/80\nEpoch 00049: val_loss improved from 0.04293 to 0.04207, saving model to best_m_v2.h5\n9s - loss: 0.0668 - acc: 0.9803 - val_loss: 0.0421 - val_acc: 0.9874\nEpoch 51/80\nEpoch 00050: val_loss did not improve\n9s - loss: 0.0731 - acc: 0.9784 - val_loss: 0.0516 - val_acc: 0.9843\nEpoch 52/80\nEpoch 00051: val_loss improved from 0.04207 to 0.04147, saving model to best_m_v2.h5\n\nEpoch 00051: reducing learning rate to 0.0003600000170990825.\n9s - loss: 0.0880 - acc: 0.9727 - val_loss: 0.0415 - val_acc: 0.9871\nEpoch 53/80\nEpoch 00052: val_loss did not improve\n9s - loss: 0.0862 - acc: 0.9736 - val_loss: 0.0424 - val_acc: 0.9876\nEpoch 54/80\nEpoch 00053: val_loss improved from 0.04147 to 0.03674, saving model to best_m_v2.h5\n9s - loss: 0.0621 - acc: 0.9800 - val_loss: 0.0367 - val_acc: 0.9879\nEpoch 55/80\nEpoch 00054: val_loss did not improve\n10s - loss: 0.0763 - acc: 0.9770 - val_loss: 0.0426 - val_acc: 0.9876\nEpoch 56/80\nEpoch 00055: val_loss did not improve\n9s - loss: 0.0831 - acc: 0.9773 - val_loss: 0.0400 - val_acc: 0.9860\nEpoch 57/80\nEpoch 00056: val_loss improved from 0.03674 to 0.03563, saving model to best_m_v2.h5\n10s - loss: 0.0752 - acc: 0.9788 - val_loss: 0.0356 - val_acc: 0.9886\nEpoch 58/80\nEpoch 00057: val_loss improved from 0.03563 to 0.03465, saving model to best_m_v2.h5\n9s - loss: 0.0766 - acc: 0.9766 - val_loss: 0.0346 - val_acc: 0.9879\nEpoch 59/80\n"
],
[
"model = load_model(best_model_path) # try callback model\n# predict results\nresults = model.predict(test)\n# select the indix with the maximum probability\nresults = np.argmax(results,axis = 1)\nresults = pd.Series(results,name=\"Label\")\nimport arrow\nts = str(arrow.now())[:-10].replace(':','_').replace('.',\"_\")\nres_file = \"deep_play_cnn_mnist_datagen_{}.csv\".format(ts)\nsubmission = pd.concat([pd.Series(range(1,28001),name = \"ImageId\"),results],axis = 1)\nsubmission.to_csv(res_file,index=False)\nprint('save done',res_file)",
"save done deep_play_cnn_mnist_datagen_2017-09-07T10_30_43_60.csv\n"
]
]
] | [
"code"
] | [
[
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecae743281219e7e0d03edc41c968a84429022ec | 90,557 | ipynb | Jupyter Notebook | basics/first/Ch09 Data visualizations.ipynb | febin-varghese/Data-Science | 25f4f186019573a8355a90300bcaac2bf0e88e13 | [
"BSD-3-Clause"
] | 1 | 2021-01-09T16:53:51.000Z | 2021-01-09T16:53:51.000Z | basics/first/Ch09 Data visualizations.ipynb | febin-varghese/Data-Science | 25f4f186019573a8355a90300bcaac2bf0e88e13 | [
"BSD-3-Clause"
] | null | null | null | basics/first/Ch09 Data visualizations.ipynb | febin-varghese/Data-Science | 25f4f186019573a8355a90300bcaac2bf0e88e13 | [
"BSD-3-Clause"
] | null | null | null | 89.571711 | 19,960 | 0.778504 | [
[
[
"# Data visualizations",
"_____no_output_____"
],
[
"## Seaborn with heatmaps",
"_____no_output_____"
]
],
[
[
"import pandas as pd\nimport matplotlib.pyplot as plt\n%matplotlib inline",
"_____no_output_____"
],
[
"import seaborn as sns",
"_____no_output_____"
],
[
"oo = pd.read_csv('data/olympics.csv',skiprows=4)\noo.head()",
"_____no_output_____"
]
],
[
[
"### Using the Olympic dataset, present a summary of the total medals won by participating countries in the 2008 Olympics.",
"_____no_output_____"
]
],
[
[
"lo = oo[oo.Edition == 2008]\nlo",
"_____no_output_____"
],
[
"g = lo.groupby(['NOC','Medal']).size().unstack('Medal',fill_value=0)\ng = g.sort_values(['Gold','Silver','Bronze'],ascending=False)[['Gold','Silver','Bronze']]\ng",
"_____no_output_____"
],
[
"sns.heatmap(g)",
"_____no_output_____"
],
[
"g = g.transpose()\ng",
"_____no_output_____"
],
[
"plt.figure(figsize=(16,5))\nsns.heatmap(g)",
"_____no_output_____"
]
],
[
[
"## Creating your own colormaps",
"_____no_output_____"
]
],
[
[
"g = oo.groupby(['Athlete','Medal']).size().unstack('Medal',fill_value=0)\ng.sort_values(['Gold','Silver','Bronze'],ascending=False)[['Gold','Silver','Bronze']].head().plot(kind='bar')",
"_____no_output_____"
],
[
"from matplotlib.colors import ListedColormap",
"_____no_output_____"
],
[
"sns.color_palette()",
"_____no_output_____"
],
[
"sns.palplot(sns.color_palette())",
"_____no_output_____"
],
[
"gsb = ['#dbb40c','#c5c9c7','#a87900']\nsns.palplot(sns.color_palette(gsb))",
"_____no_output_____"
],
[
"my_gsb = ListedColormap(sns.color_palette(gsb))",
"_____no_output_____"
],
[
"g = oo.groupby(['Athlete','Medal']).size().unstack('Medal',fill_value=0)\ng = g.sort_values(['Gold','Silver','Bronze'],ascending=False)[['Gold','Silver','Bronze']].head()\ng.plot(kind='bar',colormap=my_gsb)",
"_____no_output_____"
]
]
] | [
"markdown",
"code",
"markdown",
"code",
"markdown",
"code"
] | [
[
"markdown",
"markdown"
],
[
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code"
],
[
"markdown"
],
[
"code",
"code",
"code",
"code",
"code",
"code",
"code"
]
] |
ecae7a7956ecc81b192bf1704203409dbc4a4f24 | 29,490 | ipynb | Jupyter Notebook | src/disney_subquery.ipynb | prasertcbs/sql_basic | 509e9e875bdbc7f35012b33886098c3c9010ae19 | [
"MIT"
] | null | null | null | src/disney_subquery.ipynb | prasertcbs/sql_basic | 509e9e875bdbc7f35012b33886098c3c9010ae19 | [
"MIT"
] | null | null | null | src/disney_subquery.ipynb | prasertcbs/sql_basic | 509e9e875bdbc7f35012b33886098c3c9010ae19 | [
"MIT"
] | null | null | null | 50.410256 | 2,135 | 0.283384 | [
[
[
"empty"
]
]
] | [
"empty"
] | [
[
"empty"
]
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.