标签: talos

tf.data.Dataset:不得为给定的输入类型指定 `batch_size` 参数

我使用的Talos和谷歌colab TPU运行的超参数调整Keras模型。请注意,我使用的是 Tensorflow 1.15.0 和 Keras 2.2.4-tf。

import os
import tensorflow as tf
import talos as ta
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
from tensorflow.keras.optimizers import Adam
from sklearn.model_selection import train_test_split

def iris_model(x_train, y_train, x_val, y_val, params):

    # Specify a distributed strategy to use TPU
    resolver = tf.contrib.cluster_resolver.TPUClusterResolver(tpu='grpc://' + os.environ['COLAB_TPU_ADDR'])
    tf.contrib.distribute.initialize_tpu_system(resolver)
    strategy = tf.contrib.distribute.TPUStrategy(resolver)

    # Use the strategy to create and compile a Keras model
    with strategy.scope():
      model = Sequential()
      model.add(Dense(32, input_shape=(4,), activation=tf.nn.relu, …
Run Code Online (Sandbox Code Playgroud)

keras tensorflow google-colaboratory google-cloud-tpu talos

12
推荐指数
1
解决办法
5983
查看次数

5
推荐指数
1
解决办法
974
查看次数