Tensorflow:模型调参

 

 

Tensorflow中使用gridsearch

1 使用tf.contrib.learn.estimators

使用tf中自带的Estimator将自定义的tf模型转换成估计器,输入到sklearn中的gridesearch运行。

# My custom model. 
# Feature request: New params dict with values filled by GridSearchCV
def cnn_model(X, Y, params):
  stride = params['stride']
  ... custom model definition here ...

# Create the Convnet classifier
cnn_classifier = learn.TensorFlowEstimator(model_fn=cnn_model)

# Grid search on different stride values.
parameters = {'stride': [1, 2, 3],}
grid_searcher = GridSearchCV(cnn_classifier, parameters)
grid_searcher.fit(X, Y)

可能的报错
WARNING:tensorflow:Using temporary folder as model directory: C:\Users\piting.pt\AppData\Local\Temp\tmpufiz6_ts

[Pass grid search params to TensorFlowEstimator custom model #2030 ]

这种方式需要使用到tf.contrib.learn中的estimators,比较麻烦。未测试出来。

[Creating Estimators in tf.contrib.learn ]

2 直接将自定义的模型修改成具有sklearn中estimators的功能

from: -柚子皮-

ref:

 

你可能感兴趣的:(Tensorflow,调参,tensorflow)