Is there something big broken in the tensorflow framework or am I just making some simple mistakes here. I tried to get the GMM or KMeans clustering to work but I'm totally stuck.
import numpy as np
import tensorflow as tf
from tensorflow.contrib.learn.python.learn.estimators.kmeans import KMeansClustering
def make_random_centers(num_centers, num_dims):
return np.round(np.random.rand(num_centers,
num_dims).astype(np.float32) * 500)
def make_random_points(centers, num_points):
num_centers, num_dims = centers.shape
assignments = np.random.choice(num_centers, num_points)
offsets = np.round(np.random.randn(num_points,
num_dims).astype(np.float32) * 20)
points = centers[assignments] + offsets
return points
num_centers = 3
num_dims = 2
num_points = 100
true_centers = make_random_centers(num_centers, num_dims)
points = make_random_points(true_centers, num_points)
print(points.shape)
print(points.dtype)
km = KMeansClustering(num_centers)
km.fit(x=points)
clusters = km.clusters()
print(clusters)
I'm getting a InvalidArgumentError though my data seems to be the correct shape and type (= (100, 2), float32):
InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'input' with dtype float and shape [?,2]
答案 0 :(得分:-1)
尝试使用def get_input_fn(x):
def input_fn():
return tf.constant(x.astype('float32')), None
return input_fn
这样的
// For Woocommerce version 3 and above only
add_filter( 'woocommerce_loop_add_to_cart_link', 'filter_loop_add_to_cart_link', 20, 3 );
function filter_loop_add_to_cart_link( $button, $product, $args = array() ) {
if( $product->is_in_stock() ) return $button;
// HERE set your button text (when product is not on stock)
$button_text = __('Not available', 'woocommerce');
// HERE set your button STYLING (when product is not on stock)
$color = "#777"; // Button text color
$background = "#aaa"; // Button background color
// Changing and disbling the button when products are not in stock
$style = 'color:'.$color.';background-color:'.$background.';cursor:not-allowed;';
return sprintf( '<a class="button disabled" style="%s">%s</a>', $style, $button_text );
}